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

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.

  1. 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 j2cli
  2. Specify any host-specific information related to the OS configuration.

    1. 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=node1
    2. Specify 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=sda
    3. Specify the name of the network interface:

      root@host:~# export IFACE=eth0

      Note

      Since you will be using predictable network interface names, this is already known.

    4. Specify the root password hash:

      root@host:~# export ROOT_PASSWD_HASH=$(mkpasswd -m sha-512) Password:
    5. 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.10

      Note

      This should be the address of your bootstrap host.

  3. Create the OS configuration file. Choose one of the following options based on your desired OS.

    1. Specify the path of your OS configuration file:

      root@host:~# export KS=/var/www/html/conf/${HOSTNAME?}.cfg
    2. Copy and paste the following code inside ks.cfg.j2:

      ks.cfg.j2
      1url --url="http://{{ WEBSERVER_ADDRESS }}/iso/Rocky8"
      2# text
      3# reboot
      4-67
      4poweroff
      5
      6lang en_US.UTF-8
      7keyboard us
      8
      9network --onboot yes --device {{ IFACE }} --bootproto dhcp --noipv6 --activate --hostname {{ HOSTNAME }}
      10
      11# mkpasswd -m sha-512 -- "12341234"
      12rootpw --iscrypted {{ ROOT_PASSWD_HASH }}
      13# https://www.mankier.com/7/authselect-migration
      14#authconfig --enableshadow --passalgo=sha512
      15authselect select minimal
      16
      17# firewall --enabled --ssh
      18firewall --disabled
      19# selinux --enforcing
      20selinux --disabled
      21
      22timezone --utc America/New_York
      23
      24ignoredisk --only-use={{ DISK }}
      25
      26zerombr
      27clearpart --all --initlabel
      28autopart --nohome --nolvm --noboot --noswap
      29bootloader --location=mbr --driveorder=sda --append=" crashkernel=auto" --timeout=0
      30
      31%packages
      32@^minimal-environment
      33#python36
      34#wget
      35#ksh
      36dos2unix
      37logwatch
      38tar
      39postfix
      40#bind-utils
      41bc
      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
      65exec 1>/root/ks-post.log 2>&1
      66tail -f /root/ks-post.log > /dev/console &
      67
      68mkdir -p /root/.ssh
      69curl -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.

    3. 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

  1. 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 lynx
  2. Verify 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.