Centos Setup

Setup OS & Desktop

sudo hostnamectl set-hostname ocp-bastion-01
sudo yum install -y gnome-tweak-tool
sudo yum install -y neofetch
sudo yum install -y epel-release.noarch
sudo yum install -y git
sudo yum update -y
git clone https://github.com/daniruiz/flat-remix-gnome
git clone https://github.com/daniruiz/flat-remix-gtk
mkdir ~/.themes
cp -r /flat-remix-gnome/Flat-Remix ~/.themes
cp -r /flat-remix-gtk/Flat-Remix-GTK ~/.themes

cat << EOM >> /etc/yum.repos.d/google-chrome.repo
[google-chrome]
name=google-chrome
baseurl=http://dl.google.com/linux/chrome/rpm/stable/x86_64
enabled=1
gpgcheck=1
gpgkey=https://dl.google.com/linux/linux_signing_key.pub
EOM

yum install -y google-chrome-stable

gsettings set org.gnome.shell.extensions.user-theme name 'Flat-Remix'
gsettings set org.gnome.desktop.interface gtk-theme 'Flat-Remix-GTK'

Setup OS Extra Packages

yum install wget.x86_64 -y
yum update -y 
yum upgrade -y
yum repolist
yum install bash-completion.noarch -y
yum install unzip.x86_64 -y
yum install perl.x86_64 -y
yum install net-tools.x86_64 -y
yum install gcc.x86_64 -y
yum install kernel-devel-3.10.0-327.13.1.el7.x86_64 -y
sed -i '1 c co-dev.localdomain' /etc/hostname

Setup PXE

yum install -y httpd xinetd syslinux tftp-server
cd /usr/share/syslinux/
cp pxelinux.0 menu.c32 memdisk mboot.c32 chain.c32 /var/lib/tftpboot/
sed -i '14s/yes/no/' /etc/xinetd.d/tftp
wget/curl centos image
sudo mount -o loop ~/Downloads/CentOS-7-x86_64-Minimal-1804.iso /mnt/
mkdir /var/lib/tftpboot/centos7_x64
cp -fr /mnt/* /var/lib/tftpboot/centos7_x64/
umount /mnt

chmod -R 755 /var/lib/tftpboot/centos7_x64/

cat << EOM >> /etc/httpd/conf.d/pxeboot.conf
Alias /centos7_x64 /var/lib/tftpboot/centos7_x64/

<Directory /var/lib/tftpboot/centos7_x64>
 Options Indexes FollowSymLinks
 Require all granted
</Directory>
EOM

mkdir /var/lib/tftpboot/pxelinux.cfg

cat << EOM >> /var/lib/tftpboot/pxelinux.cfg/default
default menu.c32
prompt 0
timeout 30
ONTIMEOUT 3

menu title ########## PXE Boot Menu ##########

label 1
menu label ^1) Manual Install CentOS 7
kernel centos7_x64/images/pxeboot/vmlinuz
append initrd=centos7_x64/images/pxeboot/initrd.img method=http://192.168.0.101/centos7_x64 devfs=nomount

label 2
menu label ^2) Boot from local drive localboot

label 3
menu label ^3) PXE CentOS Install with Kickstart ks.cfg
kernel centos7_x64/images/pxeboot/vmlinuz
append initrd=centos7_x64/images/pxeboot/initrd.img inst.repo=http://192.168.0.101/centos7_x64 ks=http://192.168.0.101/centos7_x64/ks.cfg
EOM

systemctl enable tftp.service
systemctl start tftp.service
systemctl restart xinetd
systemctl restart httpd
systemctl enable xinetd
systemctl enable httpd
systemctl disable firewalld
systemctl stop firewalld

tcpdump -i ens33 -vvv -s 0 port bootps

# PXE Hangs for 10 mins due to option 43 configured in DHCP scope - Ended up moving the option to the specfic device that required it (a wireless access point) - Only relevant if you're sharing dhcp scope with other devices
http://scug.be/sccm/2011/01/13/configmgr-2007-pxe-boot-amp-mtftp-defaulting-and-make-you-wait-for-10-15-minutes/

# Useful links
https://www.unixmen.com/install-pxe-server-and-configure-pxe-client-on-centos-7/
https://www.linuxtechi.com/configure-pxe-installation-server-centos-7/
https://www.unixmen.com/install-pxe-server-centos-7/
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/installation_guide/sect-kickstart-syntax
https://marclop.svbtle.com/creating-an-automated-centos-7-install-via-kickstart-file

# Troubleshoot 403 error - This is noted on PXE boot and the boot image cannot access the chained files due to selinux. You can disable completely or setup exceptions

https://www.digitalocean.com/community/tutorials/an-introduction-to-selinux-on-centos-7-part-2-files-and-processes
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/selinux_users_and_administrators_guide/sect-managing_confined_services-the_apache_http_server-configuration_examples

getenforce
curl http://127.0.0.1/centos7_x64/LiveOS/squashfs.img
chown -R apache: /var/lib/tftpboot
chcon -R --type httpd_sys_content_t /var/lib/tftpboot/centos7_x64
chcon --reference=/var/www/ /var/lib/tftpboot/centos7_x64
getsebool -a
sealert && tail -f /var/log/messages
setsebool -P tftp_home_dir on

# Check context for file
ls -Z /var/lib/tftpboot/centos7_x64

ks.cfg - Kickstart File for CentOS Automated Install

#platform=x86, AMD64, or Intel EM64T
 #version=DEVEL
 network --bootproto=dhcp
 # Firewall configuration
 firewall --disabled
 # Install OS instead of upgrade
 install
 # Use NFS installation media
 url --url="http://192.168.0.101/centos7_x64/"
 # Accept Eula
 eula --agreed
 # Reboot post install
 reboot
 # Root password [openssl passwd -1 as]
 rootpw --iscrypted $1$mF.LQITn$6G0vL81fe/XDqBnh1FhjK.
 # System authorization information
 auth  useshadow  passalgo=sha512
 # Use graphical install
 #graphical
 firstboot disable
 # System keyboard
 keyboard uk
 # System language
 lang en_GB
 # SELinux configuration
 selinux --permissive
 # Installation logging level
 logging level=info
# System timezone
 timezone Europe/London
 # System bootloader configuration
 bootloader location=mbr
 clearpart --all --initlabel
 part swap --asprimary --fstype="swap" --size=1024
 part /boot --fstype xfs --size=200
 part pv.01 --size=1 --grow
 volgroup rootvg01 pv.01
 logvol / --fstype xfs --name=lv01 --vgname=rootvg01 --size=1 --grow

 %packages
 @core
 %end
 %post
 %end

Update Sudoers File

sed -i '93 i alex    ALL=(ALL)       NOPASSWD: ALL' /etc/sudoers

Boot Nodes

Nodes will boot, pick up an IP Address and DNS Hostname as defined on the DHCP server, PXE boot and install CentOS based on the ks.cfg file

Insert a Markdown card with / (thank god)