RHEL_9_Foreman_Guide

Foreman 3.10 + Puppet + Katello + Discovery Plugin-Installation- & PXE Beginners Guide for RHEL_9 (using local-DHCP&TFTP)

In this Guide i will show you how to install Forman with puppet, katello and discovery plugin. You will also learn how to install and setup DHCP- and TFTP-Server. I will also show you how to setup Foreman and how to use the Foreman Boot Image via PXE. You will be ready to discover and provision your physical servers and workstations after following this Guide.

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

192.168.2.100 my_hostname.speedport.ip

***firewall settings:***
```Bash
# 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 ForemanBootImage
 menu label ^Foreman Boot Image
kernel /path/to/your/boot/image/vmlinuz
append initrd=/path/to/your/boot/image/initrd.img root=/dev/nfs nfsroot=:192.168.0.1:/var> > /lib/tftboot/boot ip=dhcp
# sudo chmod -R 777 /var/lib/tftpboot
# sudo chown -R nobody: /var/lib/tftpboot
[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
}

Add a subnet

Build PXE default template

click on A) pxe defauflt

Boot a machine via PXE i was to lazy to setup kvm and libvirt so i used my server here if everything works, you dont need to do anything: just let it run pxe_boot

Required Knowledge

> - MAAS:
> 	- Focus: Direct management of VLANs and subnets within the platform itself.
> 	- Functionality: Allows creation and management of multiple VLANs, supporting both tagged and untagged VLANs on managed switches. Each fabric has a default VLAN, with additional VLANs added for logical separation within the same physical infrastructure.
> - Foreman:
> 	- Focus: Primarily focused on provisioning hosts and configuring their network settings.
> 	- Functionality: Can provision hosts across various subnets but does not directly manage VLANs. Requires separate network-level configuration for creating and managing VLANs.
> In essence, MAAS offers integrated VLAN and subnet management within its environment, whereas Foreman focuses on host provisioning and network configuration, leaving VLAN management to external network administration.

### DNS
```mermaid
sequenceDiagram
    participant Client as Client Device
    participant DNS_Client as DNS Client
    participant DNS_Server as DNS Server
    Note over Client: Client wants to access www.example.com
    Client->>+DNS_Client: Sends DNS query for www.example.com
    DNS_Client->>+DNS_Server: Queries DNS Server for www.example.com
    DNS_Server->>+DNS_Client: Returns IP address for www.example.com
    DNS_Client->>+Client: Sends IP address for www.example.com
    Note over Client: Client accesses www.example.com using the returned IP address

hosts file

This diagram outlines the differences in the process of resolving a domain name using the hosts file versus a DNS server:

sequenceDiagram
    participant Client as Client Device
    participant Browser as Web Browser
    participant Hosts_File as Hosts File
    participant DNS_Server as DNS Server
    Note over Client: Client wants to access www.example.com
    Browser->>+Hosts_File: Checks for www.example.com
    Hosts_File->>+Browser: Returns IP address if found
    Note over Browser: Uses IP address from Hosts File
    Browser->>+DNS_Server: Queries DNS Server for www.example.com
    DNS_Server->>+Browser: Returns IP address for www.example.com
    Note over Browser: Uses IP address from DNS Server

PXE and TFTP

This diagram outlines the basic steps involved in the PXE and TFTP boot process:

sequenceDiagram
    participant Client as Client Device
    participant DHCP_Server as DHCP Server
    participant TFTP_Server as TFTP Server
    participant PXE_DP as PXE Distribution Point
    Note over Client: Client starts booting
    Client->>+DHCP_Server: Sends DHCPDISCOVER
    DHCP_Server->>+Client: Sends DHCPOFFER with IP, TFTP Server info
    Client->>+TFTP_Server: Requests boot image
    TFTP_Server->>+Client: Sends boot image
    Client->>+PXE_DP: Executes boot image
    Note over Client: Client boots from network

Foreman Smartproxy & Network Configuration Process

This diagram provides a visual representation of the network configuration process, detailing how a client PC interacts with various components such as VLAN, DNS Server, DHCP in Router, and Storage during the boot process

sequenceDiagram
    participant Client as Client Device
    participant PXE as PXE (Preboot Execution Environment)
    participant DHCP_Server as DHCP Server
    participant DNS_Server as DNS Server
    participant Foreman as Foreman
    participant SmartProxy as SmartProxy
    participant TFTP_Server as TFTP Server
    participant HTTP_Server as HTTP Server
    Note over Client: Client starts boot process
    Client->>+PXE: Initiates PXE Boot
    PXE->>+DHCP_Server: Sends DHCPDISCOVER
    DHCP_Server->>+PXE: Sends DHCPOFFER with IP Address
    PXE->>+Client: Sends IP Address
    Note over Client: Client receives IP Address
    Client->>+DNS_Server: Sends DNS query for Foreman Domain
    DNS_Server->>+Client: Sends IP Address for Foreman Domain
    Note over Client: Client configures DNS settings
    Client->>+SmartProxy: Sends PXE Boot Request
    SmartProxy->>+Foreman: Sends request for Host Provisioning
    Foreman->>+HTTP_Server: Sends request for Host Template
    HTTP_Server->>+Foreman: Sends Host Template
    Foreman->>+SmartProxy: Sends response with Host Information
    SmartProxy->>+Client: Sends Boot Image via TFTP
    Client->>+TFTP_Server: Sends request for Boot Image
    TFTP_Server->>+Client: Sends Boot Image
    Note over Client: Client boots from network

you made it trough the tutorial!!!