Set Up per Host OS Configuration Files¶
This guide will walk you through setting up OS configuration files for each of your physical hosts that will automate the OS installation. During this process you will
- Use your DHCP server to configure networking,
- Set a root password for each physical host,
- Use a single disk configuration similar to the ones that cloud providers use for their Kubernetes nodes,
- Install the absolutely necessary packages, and
- Allow SSH with your initial authorized keys.
Note
In this guide you will configure lighttpd on your bootstrap host to serve the OS configuration files for each of your physical nodes. If your HTTP server lives outside of your bootstrap host, configure it accordingly.
What You’ll Need¶
- A bootstrap host.
- A configured HTTP server.
For each physical host, you have to provide
- the hostname,
- the name of the hard disk to use, and
- the root password.
Procedure¶
Important
Repeat the following steps for each physical host.
Go to your bootstrap host and install the necessary packages, if you don’t have them already on your system:
root@host:~# apt-get install -y whois j2cliSpecify any host-specific information related to the OS configuration.
Specify the hostname of the physical host:
root@host:~# export HOSTNAME=<HOSTNAME>Replace
<HOSTNAME>
with the hostname of your physical host. For example:root@host:~# export HOSTNAME=node1Specify the name of the hard disk to use:
root@host:~# export DISK=<DISK>Replace
<DISK>
with the disk name of your physical host. For example:root@host:~# export DISK=sdaSpecify the name of the network interface:
root@host:~# export IFACE=eth0Note
Since you will be using predictable network interface names, this is already known.
Specify the root password hash:
root@host:~# export ROOT_PASSWD_HASH=$(mkpasswd -m sha-512) Password:Specify the address of your webserver:
root@host:~# export WEBSERVER_ADDRESS=<ADDRESS>Replace
<ADDRESS>
with your webserver address. For example:root@host:~# export WEBSERVER_ADDRESS=192.168.2.10Note
This should be the address of your bootstrap host.
Create the OS configuration file. Choose one of the following options based on your desired OS.
Specify the path of your OS configuration file:
root@host:~# export KS=/var/www/html/conf/${HOSTNAME?}.cfgCopy and paste the following code inside
ks.cfg.j2
:ks.cfg.j21 url --url="http://{{ WEBSERVER_ADDRESS }}/iso/Rocky8" 2 # text 3 # reboot 4-67 4 poweroff 5 6 lang en_US.UTF-8 7 keyboard us 8 9 network --onboot yes --device {{ IFACE }} --bootproto dhcp --noipv6 --activate --hostname {{ HOSTNAME }} 10 11 # mkpasswd -m sha-512 -- "12341234" 12 rootpw --iscrypted {{ ROOT_PASSWD_HASH }} 13 # https://www.mankier.com/7/authselect-migration 14 #authconfig --enableshadow --passalgo=sha512 15 authselect select minimal 16 17 # firewall --enabled --ssh 18 firewall --disabled 19 # selinux --enforcing 20 selinux --disabled 21 22 timezone --utc America/New_York 23 24 ignoredisk --only-use={{ DISK }} 25 26 zerombr 27 clearpart --all --initlabel 28 autopart --nohome --nolvm --noboot --noswap 29 bootloader --location=mbr --driveorder=sda --append=" crashkernel=auto" --timeout=0 30 31 %packages 32 @^minimal-environment 33 #python36 34 #wget 35 #ksh 36 dos2unix 37 logwatch 38 tar 39 postfix 40 #bind-utils 41 bc 42 -kdump 43 -iwl100-firmware 44 -iwl1000-firmware 45 -iwl105-firmware 46 -iwl135-firmware 47 -iwl2000-firmware 48 -iwl2030-firmware 49 -iwl3160-firmware 50 -iwl3945-firmware 51 -iwl4965-firmware 52 -iwl5000-firmware 53 -iwl5150-firmware 54 -iwl6000-firmware 55 -iwl6000g2a-firmware 56 -iwl6050-firmware 57 -iwl7260-firmware 58 -biosdevname 59 %end 60 61 %addon com_redhat_kdump --disable --reserve-mb='auto' 62 %end 63 64 %post 65 exec 1>/root/ks-post.log 2>&1 66 tail -f /root/ks-post.log > /dev/console & 67 68 mkdir -p /root/.ssh 69 curl -o /root/.ssh/authorized_keys http://{{ WEBSERVER_ADDRESS }}/files/initial_authorized_keys 70 %end Alternatively, download the file above and upload it to your bootstrap host.
Render the OS configuration file:
root@host:~# j2 ks.cfg.j2 -o ${KS?}
Note
This example configuration will:
- Obtain the installation source from
/iso/Rocky8
of your HTTP server. - Power off the host after the installation.
- Set the root password.
- Disable the firewall.
- Disable selinux.
- Operate only on hard disk
sda
. - Use a simple single disk configuration with a single partition for rootfs.
- Install all the packages for a minimal environment.
- Disable the kdump kernel crash dumping mechanism.
- Obtain initial authorized SSH keys from
/files
of your HTTP server.
Verify¶
Go to your bootstrap host and install the necessary packages, if you don’t have them already on your system:
root@host:~# apt-get update root@host:~# apt-get install -y lynxVerify that your OS configuration files are available. Choose based on your desired OS.
root@host:~# lynx -dump -hiddenlinks=listonly --listonly localhost/conf References 1. http://localhost/ 2. http://localhost/conf/node1.cfg
Summary¶
You have successfully created OS configuration files for your physical hosts.
What’s Next¶
The next step is to set up PXE configuration files for your physical hosts.