RHEL_9_Foreman_Guide

Knowledge Base Install Discovery and Provisioning libvirt proxmox external DNS&DHCP diskless pxe-boot using zfs

Installation (katello,discovery,dhcp,tftp)

before we start:

Preperation

switch to root because its easier:

$ su root

get your NIC’s IP and Name:

$ ifconfig

enp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.2.100 netmask 255.255.255.0 broadcast 192.168.2.255 .

find your NIC’s DNS-Server’s IP and Domain

$ nslookup 192.168.2.1
1.2.168.192.in-addr.arpa	name = speedport.ip.

edit the hosts file

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.2.100 my_hostname.speedport.ip

firewall settings:

$ firewall-cmd --add-port="5646/tcp"
$ firewall-cmd \
--add-port="5647/tcp" \
--add-port="8000/tcp" \
--add-port="9090/tcp"
$ firewall-cmd \
--add-service=dns \
--add-service=dhcp \
--add-service=tftp \
--add-service=http \
--add-service=https \
--add-service=puppetmaster
$ firewall-cmd --runtime-to-permanent

» check if it works «

$ firewall-cmd --list-all
...
 interfaces: enp2s0
 sources: 
 services: cockpit dhcp dhcpv6-client dns http https mdns puppetmaster ssh tftp
 ports: 5646/tcp 5647/tcp 8000/tcp 9090/tcp
...    

Install

get the repos

$ dnf install https://yum.theforeman.org/releases/3.10/el9/x86_64/foreman-release.rpm
$ dnf install https://yum.theforeman.org/katello/4.12/katello/el9/x86_64/katello-repos-latest.rpm
$ dnf install https://yum.puppet.com/puppet7-release-el-9.noarch.rpm

install foreman 3.10 with katello plugin

$ dnf update
$ dnf install foreman-installer-katello
$ foreman-installer --scenario katello
...
 Success!
 * Foreman is running at https://my_hostname.speedport.ip
     Initial credentials are admin / <pass>
 * To install an additional Foreman proxy on separate machine continue by running:

     foreman-proxy-certs-generate --foreman-proxy-fqdn "$FOREMAN_PROXY" --certs-tar "/root/$FOREMAN_PROXY-certs.tar.gz"
 * Foreman Proxy is running at https://my_hostname.speedport.ip:9090

The full log is at /var/log/foreman-installer/katello.log

we connect to foreman dashboard by using

URL: https://my_hostname.speedport.ip
user: admin
pass:  <pass>`

install the Discovery Plugin

$ foreman-installer --enable-foreman-plugin-discovery
...
 Success!
 * Foreman is running at https://my_hostname.speedport.ip
 * To install an additional Foreman proxy on separate machine continue by running:

     foreman-proxy-certs-generate --foreman-proxy-fqdn "$FOREMAN_PROXY" --certs-tar "/root/$FOREMAN_PROXY-certs.tar.gz"
 * Foreman Proxy is running at https://my_hostname.speedport.ip:9090

The full log is at /var/log/foreman-installer/katello.log

» check if it worked «

$ dnf repolist enabled
...
foreman                   Foreman 3.10
foreman-plugins           Foreman plugins 3.10
katello                   Katello 4.12
pulpcore                  pulpcore: Fetch, Upload, Organize, and Distribute Software Packages.
puppet7                   Puppet 7 Repository el 9 - x86_64

**(optional)* delete old/wrong repo:*

DHCP

Install:

$ dnf install dhcp-server -y

Config:

$ sudo nano /etc/dhcp/dhcpd.conf
...
# speedport.ip
subnet 192.168.2.0 netmask 255.255.255.0 {
pool
 {
   range 192.168.2.101 192.168.2.200;
 }
 option subnet-mask 255.255.255.0;
 option routers 192.168.2.100;
}

**(optional)* check if dhcp server is already installed and running*

$ nmap -sU 127.0.0.1 -p 67
 # if  its not installed or not running:
...
PORT   STATE  SERVICE
67/udp closed dhcps
...
#  if up and running:
...
PORT   STATE         SERVICE
67/udp open|filtered dhcps
...

of course you can check systemctl as well, but since we dont know the name of the service we just check the port directly (DHCP is Port 67 followed by TFTP port 68) you can also use telnet, lsof, etc

TFTP

install

$ sudo dnf install tftp-server -y

check if Discovery-Plugin created the Boot-image Files:

 $  nano /var/lib/tftpboot/pxelinux.cfg/default
default menu.c32
timeout 300
#LABEL discovery
  MENU LABEL Foreman Discovery Image
  KERNEL boot/fdi-image/vmlinuz0
 APPEND initrd=boot/fdi-image/initrd0.img rootflags=loop root=live:/fdi.iso rootfstype=auto proxy.url=https://cc.speedport.ip proxy.type=foreman
 IPAPPEND 2
$ sudo chmod -R 777 /var/lib/tftpboot
$ sudo chown -R nobody: /var/lib/tftpboot
$ nano /usr/lib/systemd/system/tftp.service
[Unit]
Description=Tftp Server
Requires=tftp.socket
Documentation=man:in.tftpd
[Service]
ExecStart=/usr/sbin/in.tftpd -s /var/lib/tftpboot
StandardInput=socket
[Install]
Also=tftp.socket
$ sudo nano /etc/xinetd.d/tftp
service tftp
{
socket_type             = dgram
protocol                = udp
wait                    = yes
user                    = root
server                  = /usr/sbin/in.tftpd
server_args             = -s /var/lib/tftpboot
disable                 = no 						# needs to be "no"
per_source              = 11
cps                     = 100 2
flags                   = IPv4
}
$ systemctl enable tftp
$ journalctl -u tftp -f
Mai 24 19:26:15 <user> in.tftpd[26138]: Client ::ffff:192.168.2.104 finished boot/rocky-linux-imLv796i67R9-initrd.img
Mai 24 19:41:00 <user> systemd[1]: tftp.service: Deactivated successfully.
Mai 26 10:16:08 <user> systemd[1]: Started Tftp Server.
Mai 26 10:16:08 <user> in.tftpd[147746]: Client ::ffff:192.168.2.104 finished pxelinux.0

Update Foreman

$  foreman-installer \
--foreman-proxy-dns true \
--foreman-proxy-dns-managed false \
--foreman-proxy-dhcp true \
--foreman-proxy-dhcp-managed true \
--foreman-proxy-dhcp-range "192.168.2.101 192.168.2.200" \
--foreman-proxy-dhcp-gateway 192.168.2.100 \
--foreman-proxy-dhcp-nameservers 192.168.2.100 \
--foreman-proxy-tftp true \
--foreman-proxy-tftp-managed true \
--foreman-proxy-tftp-servername 192.168.2.100

Knowledge Base Install Discovery and Provisioning libvirt proxmox external DNS&DHCP diskless pxe-boot using zfs