Skip to content

Instantly share code, notes, and snippets.

@wilkersoncs
Created June 2, 2018 06:35
Show Gist options
  • Save wilkersoncs/c3a16f828564b7af44da2a18c1148786 to your computer and use it in GitHub Desktop.
Save wilkersoncs/c3a16f828564b7af44da2a18c1148786 to your computer and use it in GitHub Desktop.
Kickstart to create CentOS 7 PXE Server with sample network install kickstart
#version=DEVEL
##Adapted from procedures from https://www.linuxtechi.com/configure-pxe-installation-server-centos-7/
##Use by pressing tab on CentOS install screen and adding
## ks=hd:sdb1:/ks-pxe.cfg
##Make sure target system has 2GB of RAM
firewall --disabled
selinux --disabled
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
cdrom
# Use text mode install
text
# Accept license
eula --agreed
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=us --xlayouts=''
# System language
lang en_US.UTF-8
# Network information
network --bootproto=static --ip=172.168.1.11 --device=ens33
network --hostname=pxe
# Root password Pxe@123#
rootpw --iscrypted $1$e2wrcGGX$tZPQKPsXVhNmbiGg53MN41
## To generate another password, run:
##openssl passwd -1 Pxe@123#
## Replace above with generated output
# System services
services --enabled="chronyd"
# Do not configure the X Window System
skipx
# System timezone
timezone America/Phoenix --isUtc
user --groups=wheel --name=rhuser
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
autopart --type=lvm
# Partition clearing information
clearpart --all --initlabel --drives=sda
##Uncomment to auto reboot
#reboot --eject
##To install GUI, change ^minimal to ^graphical-server-environment
## add @gnome-desktop & @internet-browser and comment out skipx above
%packages
@^minimal
@core --nodefaults
chrony
kexec-tools
dhcp
tftp
tftp-server
syslinux
xinetd
vsftpd
%end
%addon com_redhat_kdump --enable --reserve-mb='auto'
%end
%post --log=/root/kickstart-post2.log --erroronfail
set -x
cat <<-DHCPDCONF >> /etc/dhcp/dhcpd.conf
# DHCP Server Configuration file.
ddns-update-style interim;
ignore client-updates;
authoritative;
allow booting;
allow bootp;
allow unknown-clients;
# internal subnet for my DHCP Server
subnet 172.168.1.0 netmask 255.255.255.0 {
range 172.168.1.21 172.168.1.151;
option domain-name-servers 172.168.1.11;
option domain-name "pxe.example.com";
option routers 172.168.1.11;
option broadcast-address 172.168.1.255;
default-lease-time 600;
max-lease-time 7200;
# IP of PXE Server
next-server 172.168.1.11;
filename "pxelinux.0";
}
DHCPDCONF
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot
cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot
cp /usr/share/syslinux/memdisk /var/lib/tftpboot
cp /usr/share/syslinux/mboot.c32 /var/lib/tftpboot
cp /usr/share/syslinux/chain.c32 /var/lib/tftpboot
mkdir /var/lib/tftpboot/pxelinux.cfg
mkdir /var/lib/tftpboot/networkboot
mkdir /mnt/cdrom
mount /dev/cdrom /mnt/cdrom
cp /mnt/cdrom/images/pxeboot/vmlinuz /var/lib/tftpboot/networkboot/
cp /mnt/cdrom/images/pxeboot/initrd.img /var/lib/tftpboot/networkboot/
cd /mnt/cdrom
mkdir -p /var/ftp/pub
cp -av * /var/ftp/pub/
sed -i 's/disable.*= .*/disable = no/g' /etc/xinetd.d/tftp
cat <<-DEFAULT > /var/lib/tftpboot/pxelinux.cfg/default
default menu.c32
prompt 0
timeout 30
MENU TITLE LinuxTechi.com PXE Menu
LABEL centos7_x64
MENU LABEL CentOS 7_X64
KERNEL /networkboot/vmlinuz
APPEND initrd=/networkboot/initrd.img inst.repo=ftp://172.168.1.11/pub ks=ftp://172.168.1.11/pub/centos7.cfg
DEFAULT
cat <<-CENTOS7CFG > /var/ftp/pub/centos7.cfg
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use FTP installation media
url --url="ftp://172.168.1.11/pub/"
# Root password Pxe@123# need to escape \$
rootpw --iscrypted \$1\$e2wrcGGX\$tZPQKPsXVhNmbiGg53MN41
# System authorization information
auth useshadow passalgo=sha512
# Use graphical install
graphical
firstboot disable
# System keyboard
keyboard us
# System language
lang en_US
# SELinux configuration
selinux disabled
# Installation logging level
logging level=info
# System timezone
timezone America/Phoenix
# System bootloader configuration
bootloader location=mbr
clearpart --all --initlabel
part swap --asprimary --fstype="swap" --size=1024
part /boot --fstype xfs --size=300
part pv.01 --size=1 --grow
volgroup root_vg01 pv.01
logvol / --fstype xfs --name=lv_01 --vgname=root_vg01 --size=1 --grow
## Allow cfg within cfg, replace ampersand with percent by sed after install
&packages
@^minimal
@core
&end
&addon com_redhat_kdump --disable --reserve-mb='auto'
&end
CENTOS7CFG
sed 's/^&/%/' -i /var/ftp/pub/centos7.cfg
systemctl enable xinetd
systemctl enable dhcpd.service
systemctl enable vsftpd
%end
%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
%end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment