1. Preparing your environment for installation

Before you install Foreman, ensure that your environment meets the following requirements.

1.1. System requirements

The following requirements apply to the networked base operating system:

  • x86_64 architecture

  • 4-core 2.0 GHz CPU at a minimum

  • A minimum of 20 GB RAM is required for Foreman server to function. In addition, a minimum of 4 GB RAM of swap space is also recommended. Foreman running with less RAM than the minimum value might not operate correctly.

  • A unique host name, which can contain lower-case letters, numbers, dots (.) and hyphens (-)

  • Administrative user (root) access

  • Full forward and reverse DNS resolution using a fully-qualified domain name

Foreman only supports UTF-8 encoding. If your territory is USA and your language is English, set en_US.utf-8 as the system-wide locale settings. For more information about configuring system locale in Enterprise Linux, see Configuring the system locale in Red Hat Enterprise Linux 9 Configuring basic system settings.

Foreman server and Smart Proxy server do not support shortnames in the hostnames. When using custom certificates, the Common Name (CN) of the custom certificate must be a fully qualified domain name (FQDN) instead of a shortname. This does not apply to the clients of a Foreman.

Before you install Foreman server, ensure that your environment meets the requirements for installation.

Foreman server must be installed on a freshly provisioned system that serves no other function except to run Foreman server. The freshly provisioned system must not have the following users provided by external identity providers to avoid conflicts with the local users that Foreman server creates:

  • apache

  • foreman

  • foreman-proxy

  • postgres

  • pulp

  • puppet

  • redis

  • tomcat

SELinux mode

SELinux must be enabled, either in enforcing or permissive mode. Installation with disabled SELinux is not supported.

FIPS mode

You can install Foreman on a Enterprise Linux system that is operating in FIPS mode. You cannot enable FIPS mode after the installation of Foreman. Red Hat Enterprise Linux clones are not being actively tested in FIPS mode. If you require FIPS, consider using Red Hat Enterprise Linux. For more information, see Installing the system in FIPS mode in Red Hat Enterprise Linux 9 Security hardening or Installing the system in FIPS mode in Red Hat Enterprise Linux 8 Security hardening.

Note

Foreman supports DEFAULT and FIPS crypto-policies. The FUTURE crypto-policy is not supported for Foreman and Smart Proxy installations. The FUTURE policy is a stricter forward-looking security level intended for testing a possible future policy. For more information, see Using system-wide cryptographic policies in Red Hat Enterprise Linux 9 Security hardening.

1.2. Storage requirements

The following table details storage requirements for specific directories. These values are based on expected use case scenarios and can vary according to individual environments.

The runtime size was measured with Red Hat Enterprise Linux 7, 8, and 9 repositories synchronized.

Table 1. Storage requirements for a Foreman server installation
Directory Installation Size Runtime Size

/var/log

10 MB

10 GB

/var/lib/pgsql

100 MB

20 GB

/usr

10 GB

Not Applicable

/opt/puppetlabs

500 MB

Not Applicable

/var/lib/pulp

1 MB

300 GB

For external database servers: /var/lib/pgsql with installation size of 100 MB and runtime size of 20 GB.

For detailed information on partitioning and size, see Partitioning reference in Performing a standard RHEL 9 installation.

1.3. Storage guidelines

Consider the following guidelines when installing Foreman server to increase efficiency.

  • If you mount the /tmp directory as a separate file system, you must use the exec mount option in the /etc/fstab file. If /tmp is already mounted with the noexec option, you must change the option to exec and re-mount the file system. This is a requirement for the puppetserver service to work.

  • Because most Foreman server data is stored in the /var directory, mounting /var on LVM storage can help the system to scale.

  • Use high-bandwidth, low-latency storage for the /var/lib/pulp/ directories. As Foreman has many operations that are I/O intensive, using high latency, low-bandwidth storage causes performance degradation. Ensure your installation has a speed in the range 60 – 80 Megabytes per second.

File system guidelines
  • Do not use the GFS2 file system as the input-output latency is too high.

Log file storage

Log files are written to /var/log/messages/, /var/log/httpd/, and /var/lib/foreman-proxy/openscap/content/. You can manage the size of these files using logrotate.

The exact amount of storage you require for log messages depends on your installation and setup.

SELinux considerations for NFS mount

When the /var/lib/pulp directory is mounted using an NFS share, SELinux blocks the synchronization process. To avoid this, specify the SELinux context of the /var/lib/pulp directory in the file system table by adding the following lines to /etc/fstab:

nfs.example.com:/nfsshare  /var/lib/pulp  nfs  context="system_u:object_r:var_lib_t:s0"  1 2

If NFS share is already mounted, remount it using the above configuration and enter the following command:

# restorecon -R /var/lib/pulp
Duplicated packages

Packages that are duplicated in different repositories are only stored once on the disk. Additional repositories containing duplicate packages require less additional storage. The bulk of storage resides in the /var/lib/pulp/ directory. These end points are not manually configurable. Ensure that storage is available on the /var file system to prevent storage problems.

Symbolic links

You cannot use symbolic links for /var/lib/pulp/.

Synchronized RHEL ISO

If you plan to synchronize RHEL content ISOs to Foreman, note that all minor versions of Red Hat Enterprise Linux also synchronize. You must plan to have adequate storage on your Foreman to manage this.

1.4. Supported operating systems

The following operating systems are supported by the installer, have packages, and are tested for deploying Foreman:

Table 2. Operating systems supported by foreman-installer

Operating System

Architecture

Notes

Enterprise Linux 9

x86_64 only

EPEL is not supported.

Enterprise Linux 8

x86_64 only

EPEL is not supported.

Foreman community advises against using an existing system because the Foreman installer will affect the configuration of several components.

1.5. Supported browsers

Using the most recent version of a major browser is highly recommended, as Foreman and the frameworks it uses offer limited support for older versions.

The recommended requirements are as follows for major browsers:

  • Google Chrome – latest version

  • Microsoft Edge – latest version

  • Apple Safari – latest version

  • Mozilla Firefox – latest version

  • Mozilla Firefox Extended Support Release (ESR) – latest version

Other browsers may work unpredictably.

The Foreman web UI and command-line interface support English, Portuguese, Simplified Chinese Traditional Chinese, Korean, Japanese, Italian, Spanish, Russian, French, and German.

1.6. Port and firewall requirements

For the components of Foreman architecture to communicate, ensure that the required network ports are open and free on the base operating system. You must also ensure that the required network ports are open on any network-based firewalls.

Use this information to configure any network-based firewalls. Note that some cloud solutions must be specifically configured to allow communications between machines because they isolate machines similarly to network-based firewalls. If you use an application-based firewall, ensure that the application-based firewall permits all applications that are listed in the tables and known to your firewall. If possible, disable the application checking and allow open port communication based on the protocol.

Integrated Smart Proxy

Foreman server has an integrated Smart Proxy and any host that is directly connected to Foreman server is a Client of Foreman in the context of this section. This includes the base operating system on which Smart Proxy server is running.

Clients of Smart Proxy

Hosts which are clients of Smart Proxies, other than Foreman’s integrated Smart Proxy, do not need access to Foreman server.

Required ports can change based on your configuration.

The following tables indicate the destination port and the direction of network traffic:

Table 3. Foreman server incoming traffic

Destination Port

Protocol

Service

Source

Required For

Description

53

TCP and UDP

DNS

DNS Servers and clients

Name resolution

DNS (optional)

67

UDP

DHCP

Client

Dynamic IP

DHCP (optional)

69

UDP

TFTP

Client

TFTP Server (optional)

443

TCP

HTTPS

Smart Proxy

Foreman API

Communication from Smart Proxy

443, 80

TCP

HTTPS, HTTP

Client

Global Registration

Registering hosts to Foreman

Port 443 is required for registration initiation, uploading facts, and sending installed packages and traces

Port 80 notifies Foreman on the /unattended/built endpoint that registration has finished

443

TCP

HTTPS

Foreman

Content Mirroring

Management

443

TCP

HTTPS

Foreman

Smart Proxy API

Smart Proxy functionality

443, 80

TCP

HTTPS, HTTP

Smart Proxy

Content Retrieval

Content

443, 80

TCP

HTTPS, HTTP

Client

Content Retrieval

Content

1883

TCP

MQTT

Client

Pull based REX (optional)

Content hosts for REX job notification (optional)

5910 – 5930

TCP

HTTPS

Browsers

Compute Resource’s virtual console

8000

TCP

HTTP

Client

Provisioning templates

Template retrieval for client installers, iPXE or UEFI HTTP Boot

8000

TCP

HTTPS

Client

PXE Boot

Installation

8140

TCP

HTTPS

Client

Puppet agent

Client updates (optional)

9090

TCP

HTTPS

Foreman

Smart Proxy API

Smart Proxy functionality

9090

TCP

HTTPS

Client

OpenSCAP

Configure Client (if the OpenSCAP plugin is installed)

9090

TCP

HTTPS

Discovered Node

Discovery

Host discovery and provisioning (if the discovery plugin is installed)

Any host that is directly connected to Foreman server is a client in this context because it is a client of the integrated Smart Proxy. This includes the base operating system on which a Smart Proxy server is running.

A DHCP Smart Proxy performs ICMP ping or TCP echo connection attempts to hosts in subnets with DHCP IPAM set to find out if an IP address considered for use is free. This behavior can be turned off using foreman-installer --foreman-proxy-dhcp-ping-free-ip=false.

Note

Some outgoing traffic returns to Foreman to enable internal communication and security operations.

Table 4. Foreman server outgoing traffic
Destination Port Protocol Service Destination Required For Description

ICMP

ping

Client

DHCP

Free IP checking (optional)

7

TCP

echo

Client

DHCP

Free IP checking (optional)

22

TCP

SSH

Target host

Remote execution

Run jobs

22, 16514

TCP

SSH SSH/TLS

Compute Resource

Foreman originated communications, for compute resources in libvirt

53

TCP and UDP

DNS

DNS Servers on the Internet

DNS Server

Resolve DNS records (optional)

53

TCP and UDP

DNS

DNS Server

Smart Proxy DNS

Validation of DNS conflicts (optional)

53

TCP and UDP

DNS

DNS Server

Orchestration

Validation of DNS conflicts

68

UDP

DHCP

Client

Dynamic IP

DHCP (optional)

80

TCP

HTTP

Remote repository

Content Sync

Remote repositories

389, 636

TCP

LDAP, LDAPS

External LDAP Server

LDAP

LDAP authentication, necessary only if external authentication is enabled. The port can be customized when LDAPAuthSource is defined

443

TCP

HTTPS

Foreman

Smart Proxy

Smart Proxy

Configuration management

Template retrieval

OpenSCAP

Remote Execution result upload

443

TCP

HTTPS

Amazon EC2, Azure, Google GCE

Compute resources

Virtual machine interactions (query/create/destroy) (optional)

443

TCP

HTTPS

Smart Proxy

Content mirroring

Initiation

443

TCP

HTTPS

Infoblox DHCP Server

DHCP management

When using Infoblox for DHCP, management of the DHCP leases (optional)

623

Client

Power management

BMC On/Off/Cycle/Status

5000

TCP

HTTPS

OpenStack Compute Resource

Compute resources

Virtual machine interactions (query/create/destroy) (optional)

5900 – 5930

TCP

SSL/TLS

Hypervisor

noVNC console

Launch noVNC console

5985

TCP

HTTP

Client

WinRM

Configure Client running Windows

5986

TCP

HTTPS

Client

WinRM

Configure Client running Windows

7911

TCP

DHCP, OMAPI

DHCP Server

DHCP

The DHCP target is configured using --foreman-proxy-dhcp-server and defaults to localhost

ISC and remote_isc use a configurable port that defaults to 7911 and uses OMAPI

8443

TCP

HTTPS

Client

Discovery

Smart Proxy sends reboot command to the discovered host (optional)

9090

TCP

HTTPS

Smart Proxy

Smart Proxy API

Management of Smart Proxies

1.7. Enabling connections from a client to Foreman server

Smart Proxies and Content Hosts that are clients of a Foreman server’s internal Smart Proxy require access through Foreman’s host-based firewall and any network-based firewalls.

Use this procedure to configure the host-based firewall on the system that Foreman is installed on, to enable incoming connections from Clients, and to make the configuration persistent across system reboots. For more information on the ports used, see Port and firewall requirements in Installing Foreman Server with Katello 4.13 plugin on Enterprise Linux.

If you do not use firewall-cmd to configure the Linux firewall, implement using the command of your choice.

Procedure
  1. Open the ports for clients on Foreman server:

    # firewall-cmd \
    --add-port="5647/tcp" \
    --add-port="8000/tcp" \
    --add-port="9090/tcp"
  2. Allow access to services on Foreman server:

    # firewall-cmd \
    --add-service=dns \
    --add-service=dhcp \
    --add-service=tftp \
    --add-service=http \
    --add-service=https \
    --add-service=puppetmaster
  3. Make the changes persistent:

    # firewall-cmd --runtime-to-permanent
Verification
  • Enter the following command:

    # firewall-cmd --list-all

For more information, see Using and configuring firewalld in Red Hat Enterprise Linux 9 Configuring firewalls and packet filters or Using and configuring firewalld in Red Hat Enterprise Linux 8 Configuring and managing networking.

1.8. Verifying DNS resolution

Verify the full forward and reverse DNS resolution using a fully-qualified domain name to prevent issues while installing Foreman.

Procedure
  1. Ensure that the host name and local host resolve correctly:

    # ping -c1 localhost
    # ping -c1 `hostname -f` # my_system.domain.com

    Successful name resolution results in output similar to the following:

    # ping -c1 localhost
    PING localhost (127.0.0.1) 56(84) bytes of data.
    64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.043 ms
    
    --- localhost ping statistics ---
    1 packets transmitted, 1 received, 0% packet loss, time 0ms
    rtt min/avg/max/mdev = 0.043/0.043/0.043/0.000 ms
    
    # ping -c1 `hostname -f`
    PING hostname.gateway (XX.XX.XX.XX) 56(84) bytes of data.
    64 bytes from hostname.gateway (XX.XX.XX.XX): icmp_seq=1 ttl=64 time=0.019 ms
    
    --- localhost.gateway ping statistics ---
    1 packets transmitted, 1 received, 0% packet loss, time 0ms
    rtt min/avg/max/mdev = 0.019/0.019/0.019/0.000 ms
  2. To avoid discrepancies with static and transient host names, set all the host names on the system by entering the following command:

    # hostnamectl set-hostname name
Warning

Name resolution is critical to the operation of Foreman. If Foreman cannot properly resolve its fully qualified domain name, tasks such as content management, subscription management, and provisioning will fail.

1.9. Tuning Foreman server with predefined profiles

If your Foreman deployment includes more than 5000 hosts, you can use predefined tuning profiles to improve performance of Foreman.

Note that you cannot use tuning profiles on Smart Proxies.

You can choose one of the profiles depending on the number of hosts your Foreman manages and available hardware resources.

The tuning profiles are available in the /usr/share/foreman-installer/config/foreman.hiera/tuning/sizes directory.

When you run the foreman-installer command with the --tuning option, deployment configuration settings are applied to Foreman in the following order:

  1. The default tuning profile defined in the /usr/share/foreman-installer/config/foreman.hiera/tuning/common.yaml file

  2. The tuning profile that you want to apply to your deployment and is defined in the /usr/share/foreman-installer/config/foreman.hiera/tuning/sizes/ directory

  3. Optional: If you have configured a /etc/foreman-installer/custom-hiera.yaml file, Foreman applies these configuration settings.

Note that the configuration settings that are defined in the /etc/foreman-installer/custom-hiera.yaml file override the configuration settings that are defined in the tuning profiles.

Therefore, before applying a tuning profile, you must compare the configuration settings that are defined in the default tuning profile in /usr/share/foreman-installer/config/foreman.hiera/tuning/common.yaml, the tuning profile that you want to apply and your /etc/foreman-installer/custom-hiera.yaml file, and remove any duplicated configuration from the /etc/foreman-installer/custom-hiera.yaml file.

default

Number of hosts: 0 – 5000

RAM: 20G

Number of CPU cores: 4

medium

Number of hosts: 5001 – 10000

RAM: 32G

Number of CPU cores: 8

large

Number of hosts: 10001 – 20000

RAM: 64G

Number of CPU cores: 16

extra-large

Number of hosts: 20001 – 60000

RAM: 128G

Number of CPU cores: 32

extra-extra-large

Number of hosts: 60000+

RAM: 256G

Number of CPU cores: 48+

Procedure
  1. Optional: If you have configured the custom-hiera.yaml file on Foreman server, back up the /etc/foreman-installer/custom-hiera.yaml file to custom-hiera.original. You can use the backup file to restore the /etc/foreman-installer/custom-hiera.yaml file to its original state if it becomes corrupted:

    # cp /etc/foreman-installer/custom-hiera.yaml \
    /etc/foreman-installer/custom-hiera.original
  2. Optional: If you have configured the custom-hiera.yaml file on Foreman server, review the definitions of the default tuning profile in /usr/share/foreman-installer/config/foreman.hiera/tuning/common.yaml and the tuning profile that you want to apply in /usr/share/foreman-installer/config/foreman.hiera/tuning/sizes/. Compare the configuration entries against the entries in your /etc/foreman-installer/custom-hiera.yaml file and remove any duplicated configuration settings in your /etc/foreman-installer/custom-hiera.yaml file.

  3. Enter the foreman-installer command with the --tuning option for the profile that you want to apply. For example, to apply the medium tuning profile settings, enter the following command:

    # foreman-installer --tuning medium

2. Preparing your environment for Foreman installation in an IPv6 network

You can install and use Foreman in an IPv6 network. Before installing Foreman in an IPv6 network, view the limitations and ensure that you meet the requirements.

To provision hosts in an IPv6 network, after installing Foreman, you must also configure Foreman for the UEFI HTTP boot provisioning. For more information, see Configuring Foreman for UEFI HTTP boot provisioning in an IPv6 network.

2.1. Limitations of Foreman installation in an IPv6 network

Foreman installation in an IPv6 network has the following limitations:

  • You can install Foreman and Smart Proxies in IPv6-only systems, dual-stack installation is not supported.

  • Although Foreman provisioning templates include IPv6 support for PXE and HTTP (iPXE) provisioning, the only tested and certified provisioning workflow is the UEFI HTTP Boot provisioning. This limitation only relates to users who plan to use Foreman to provision hosts.

2.2. Requirements for Foreman installation in an IPv6 network

Before installing Foreman in an IPv6 network, ensure that you meet the following requirements:

  • You must deploy an external DHCP IPv6 server as a separate unmanaged service to bootstrap clients into GRUB2, which then configures IPv6 networking either using DHCPv6 or assigning static IPv6 address. This is required because the DHCP server in Red Hat Enterprise Linux (ISC DHCP) does not provide an integration API for managing IPv6 records, therefore the Smart Proxy DHCP plugin that provides DHCP management is limited to IPv4 subnets.

  • Optional: If you rely on content from IPv4 networks, you must deploy an external IPv4 HTTP proxy server. This is required to access Content Delivery Networks that distribute content only over IPv4 networks, therefore you must use this proxy to pull content into Foreman on your IPv6 network.

  • You must configure Foreman to use this dual stack (supporting both IPv4 and IPv6) HTTP proxy server as the default proxy. For more information, see Adding a Default HTTP Proxy to Foreman.

3. Installing Foreman server

Use the following procedures to install Foreman server and perform the initial configuration.

Note that the Foreman installation script is based on Puppet, which means that if you run the installation script more than once, it might overwrite any manual configuration changes. ⁠ To avoid this and determine which future changes apply, use the --noop argument when you run the installation script. This argument ensures that no actual changes are made. Potential changes are written to /var/log/foreman-installer/katello.log.

Files are always backed up and so you can revert any unwanted changes. For example, in the foreman-installer logs, you can see an entry similar to the following about Filebucket:

/Stage[main]/Dhcp/File[/etc/dhcp/dhcpd.conf]: Filebucketed /etc/dhcp/dhcpd.conf to puppet with sum 622d9820b8e764ab124367c68f5fa3a1

You can restore the previous file as follows:

# puppet filebucket -l \
restore /etc/dhcp/dhcpd.conf 622d9820b8e764ab124367c68f5fa3a1

3.1. Configuring the HTTP proxy to connect to Red Hat CDN

Prerequisites

Your network gateway and the HTTP proxy must allow access to the following hosts:

Host name Port Protocol

subscription.rhsm.redhat.com

443

HTTPS

cdn.redhat.com

443

HTTPS

*.akamaiedge.net

443

HTTPS

Foreman server uses SSL to communicate with the Red Hat CDN securely. An SSL interception proxy interferes with this communication. These hosts must be allowlisted on your HTTP proxy.

For a list of IP addresses used by the Red Hat CDN (cdn.redhat.com), see the Knowledgebase article Public CIDR Lists for Red Hat on the Red Hat Customer Portal.

To configure the Subscription Manager with the HTTP proxy, follow the procedure below.

Procedure
  1. On Foreman server, complete the following details in the /etc/rhsm/rhsm.conf file:

    # an http proxy server to use (enter server FQDN)
    proxy_hostname = myproxy.example.com
    
    # port for http proxy server
    proxy_port = 8080
    
    # user name for authenticating to an http proxy, if needed
    proxy_user =
    
    # password for basic http proxy auth, if needed
    proxy_password =

3.2. Configuring repositories

Procedure

Select the operating system and version you are installing on:

3.2.1. Enterprise Linux 9

  1. Clear any metadata:

    # dnf clean all
  2. Install the foreman-release.rpm package:

    # dnf install https://yum.theforeman.org/releases/3.11/el9/x86_64/foreman-release.rpm
  3. Install the katello-repos-latest.rpm package:

    # dnf install https://yum.theforeman.org/katello/4.13/katello/el9/x86_64/katello-repos-latest.rpm
  4. Install the puppet7-release-el-9.noarch.rpm package:

    # dnf install https://yum.puppet.com/puppet7-release-el-9.noarch.rpm
Verification
  • Verify that the required repositories are enabled:

    # dnf repolist enabled

3.2.2. Enterprise Linux 8

  1. Clear any metadata:

    # dnf clean all
  2. Install the foreman-release.rpm package:

    # dnf install https://yum.theforeman.org/releases/3.11/el8/x86_64/foreman-release.rpm
  3. Install the katello-repos-latest.rpm package:

    # dnf install https://yum.theforeman.org/katello/4.13/katello/el8/x86_64/katello-repos-latest.rpm
  4. Install the puppet7-release-el-8.noarch.rpm package:

    # dnf install https://yum.puppet.com/puppet7-release-el-8.noarch.rpm
  5. Enable the DNF modules:

    # dnf module enable katello:el8
    Note

    If there is any warning about conflicts with Ruby or PostgreSQL while enabling katello:el8 module, see Troubleshooting DNF modules. For more information about modules and lifecycle streams on Red Hat Enterprise Linux 8, see Red Hat Enterprise Linux Application Streams Lifecycle.

Verification
  • Verify that the required repositories are enabled:

    # dnf repolist enabled

3.3. Optional: Using fapolicyd on Foreman server

By enabling fapolicyd on your Foreman server, you can provide an additional layer of security by monitoring and controlling access to files and directories. The fapolicyd daemon uses the RPM database as a repository of trusted binaries and scripts.

You can turn on or off the fapolicyd on your Foreman server or Smart Proxy server at any point.

3.3.1. Installing fapolicyd on Foreman server

You can install fapolicyd along with Foreman server or can be installed on an existing Foreman server. If you are installing fapolicyd along with the new Foreman server, the installation process will detect the fapolicyd in your Enterprise Linux host and deploy the Foreman server rules automatically.

Prerequisites
  • Ensure your host has access to the BaseOS repositories of Enterprise Linux.

Procedure
  1. Install fapolicyd:

    # dnf install fapolicyd
  2. Start the fapolicyd service:

    # systemctl enable --now fapolicyd
Verification
  • Verify that the fapolicyd service is running correctly:

    # systemctl status fapolicyd
New Foreman server or Smart Proxy server installations

In case of new Foreman server or Smart Proxy server installation, follow the standard installation procedures after installing and enabling fapolicyd on your Enterprise Linux host.

Additional resources

For more information on fapolicyd, see Blocking and allowing applications using fapolicyd in Red Hat Enterprise Linux 9 Security hardening or Blocking and allowing applications using fapolicyd in Red Hat Enterprise Linux 8 Security hardening.

3.4. Installing Foreman server packages

Procedure
  1. Update all packages:

    # dnf update
  2. Install foreman-installer-katello:

    # dnf install foreman-installer-katello

3.5. Synchronizing the system clock with chronyd

To minimize the effects of time drift, you must synchronize the system clock on the base operating system on which you want to install Foreman server with Network Time Protocol (NTP) servers. If the base operating system clock is configured incorrectly, certificate verification might fail.

For more information about the chrony suite, Using the Chrony suite to configure NTP in Red Hat Enterprise Linux 9 Configuring basic system settings or Using the Chrony suite to configure NTP in Red Hat Enterprise Linux 8 Configuring basic system settings.

Procedure
  1. Install the chrony package:

    # dnf install chrony
  2. Start and enable the chronyd service:

    # systemctl enable --now chronyd

3.6. Installing the sos package on the base operating system

Install the sos package on the base operating system so that you can collect configuration and diagnostic information from a Enterprise Linux system.

Procedure
  • Install the sos package:

    # dnf install sos

3.7. Configuring Foreman server

Install Foreman server using the foreman-installer installation script.

This method is performed by running the installation script with one or more command options. The command options override the corresponding default initial configuration options and are recorded in the Foreman answer file. You can run the script as often as needed to configure any necessary options.

3.7.1. Configuring Foreman installation

This initial configuration procedure creates an organization, location, user name, and password. After the initial configuration, you can create additional organizations and locations if required. The initial configuration also installs PostgreSQL databases on the same server.

The installation process can take tens of minutes to complete. If you are connecting remotely to the system, use a utility such as tmux that allows suspending and reattaching a communication session so that you can check the installation progress in case you become disconnected from the remote system. If you lose connection to the shell where the installation command is running, see the log at /var/log/foreman-installer/katello.log to determine if the process completed successfully.

Considerations
  • Use the foreman-installer --scenario katello --help command to display the available options and any default values. If you do not specify any values, the default values are used.

  • Specify a meaningful value for the option: --foreman-initial-organization. This can be your company name. An internal label that matches the value is also created and cannot be changed afterwards. If you do not specify a value, an organization called Default Organization with the label Default_Organization is created. You can rename the organization name but not the label.

  • By default, all configuration files configured by the installer are managed. When foreman-installer runs, it overwrites any manual changes to the managed files with the intended values. This means that running the installer on a broken system should restore it to working order, regardless of changes made. For more information on how to apply custom configuration on other services, see Applying Custom Configuration to Foreman.

Procedure
  1. Enter the following command with any additional options that you want to use:

    # foreman-installer --scenario katello \
    --foreman-initial-organization "My_Organization" \
    --foreman-initial-location "My_Location" \
    --foreman-initial-admin-username admin_user_name \
    --foreman-initial-admin-password admin_password

    The script displays its progress and writes logs to /var/log/foreman-installer/katello.log.

4. Performing additional configuration on Foreman server

4.1. Configuring Foreman Server to consume content from a custom CDN

If you have an internal Content Delivery Network (CDN) or serve content on an accessible web server, you can configure your Foreman server to consume Red Hat repositories from this CDN server instead of the Red Hat CDN. A CDN server can be any web server that mirrors repositories in the same directory structure as the Red Hat CDN.

You can configure the source of content for each organization. Foreman recognizes automatically which Red Hat repositories from the subscription manifest in your organization are available on your CDN server.

Prerequisites
  • You have a CDN server that provides Red Hat content and is accessible by Foreman server.

  • If your CDN server uses HTTPS, ensure you have uploaded the SSL certificate into Foreman. For more information, see Importing Custom SSL Certificates in Managing content.

  • You have uploaded a manifest to your organization.

Procedure
  1. In the Foreman web UI, navigate to Content > Subscriptions.

  2. Click Manage Manifest.

  3. Select the CDN Configuration tab.

  4. Select the Custom CDN tab.

  5. In the URL field, enter the URL of your CDN server from which you want Foreman server to consume Red Hat repositories.

  6. Optional: In the SSL CA Content Credential, select the SSL certificate of the CDN server.

  7. Click Update.

  8. You can now enable Red Hat repositories consumed from your internal CDN server.

CLI procedure
  1. Connect to your Foreman server using SSH.

  2. Set CDN configuration to your custom CDN server:

    # hammer organization configure-cdn --name="My_Organization" \
    --type=custom_cdn \
    --url https://my-cdn.example.com \
    --ssl-ca-credential-id "My_CDN_CA_Cert_ID"
Additional resources

4.2. Configuring Foreman for UEFI HTTP boot provisioning in an IPv6 network

Use this procedure to configure Foreman to provision hosts in an IPv6 network with UEFI HTTP Boot provisioning.

Prerequisites
  • Ensure that your clients can access DHCP and HTTP servers.

  • Ensure that the UDP ports 67 and 68 are accessible by clients so clients can send DHCP requests and receive DHCP offers.

  • Ensure that the TCP port 8000 is open for clients to download files and Kickstart templates from Foreman and Smart Proxies.

  • Ensure that the host provisioning interface subnet has an HTTP Boot Smart Proxy, and Templates Smart Proxy set. For more information, see Adding a Subnet to Foreman server in Provisioning hosts.

  • In the Foreman web UI, navigate to Administer > Settings > Provisioning and ensure that the Token duration setting is not set to 0. Foreman cannot identify clients that are booting from the network by a remote IPv6 address because of unmanaged DHCPv6 service, therefore provisioning tokens must be enabled.

Procedure
  1. You must disable DHCP management in the installer or not use it.

  2. For all IPv6 subnets created in Foreman, set the DHCP Smart Proxy to blank.

  3. Optional: If the host and the DHCP server are separated by a router, configure the DHCP relay agent and point to the DHCP server.

  4. On Foreman or Smart Proxy from which you provision, update the grub2-efi package to the latest version:

    # dnf update grub2-efi

4.3. Configuring Foreman server with an HTTP proxy

Use the following procedures to configure Foreman with an HTTP proxy.

4.3.1. Adding a default HTTP proxy to Foreman

If your network uses an HTTP Proxy, you can configure Foreman server to use an HTTP proxy for requests to the Red Hat Content Delivery Network (CDN) or another content source. Use the FQDN instead of the IP address where possible to avoid losing connectivity because of network changes.

The following procedure configures a proxy only for downloading content for Foreman. To use the CLI instead of the Foreman web UI, see the CLI procedure.

Procedure
  1. In the Foreman web UI, navigate to Infrastructure > HTTP Proxies.

  2. Click New HTTP Proxy.

  3. In the Name field, enter the name for the HTTP proxy.

  4. In the Url field, enter the URL of the HTTP proxy in the following format: https://proxy.example.com:8080.

  5. Optional: If authentication is required, in the Username field, enter the username to authenticate with.

  6. Optional: If authentication is required, in the Password field, enter the password to authenticate with.

  7. To test connection to the proxy, click Test Connection.

  8. Click Submit.

  9. In the Foreman web UI, navigate to Administer > Settings, and click the Content tab.

  10. Set the Default HTTP Proxy setting to the created HTTP proxy.

CLI procedure
  1. Verify that the http_proxy, https_proxy, and no_proxy variables are not set.

    # unset http_proxy
    # unset https_proxy
    # unset no_proxy
  2. Add an HTTP proxy entry to Foreman:

    # hammer http-proxy create --name=myproxy \
    --url http://myproxy.example.com:8080  \
    --username=proxy_username \
    --password=proxy_password
  3. Configure Foreman to use this HTTP proxy by default:

    # hammer settings set --name=content_default_http_proxy --value=myproxy

4.3.2. Configuring SELinux to ensure access to Foreman on custom ports

SELinux ensures access of Foreman only to specific ports. In the case of the HTTP cache, the TCP ports are 8080, 8118, 8123, and 10001 – 10010. If you use a port that does not have SELinux type http_cache_port_t, complete the following steps.

Procedure
  1. On Foreman, to verify the ports that are permitted by SELinux for the HTTP cache, enter a command as follows:

    # semanage port -l | grep http_cache
    http_cache_port_t       tcp    8080, 8118, 8123, 10001-10010
    [output truncated]
  2. To configure SELinux to permit a port for the HTTP cache, for example 8088, enter a command as follows:

    # semanage port -a -t http_cache_port_t -p tcp 8088

4.3.3. Using an HTTP proxy for all Foreman HTTP requests

If your Foreman server must remain behind a firewall that blocks HTTP and HTTPS, you can configure a proxy for communication with external systems, including compute resources.

Note that if you are using compute resources for provisioning, and you want to use a different HTTP proxy with the compute resources, the proxy that you set for all Foreman communication takes precedence over the proxies that you set for compute resources.

Procedure
  1. In the Foreman web UI, navigate to Administer > Settings.

  2. In the HTTP(S) proxy row, select the adjacent Value column and enter the proxy URL.

  3. Click the tick icon to save your changes.

CLI procedure
  • Enter the following command:

    # hammer settings set --name=http_proxy --value=Proxy_URL

4.3.4. Excluding hosts from receiving proxied requests

If you use an HTTP Proxy for all Foreman HTTP or HTTPS requests, you can prevent certain hosts from communicating through the proxy.

Procedure
  1. In the Foreman web UI, navigate to Administer > Settings.

  2. In the HTTP(S) proxy except hosts row, select the adjacent Value column and enter the names of one or more hosts that you want to exclude from proxy requests.

  3. Click the tick icon to save your changes.

CLI procedure
  • Enter the following command:

    # hammer settings set --name=http_proxy_except_list --value=[hostname1.hostname2...]

4.3.5. Configuring a proxy for PXE file downloads

For Red Hat content served through the Content Delivery Network, Smart Proxy downloads PXE files from synchronized repositories. However, when configuring and installing an operating system using Installation Media, Smart Proxy connects directly using the wget utility.

Procedure
  1. On Smart Proxy with the TFTP feature, to verify the ports that are permitted by SELinux for the HTTP cache, enter the following command:

    # systemctl edit foreman-proxy
  2. Insert the following test into the editor:

    [Service]
    Environment="http_proxy=http://proxy.example.com:8888"
    Environment="https_proxy=https://proxy.example.com:8888"
  3. Save the file. Verify that the file appears as /etc/systemd/system/foreman-proxy.service.d/overrides.conf.

  4. Restart the foreman-proxy service:

    # systemctl restart foreman-proxy
  5. Create a host or enter build mode for an existing host to re-download PXE files to the TFTP Smart Proxy.

4.3.6. Resetting the HTTP proxy

If you want to reset the current HTTP proxy setting, unset the Default HTTP Proxy setting.

Procedure
  1. In the Foreman web UI, navigate to Administer > Settings, and click the Content tab.

  2. Set the Default HTTP Proxy setting to no global default.

CLI procedure
  • Set the content_default_http_proxy setting to an empty string:

    # hammer settings set --name=content_default_http_proxy --value=""

4.4. Enabling power management on hosts

To perform power management tasks on hosts using the intelligent platform management interface (IPMI) or a similar protocol, you must enable the baseboard management controller (BMC) module on Foreman server.

Prerequisites
Procedure
  • To enable BMC, enter the following command:

    # foreman-installer \
    --foreman-proxy-bmc "true" \
    --foreman-proxy-bmc-default-provider "freeipmi"

4.5. Configuring DNS, DHCP, and TFTP

You can manage DNS, DHCP, and TFTP centrally within the Foreman environment, or you can manage them independently after disabling their maintenance on Foreman. You can also run DNS, DHCP, and TFTP externally, outside of the Foreman environment.

4.5.1. Configuring DNS, DHCP, and TFTP on Foreman server

To configure the DNS, DHCP, and TFTP services on Foreman server, use the foreman-installer command with the options appropriate for your environment.

Any changes to the settings require entering the foreman-installer command again. You can enter the command multiple times and each time it updates all configuration files with the changed values.

Prerequisites
  • Ensure that the following information is available to you:

    • DHCP IP address ranges

    • DHCP gateway IP address

    • DHCP nameserver IP address

    • DNS information

    • TFTP server name

  • Use the FQDN instead of the IP address where possible in case of network changes.

  • Contact your network administrator to ensure that you have the correct settings.

Procedure
  • Enter the foreman-installer command with the options appropriate for your environment. The following example shows configuring full provisioning services:

    # foreman-installer \
    --foreman-proxy-dns true \
    --foreman-proxy-dns-managed true \
    --foreman-proxy-dns-zone example.com \
    --foreman-proxy-dns-reverse 2.0.192.in-addr.arpa \
    --foreman-proxy-dhcp true \
    --foreman-proxy-dhcp-managed true \
    --foreman-proxy-dhcp-range "192.0.2.100 192.0.2.150" \
    --foreman-proxy-dhcp-gateway 192.0.2.1 \
    --foreman-proxy-dhcp-nameservers 192.0.2.2 \
    --foreman-proxy-tftp true \
    --foreman-proxy-tftp-managed true \
    --foreman-proxy-tftp-servername 192.0.2.3

You can monitor the progress of the foreman-installer command displayed in your prompt. You can view the logs in /var/log/foreman-installer/katello.log.

Additional resources
  • For more information about the foreman-installer command, enter foreman-installer --help.

4.5.2. Disabling DNS, DHCP, and TFTP for unmanaged networks

If you want to manage TFTP, DHCP, and DNS services manually, you must prevent Foreman from maintaining these services on the operating system and disable orchestration to avoid DHCP and DNS validation errors. However, Foreman does not remove the back-end services on the operating system.

Procedure
  1. On Foreman server, enter the following command:

    # foreman-installer --foreman-proxy-dhcp false \
    --foreman-proxy-dns false \
    --foreman-proxy-tftp false
  2. In the Foreman web UI, navigate to Infrastructure > Subnets and select a subnet.

  3. Click the Smart Proxies tab and clear the DHCP Smart Proxy, TFTP Smart Proxy, and Reverse DNS Smart Proxy fields.

  4. In the Foreman web UI, navigate to Infrastructure > Domains and select a domain.

  5. Clear the DNS Smart Proxy field.

  6. Optional: If you use a DHCP service supplied by a third party, configure your DHCP server to pass the following options:

    Option 66: IP address of Foreman or Smart Proxy
    Option 67: /pxelinux.0

    For more information about DHCP options, see RFC 2132.

Note
Foreman does not perform orchestration when a Smart Proxy is not set for a given subnet and domain. When enabling or disabling Smart Proxy associations, orchestration commands for existing hosts can fail if the expected records and configuration files are not present. When associating a Smart Proxy to turn orchestration on, ensure the required DHCP and DNS records as well as the TFTP files are in place for the existing Foreman hosts in order to prevent host deletion failures in the future.

4.5.3. Additional resources

4.6. Configuring Foreman server for outgoing emails

To send email messages from Foreman server, you can use either an SMTP server, or the sendmail command.

Prerequisites
  • Some SMTP servers with anti-spam protection or grey-listing features are known to cause problems. To setup outgoing email with such a service either install and configure a vanilla SMTP service on Foreman server for relay or use the sendmail command instead.

Procedure
  1. In the Foreman web UI, navigate to Administer > Settings.

  2. Click the Email tab and set the configuration options to match your preferred delivery method. The changes have an immediate effect.

    1. The following example shows the configuration options for using an SMTP server:

      Table 5. Using an SMTP server as a delivery method
      Name Example value

      Delivery method

      SMTP

      SMTP address

      smtp.example.com

      SMTP authentication

      login

      SMTP HELO/EHLO domain

      example.com

      SMTP password

      password

      SMTP port

      25

      SMTP username

      user@example.com

      The SMTP username and SMTP password specify the login credentials for the SMTP server.

    2. The following example uses gmail.com as an SMTP server:

      Table 6. Using gmail.com as an SMTP server
      Name Example value

      Delivery method

      SMTP

      SMTP address

      smtp.gmail.com

      SMTP authentication

      plain

      SMTP HELO/EHLO domain

      smtp.gmail.com

      SMTP enable StartTLS auto

      Yes

      SMTP password

      password

      SMTP port

      587

      SMTP username

      user@gmail.com

    3. The following example uses the sendmail command as a delivery method:

      Table 7. Using sendmail as a delivery method
      Name Example value

      Delivery method

      Sendmail

      Sendmail location

      /usr/sbin/sendmail

      Sendmail arguments

      -i

      For security reasons, both Sendmail location and Sendmail argument settings are read-only and can be only set in /etc/foreman/settings.yaml. Both settings currently cannot be set via foreman-installer. This is being tracked in issue #33543. For more information see the sendmail 1 man page.

  3. If you decide to send email using an SMTP server which uses TLS authentication, also perform one of the following steps:

    • Mark the CA certificate of the SMTP server as trusted. To do so, execute the following commands on Foreman server:

      # cp mailca.crt /etc/pki/ca-trust/source/anchors/
      # update-ca-trust enable
      # update-ca-trust

      Where mailca.crt is the CA certificate of the SMTP server.

    • Alternatively, in the Foreman web UI, set the SMTP enable StartTLS auto option to No.

  4. Click Test email to send a test message to the user’s email address to confirm the configuration is working. If a message fails to send, the Foreman web UI displays an error. See the log at /var/log/foreman/production.log for further details.

Additional resources

4.7. Configuring an alternate CNAME for Foreman

You can configure an alternate CNAME for Foreman. This might be useful if you want to deploy the Foreman web interface on a different domain name than the one that is used by client systems to connect to Foreman. You must plan the alternate CNAME configuration in advance prior to installing Smart Proxies and registering hosts to Foreman to avoid redeploying new certificates to hosts.

4.7.1. Configuring Foreman with an alternate CNAME

Use this procedure to configure Foreman with an alternate CNAME. Note that the procedures for users of a default Foreman certificate and custom certificate differ.

For default Foreman certificate users
  • If you have installed Foreman with a default Foreman certificate and want to configure Foreman with an alternate CNAME, enter the following command on Foreman to generate a new default Foreman SSL certificate with an additional CNAME.

    # foreman-installer --certs-cname alternate_fqdn --certs-update-server
  • If you have not installed Foreman, you can add the --certs-cname alternate_fqdn option to the foreman-installer command to install Foreman with an alternate CNAME.

For custom certificate users

If you use Foreman with a custom certificate, when creating a custom certificate, include the alternate CNAME records to the custom certificate. For more information, see Creating a Custom SSL Certificate for Foreman server.

4.7.2. Configuring hosts to use an alternate Foreman CNAME for content management

If Foreman is configured with an alternate CNAME, you can configure hosts to use the alternate Foreman CNAME for content management. To do this, you must point hosts to the alternate Foreman CNAME prior to registering the hosts to Foreman. You can do this using the bootstrap script or manually.

Configuring hosts with the bootstrap script

On the host, run the bootstrap script with the --server alternate_fqdn.example.com option to register the host to the alternate Foreman CNAME:

# ./bootstrap.py --server alternate_fqdn.example.com
Configuring hosts manually

On the host, edit the /etc/rhsm/rhsm.conf file to update hostname and baseurl settings to point to the alternate host name, for example:

[server]
# Server hostname:
hostname = alternate_fqdn.example.com

content omitted

[rhsm]
# Content base URL:
baseurl=https://alternate_fqdn.example.com/pulp/content/

Now you can register the host with the subscription-manager.

4.8. Configuring Foreman server with a custom SSL certificate

By default, Foreman uses a self-signed SSL certificate to enable encrypted communications between Foreman server, external Smart Proxy servers, and all hosts. If you cannot use a Foreman self-signed certificate, you can configure Foreman server to use an SSL certificate signed by an external certificate authority (CA).

When you configure Foreman with custom SSL certificates, you must fulfill the following requirements:

  • You must use the privacy-enhanced mail (PEM) encoding for the SSL certificates.

  • You must not use the same SSL certificate for both Foreman server and Smart Proxy server.

  • The same CA must sign certificates for Foreman server and Smart Proxy server.

  • An SSL certificate must not also be a CA certificate.

  • An SSL certificate must include a subject alt name (SAN) entry that matches the common name (CN).

  • An SSL certificate must be allowed for Key Encipherment using a Key Usage extension.

  • An SSL certificate must not have a shortname as the CN.

  • You must not set a passphrase for the private key.

To configure your Foreman server with a custom certificate, complete the following procedures:

  1. Creating a custom SSL certificate for Foreman server

  2. Deploying a custom SSL certificate to Foreman server

  3. Deploying a SSL certificate to hosts

  4. If you have external Smart Proxy servers registered to Foreman server, configure them with custom SSL certificates. For more information, see Configuring Smart Proxy server with a Custom SSL Certificate in Installing a Smart Proxy Server 3.11 on Enterprise Linux.

4.8.1. Creating a custom SSL certificate for Foreman server

Use this procedure to create a custom SSL certificate for Foreman server. If you already have a custom SSL certificate for Foreman server, skip this procedure.

Procedure
  1. To store all the source certificate files, create a directory that is accessible only to the root user:

    # mkdir /root/foreman_cert
  2. Create a private key with which to sign the certificate signing request (CSR).

    Note that the private key must be unencrypted. If you use a password-protected private key, remove the private key password.

    If you already have a private key for this Foreman server, skip this step.

    # openssl genrsa -out /root/foreman_cert/foreman_cert_key.pem 4096
  3. Create the /root/foreman_cert/openssl.cnf configuration file for the CSR and include the following content:

    [ req ]
    req_extensions = v3_req
    distinguished_name = req_distinguished_name
    prompt = no
    
    [ req_distinguished_name ]
    commonName = foreman.example.com
    
    [ v3_req ]
    basicConstraints = CA:FALSE
    keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
    extendedKeyUsage = serverAuth, clientAuth, codeSigning, emailProtection
    subjectAltName = @alt_names
    
    [ alt_names ]
    DNS.1 = foreman.example.com
  4. Optional: If you want to add Distinguished Name (DN) details to the CSR, add the following information to the [ req_distinguished_name ] section:

    [req_distinguished_name]
    CN = foreman.example.com
    countryName =My_Country_Name (1)
    stateOrProvinceName = My_State_Or_Province_Name (2)
    localityName = My_Locality_Name (3)
    organizationName = My_Organization_Or_Company_Name
    organizationalUnitName = My_Organizational_Unit_Name (4)
    1. Two letter code

    2. Full name

    3. Full name (example: New York)

    4. Division responsible for the certificate (example: IT department)

  5. Generate CSR:

    # openssl req -new \
    -key /root/foreman_cert/foreman_cert_key.pem \ (1)
    -config /root/foreman_cert/openssl.cnf \ (2)
    -out /root/foreman_cert/foreman_cert_csr.pem (3)
    1. Path to the private key

    2. Path to the configuration file

    3. Path to the CSR to generate

  6. Send the certificate signing request to the certificate authority (CA). The same CA must sign certificates for Foreman server and Smart Proxy server.

    When you submit the request, specify the lifespan of the certificate. The method for sending the certificate request varies, so consult the CA for the preferred method. In response to the request, you can expect to receive a CA bundle and a signed certificate, in separate files.

4.8.2. Deploying a custom SSL certificate to Foreman server

Use this procedure to configure your Foreman server to use a custom SSL certificate signed by a Certificate Authority. The katello-certs-check command validates the input certificate files and returns the commands necessary to deploy a custom SSL certificate to Foreman server.

Important

Do not store the SSL certificates or .tar bundles in /tmp or /var/tmp directory. The operating system removes files from these directories periodically. As a result, foreman-installer fails to execute while enabling features or upgrading Foreman server.

Procedure
  1. Validate the custom SSL certificate input files. Note that for the katello-certs-check command to work correctly, Common Name (CN) in the certificate must match the FQDN of Foreman server.

    # katello-certs-check \
    -c /root/foreman_cert/foreman_cert.pem \      (1)
    -k /root/foreman_cert/foreman_cert_key.pem \  (2)
    -b /root/foreman_cert/ca_cert_bundle.pem        (3)
    1. Path to Foreman server certificate file that is signed by a Certificate Authority.

    2. Path to the private key that was used to sign Foreman server certificate.

    3. Path to the Certificate Authority bundle.

      If the command is successful, it returns two foreman-installer commands, one of which you must use to deploy a certificate to Foreman server.

      Example output of katello-certs-check
      Validation succeeded.
      
      To install the Katello main server with the custom certificates, run:
      
        foreman-installer --scenario katello \
          --certs-server-cert "/root/foreman_cert/foreman_cert.pem" \
          --certs-server-key "/root/foreman_cert/foreman_cert_key.pem" \
          --certs-server-ca-cert "/root/foreman_cert/ca_cert_bundle.pem"
      
      To update the certificates on a currently running Katello installation, run:
      
        foreman-installer --scenario katello \
          --certs-server-cert "/root/foreman_cert/foreman_cert.pem" \
          --certs-server-key "/root/foreman_cert/foreman_cert_key.pem" \
          --certs-server-ca-cert "/root/foreman_cert/ca_cert_bundle.pem" \
          --certs-update-server --certs-update-server-ca

      Note that you must not access or modify /root/ssl-build.

  2. From the output of the katello-certs-check command, depending on your requirements, enter the foreman-installer command that installs a new Foreman with custom SSL certificates or updates certificates on a currently running Foreman.

    If you are unsure which command to run, you can verify that Foreman is installed by checking if the file /etc/foreman-installer/scenarios.d/.installed exists. If the file exists, run the second foreman-installer command that updates certificates.

    Important

    foreman-installer needs the certificate archive file after you deploy the certificate. Do not modify or delete it. It is required, for example, when upgrading Foreman server.

  3. On a computer with network access to Foreman server, navigate to the following URL: https://foreman.example.com.

  4. In your browser, view the certificate details to verify the deployed certificate.

4.8.3. Deploying a SSL certificate to hosts

After you configure Foreman to use a SSL certificate, you must deploy the certificate to hosts registered to Foreman.

Procedure
  • Update the SSL certificate on each host:

    • On Debian and Ubuntu:

      # wget http://foreman.example.com/pub/katello-rhsm-consumer
      # chmod +x katello-rhsm-consumer
      # ./katello-rhsm-consumer
    • On Enterprise Linux 8+:

      # dnf install http://foreman.example.com/pub/katello-ca-consumer-latest.noarch.rpm
    • On Enterprise Linux 7:

      # yum install http://foreman.example.com/pub/katello-ca-consumer-latest.noarch.rpm
    • On OpenSUSE and SUSE Linux Enterprise Server:

      # zypper install http://foreman.example.com/pub/katello-ca-consumer-latest.noarch.rpm

4.9. Resetting SSL certificate to default self-signed certificate on Foreman server

Procedure
  • Reset the SSL certificate to default self-signed certificate:

    # foreman-installer --certs-reset
Verification

Ensure the following parameters in /etc/foreman-installer/scenarios.d/foreman-answers.yaml have no values:

  • server_cert:

  • server_key:

  • server_cert_req:

  • server_ca_cert:

Additional resources

4.10. Using external databases with Foreman

As part of the installation process for Foreman, the foreman-installer command installs PostgreSQL databases on the same server as Foreman. In certain Foreman deployments, using external databases instead of the default local databases can help with the server load.

To create and use external databases for Foreman, you must complete the following procedures:

  1. Preparing a host for external databases. Prepare a host for the external databases.

  2. Installing PostgreSQL. Prepare PostgreSQL with databases for Foreman, Candlepin and Pulp with dedicated users owning them.

  3. Configuring Foreman server to use external databases. Edit the parameters of foreman-installer to point to the new databases, and run foreman-installer.

4.10.1. PostgreSQL as an external database considerations

Foreman, Katello, and Candlepin use the PostgreSQL database. If you want to use PostgreSQL as an external database, the following information can help you decide if this option is right for your Foreman configuration. Foreman supports PostgreSQL version 12.

Advantages of external PostgreSQL
  • Increase in free memory and free CPU on Foreman

  • Flexibility to set shared_buffers on the PostgreSQL database to a high number without the risk of interfering with other services on Foreman

  • Flexibility to tune the PostgreSQL server’s system without adversely affecting Foreman operations

Disadvantages of external PostgreSQL
  • Increase in deployment complexity that can make troubleshooting more difficult

  • The external PostgreSQL server is an additional system to patch and maintain

  • If either Foreman or the PostgreSQL database server suffers a hardware or storage failure, Foreman is not operational

  • If there is latency between the Foreman server and database server, performance can suffer

4.10.2. Preparing a host for external databases

Install a freshly provisioned system with the latest Enterprise Linux 9 or Enterprise Linux 8 to host the external databases.

Prerequisites
Procedure

Select the operating system and version you are installing external database on:

Enterprise Linux 9
  1. Install the katello-repos-latest.rpm package

    # dnf install https://yum.theforeman.org/releases/3.11/el9/x86_64/foreman-release.rpm \
    https://yum.theforeman.org/katello/4.13/katello/el9/x86_64/katello-repos-latest.rpm
Verification
  • Verify that the required repositories are enabled:

    # dnf repolist enabled
Enterprise Linux 8
  1. Install the katello-repos-latest.rpm package

    # dnf install https://yum.theforeman.org/releases/3.11/el8/x86_64/foreman-release.rpm \
    https://yum.theforeman.org/katello/4.13/katello/el8/x86_64/katello-repos-latest.rpm
  2. Enable the following module:

    # dnf module enable katello:el8
    Note

    Enablement of the module katello:el8 warns about a conflict with postgresql:10 and ruby:2.5 as these modules are set to the default module versions on Enterprise Linux 8. The module katello:el8 has a dependency for the modules postgresql:12 and ruby:2.7 that will be enabled with the katello:el8 module. These warnings do not cause installation process failure, hence can be ignored safely.

Verification
  • Verify that the required repositories are enabled:

    # dnf repolist enabled

4.10.3. Installing PostgreSQL

You can install only the same version of PostgreSQL that is installed with the foreman-installer tool during an internal database installation. Foreman supports PostgreSQL version 12.

If you do not use firewall-cmd to configure the Linux firewall, implement using the command of your choice.

Procedure
  1. To install PostgreSQL, enter the following command:

    # dnf install postgresql-server postgresql-evr postgresql-contrib
  2. To initialize PostgreSQL, enter the following command:

    # postgresql-setup initdb
  3. Edit the /var/lib/pgsql/data/postgresql.conf file:

    # vi /var/lib/pgsql/data/postgresql.conf

    Note that the default configuration of external PostgreSQL needs to be adjusted to work with Foreman. The base recommended external database configuration adjustments are as follows:

    • checkpoint_completion_target: 0.9

    • max_connections: 500

    • shared_buffers: 512MB

    • work_mem: 4MB

  4. Remove the # and edit to listen to inbound connections:

    listen_addresses = '*'
  5. Edit the /var/lib/pgsql/data/pg_hba.conf file:

    # vi /var/lib/pgsql/data/pg_hba.conf
  6. Add the following line to the file:

      host  all   all   Foreman_ip/32   md5
  7. To start, and enable PostgreSQL service, enter the following commands:

    # systemctl enable --now postgresql
  8. Open the postgresql port on the external PostgreSQL server:

    # firewall-cmd --add-service=postgresql
  9. Make the changes persistent:

    # firewall-cmd --runtime-to-permanent
  10. Switch to the postgres user and start the PostgreSQL client:

    $ su - postgres -c psql
  11. Create three databases and dedicated roles: one for Foreman, one for Candlepin, and one for Pulp:

    CREATE USER "foreman" WITH PASSWORD 'Foreman_Password';
    CREATE USER "candlepin" WITH PASSWORD 'Candlepin_Password';
    CREATE USER "pulp" WITH PASSWORD 'Pulpcore_Password';
    CREATE DATABASE foreman OWNER foreman;
    CREATE DATABASE candlepin OWNER candlepin;
    CREATE DATABASE pulpcore OWNER pulp;
  12. Connect to the Pulp database:

    postgres=# \c pulpcore
    You are now connected to database "pulpcore" as user "postgres".
  13. Create the hstore extension:

    pulpcore=# CREATE EXTENSION IF NOT EXISTS "hstore";
    CREATE EXTENSION
  14. Exit the postgres user:

    # \q
  15. From Foreman server, test that you can access the database. If the connection succeeds, the commands return 1.

    # PGPASSWORD='Foreman_Password' psql -h postgres.example.com  -p 5432 -U foreman -d foreman -c "SELECT 1 as ping"
    # PGPASSWORD='Candlepin_Password' psql -h postgres.example.com -p 5432 -U candlepin -d candlepin -c "SELECT 1 as ping"
    # PGPASSWORD='Pulpcore_Password' psql -h postgres.example.com -p 5432 -U pulp -d pulpcore -c "SELECT 1 as ping"

4.10.4. Configuring Foreman server to use external databases

Use the foreman-installer command to configure Foreman to connect to an external PostgreSQL database.

Prerequisites
  • You have installed and configured a PostgreSQL database on a Enterprise Linux server.

Procedure
  1. To configure the external databases for Foreman, enter the following command:

    # foreman-installer \
    --foreman-db-database foreman \
    --foreman-db-host postgres.example.com \
    --foreman-db-manage false \
    --foreman-db-password Foreman_Password \
    --foreman-proxy-content-pulpcore-manage-postgresql false \
    --foreman-proxy-content-pulpcore-postgresql-db-name pulpcore \
    --foreman-proxy-content-pulpcore-postgresql-host postgres.example.com \
    --foreman-proxy-content-pulpcore-postgresql-password Pulpcore_Password \
    --foreman-proxy-content-pulpcore-postgresql-user pulp \
    --katello-candlepin-db-host postgres.example.com \
    --katello-candlepin-db-name candlepin \
    --katello-candlepin-db-password Candlepin_Password \
    --katello-candlepin-manage-db false

    To enable the Secure Sockets Layer (SSL) protocol for these external databases, add the following options:

    --foreman-db-root-cert <path_to_CA>
    --foreman-db-sslmode verify-full
    --foreman-proxy-content-pulpcore-postgresql-ssl true
    --foreman-proxy-content-pulpcore-postgresql-ssl-root-ca <path_to_CA>
    --katello-candlepin-db-ssl true
    --katello-candlepin-db-ssl-ca <path_to_CA>
    --katello-candlepin-db-ssl-verify true

5. Configuring external authentication

By using external authentication you can derive user and user group permissions from user group membership in an external identity provider. When you use external authentication, you do not have to create these users and maintain their group membership manually on Foreman server. In case the external source does not provide email, it will be requested during the first login through Foreman web UI.

Important user and group account information

All user and group accounts must be local accounts. This is to ensure that there are no authentication conflicts between local accounts on your Foreman server and accounts in your Active Directory domain.

Your system is not affected by this conflict if your user and group accounts exist in both /etc/passwd and /etc/group files. For example, to check if entries for puppet, apache, foreman and foreman-proxy groups exist in both /etc/passwd and /etc/group files, enter the following commands:

# grep 'puppet\|apache\|foreman\|foreman-proxy' /etc/passwd /etc/group

5.1. Configuring an LDAP server as an external identity provider for Foreman

Lightweight Directory Access Protocol (LDAP) is a set of open protocols used to access centrally stored information over a network. With Foreman, you can use one or multiple LDAP directories for external authentication.

Important

Users cannot use both FreeIPA and LDAP as an authentication method. After a user authenticates by using one of these methods, they cannot use the other method.

To change the authentication method for a user, remove the automatically created user from Foreman.

For more information on using FreeIPA as an authentication method, see Using FreeIPA.

5.1.1. Configuring TLS for secure LDAP

If Foreman uses TLS to establish a secure LDAP connection (LDAPS), you must obtain the CA certificates of your LDAP server and add them to the trusted CA list on the base operating system of your Foreman server.

If your LDAP server uses a certificate chain with intermediate certificate authorities, you must obtain all root and intermediate certificates and add them to the trusted CA list.

Procedure
  1. Obtain the CA certificate from the LDAP Server:

    1. If you use Active Directory Certificate Services, export the Enterprise PKI CA Certificate using the Base64 encoded X.509 format. See How to configure Active Directory authentication with TLS on Foreman for information on creating and exporting a CA certificate from an Active Directory server.

    2. Download the LDAP server certificate to a temporary location on the Foreman server, such as /tmp/example.crt. You will remove the certificate when finished.

      The filename extensions .cer and .crt are only conventions and can refer to DER binary or PEM ASCII format certificates.

  2. Add the LDAP certificate to your CA trust list:

    1. Install the LDAP certificate in the /etc/pki/tls/certs/ directory with the correct permissions:

      # install /tmp/example.crt /etc/pki/tls/certs/

      LDAP certificates must be individual files.

    2. Create a symbolic link to the LDAP certificate:

      # ln -s example.crt /etc/pki/tls/certs/$(openssl \
      x509 -noout -hash -in \
      /etc/pki/tls/certs/example.crt).0
    3. Restart the httpd service:

      # systemctl restart httpd
  3. Delete the downloaded LDAP certificate from the temporary location on your Foreman server.

5.1.2. Configuring Foreman to use LDAP

Configure an LDAP authentication source to enable users to log in to Foreman with their existing LDAP credentials.

Prerequisites
  • Your user account has the following permissions:

    • view_authenticators, create_authenticators, edit_authenticators

    • view_locations, assign_locations

    • view_organizations, assign_organizations

Procedure
  1. On your Foreman server, enable the Network Information System (NIS) service so that SELinux does not block outgoing LDAP connections:

    # setsebool -P nis_enabled on
  2. In the Foreman web UI, navigate to Administer > Authentication Sources.

  3. From the LDAP menu, select Create.

  4. On the LDAP server tab, enter the details of your LDAP server.

    For TLS encrypted connections, select LDAPS to enable encryption.

  5. On the Account tab, enter the account information and domain name details.

  6. On the Attribute mappings tab, map LDAP attributes to Foreman attributes.

  7. On the Locations tab, select the locations you want Foreman to assign to users created from the LDAP authentication source. These locations are available to users after they log in for the first time.

  8. On the Organizations tab, select the organizations you want Foreman to assign to users created from the LDAP authentication source. These locations are available to users after they log in for the first time.

  9. Click Submit.

Next steps
  • If you did not select Automatically Create Accounts In Foreman on the Account tab, create user accounts manually. For more information, see Creating a User in Administering Foreman.

  • If you selected Automatically Create Accounts In Foreman, LDAP users can now log in to Foreman using their LDAP accounts and passwords.

  • After users log in for the first time, the Foreman administrator must assign roles to them manually. For more information about assigning appropriate roles to user accounts, see Assigning Roles to a User in Administering Foreman.

5.1.3. Example settings for LDAP connections

Example 1. Example settings for Active Directory LDAP connections

This example uses a dedicated service account called redhat that has bind, read, and search permissions on the user and group entries.

  • Account Username: DOMAIN\redhat

  • Account password: P@ssword

  • Base DN: DC=example,DC=COM

  • Login name attribute: userPrincipalName

  • First name attribute: givenName

  • Last name attribute: sn

  • Email address attribute: mail

  • Photo attribute: thumbnailPhoto

The userPrincipalName attribute allows the use of whitespace in usernames. The sAMAccountName attribute, which provides backwards compatibility with legacy Microsoft systems, does not allow the use of whitespace in usernames.

Example 2. Example settings for FreeIPA LDAP connections

This example uses a dedicated service account called redhat that has bind, read, and search permissions on the user and group entries.

  • Account Username: uid=redhat,cn=users,cn=accounts,dc=example,dc=com

  • Base DN: dc=example,dc=com

  • Groups Base DN: cn=groups,cn=accounts,dc=example,dc=com

  • Login name attribute: uid

  • First name attribute: givenName

  • Last name attribute: sn

  • Email address attribute: mail

Example 3. Example settings for POSIX LDAP connections

This example uses a dedicated service account called redhat that has bind, read, and search permissions on the user and group entries.

  • Account Username: uid=redhat,ou=users,dc=example,dc=com

  • Base DN: dc=example,dc=com

  • Groups Base DN: cn=employee,ou=userclass,dc=example,dc=com

  • Login name attribute: uid

  • First name attribute: givenName

  • Last name attribute: sn

  • Email address attribute: mail

5.1.4. Example LDAP filters

Example 4. Example LDAP filters for allowing specific users to login

You are using the following LDAP directory structure:

DC=Domain,DC=Example
   |
   |----- CN=Users
         |
         |----- CN=Group1
         |----- CN=Group2
         |----- CN=User1
         |----- CN=User2
         |----- CN=User3

Group membership is defined as follows:

  • Group1 includes users User1 and User3

  • Group2 includes users User2 and User3

For example, you can define the following search filters:

Search result (users) Filter

User1

(distinguishedName=cn=User1,cn=Users,dc=domain,dc=example)

User1, User3

(memberOf=cn=Group1,cn=Users,dc=domain,dc=example)

User2, User3

(memberOf=cn=Group2,cn=Users,dc=domain,dc=example)

User1, User2, User3

(|(memberOf=cn=Group1,cn=Users,dc=domain,dc=example)(memberOf=cn=Group2,cn=Users,dc=domain,dc=example))

User1, User2, User3

(memberOf:1.2.840.113556.1.4.1941:=cn=Users,dc=domain,dc=example)

Because group Users is a nested group that contains groups Group1 and Group2, the filter must include memberOf:1.2.840.113556.1.4.1941:= before the nested group name. This enables you to filter all users from the nested group.

5.2. Configuring a FreeIPA server as an external identity provider for Foreman

FreeIPA deals with the management of individual identities, their credentials, and privileges used in a networking environment.

5.2.1. Using FreeIPA

This section shows how to integrate Foreman server with a FreeIPA server and how to enable host-based access control.

Note

You can attach FreeIPA as an external authentication source with no single sign-on support. For more information, see Configuring an LDAP server as an external identity provider for Foreman.

Important

Users cannot use both FreeIPA and LDAP as an authentication method. After a user authenticates by using one of these methods, they cannot use the other method.

To change the authentication method for a user, remove the automatically created user from Foreman.

Prerequisites
  • The base operating system of Foreman server must be enrolled in the FreeIPA domain by the FreeIPA administrator of your organization.

The examples in this chapter assume separation between FreeIPA and Foreman configuration. However, if you have administrator privileges for both servers, you can configure FreeIPA as described in Red Hat Enterprise Linux 9 Installing Identity Management or Red Hat Enterprise Linux 8 Installing Identity Management Guide.

5.2.2. Configuring FreeIPA authentication on Foreman server

In the Foreman CLI, configure FreeIPA authentication by first creating a host entry on the FreeIPA server.

Procedure
  1. On the FreeIPA server, to authenticate, enter the following command and enter your password when prompted:

    # kinit admin
  2. To verify that you have authenticated, enter the following command:

    # klist
  3. On the FreeIPA server, create a host entry for Foreman server and generate a one-time password, for example:

    # ipa host-add --random hostname
    Note

    The generated one-time password must be used on the client to complete FreeIPA-enrollment.

  4. Create an HTTP service for Foreman server, for example:

    # ipa service-add HTTP/hostname
  5. On Foreman server, install the IPA client:

    # dnf install ipa-client
  6. On Foreman server, enter the following command as root to configure FreeIPA-enrollment:

    # ipa-client-install --password OTP

    Replace OTP with the one-time password provided by the FreeIPA administrator.

  7. Set FreeIPA as the authentication provider, using one of the following commands:

    • If you only want to enable access to the Foreman web UI but not the Foreman API, enter:

      # foreman-installer \
      --foreman-ipa-authentication=true
    • If you want to enable access both to the Foreman web UI and the Foreman API, enter:

      # foreman-installer \
      --foreman-ipa-authentication-api=true \
      --foreman-ipa-authentication=true
      Warning

      Enabling access to both the Foreman API and the Foreman web UI can lead to security problems. After an IdM user receives a Kerberos ticket-granting ticket (TGT) by entering kinit user_name, an attacker can obtain an API session. The attack is possible even if the user did not previously enter the Foreman login credentials anywhere, for example in the browser.

  8. Restart Foreman services:

    # foreman-maintain service restart

External users can now log in to Foreman using their FreeIPA credentials. They can now choose to either log in to Foreman server directly using their username and password or take advantage of the configured Kerberos single sign-on and obtain a ticket on their client machine and be logged in automatically. The two-factor authentication with one-time password (2FA OTP) is also supported.

5.2.3. Configuring host-based authentication control

HBAC rules define which machine within the domain a FreeIPA user is allowed to access. You can configure HBAC on the FreeIPA server to prevent selected users from accessing Foreman server. With this approach, you can prevent Foreman from creating database entries for users that are not allowed to log in. For more information on HBAC, see Red Hat Enterprise Linux 9 Managing IdM users, groups, hosts, and access control rules or Red Hat Enterprise Linux 8 Managing IdM users, groups, hosts, and access control rules.

On the FreeIPA server, configure Host-Based Authentication Control (HBAC).

Procedure
  1. On the FreeIPA server, to authenticate, enter the following command and enter your password when prompted:

    # kinit admin
  2. To verify that you have authenticated, enter the following command:

    # klist
  3. Create HBAC service and rule on the FreeIPA server and link them together. The following examples use the PAM service name foreman-prod. Execute the following commands on the FreeIPA server:

    # ipa hbacsvc-add foreman-prod
    # ipa hbacrule-add allow_foreman_prod
    # ipa hbacrule-add-service allow_foreman_prod --hbacsvcs=foreman-prod
  4. Add the user who is to have access to the service foreman-prod, and the hostname of Foreman server:

    # ipa hbacrule-add-user allow_foreman_prod --user=username
    # ipa hbacrule-add-host allow_foreman_prod --hosts=foreman.example.com

    Alternatively, host groups and user groups can be added to the allowforeman_prod_ rule.

  5. To check the status of the rule, execute:

    # ipa hbacrule-find foreman-prod
    # ipa hbactest --user=username --host=foreman.example.com --service=foreman-prod
  6. Ensure the allow_all rule is disabled on the FreeIPA server. For instructions on how to do so without disrupting other services see the How to configure HBAC rules in IdM article on the Red Hat Customer Portal.

  7. Configure the FreeIPA integration with Foreman server as described in Configuring FreeIPA authentication on Foreman server. On Foreman server, define the PAM service as root:

    # foreman-installer --foreman-pam-service=foreman-prod

5.3. Configuring Active Directory integrated with FreeIPA through cross-forest Kerberos trust as an external identity provider for Foreman

Kerberos can create cross-forest trust that defines a relationship between two otherwise separate domain forests. A domain forest is a hierarchical structure of domains; both AD and FreeIPA constitute a forest. With a trust relationship enabled between AD and FreeIPA, AD users can access Linux hosts and services using a single set of credentials.

5.3.1. Active Directory with cross-forest trust

Kerberos can create cross-forest trust that defines a relationship between two otherwise separate domain forests. A domain forest is a hierarchical structure of domains; both AD and FreeIPA constitute a forest. With a trust relationship enabled between AD and FreeIPA, users of AD can access Linux hosts and services using a single set of credentials.

From the Foreman point of view, the configuration process is the same as integration with FreeIPA server without cross-forest trust configured. Foreman server has to be enrolled in the IdM domain and integrated as described in Using FreeIPA.

5.4. Configuring Wildfly-based Keycloak authentication for Foreman

Use this section to configure Foreman to use Wildfly-based Keycloak as an OpenID provider for external authentication.

5.4.1. Prerequisites for configuring Foreman with Wildfly-based Keycloak authentication

Before configuring Foreman with Wildfly-based Keycloak external authentication, ensure that you meet the following requirements:

  • A working installation of Wildfly-based Keycloak server that uses HTTPS instead of HTTP.

  • A Wildfly-based Keycloak account with admin privileges.

  • A realm for Foreman user accounts created in Wildfly-based Keycloak.

  • If the certificates or the CA are self-signed, ensure that they are added to the end-user certificate trust store.

  • Users imported or added to Wildfly-based Keycloak.

    If you have an existing user database configured such as LDAP or Kerberos, you can import users from it by configuring user federation. For more information, see User Storage Federation in the Red Hat Single Sign-On Server Administration Guide.

    If you do not have an existing user database configured, you can manually create users in Wildfly-based Keycloak. For more information, see Creating New Users in the Red Hat Single Sign-On Server Administration Guide.

5.4.2. Registering Foreman as a client of Keycloak

Use this procedure to register Foreman to Keycloak as a client and configure Foreman to use Keycloak as an authentication source.

You can configure Foreman and Keycloak with two different authentication methods:

  1. Users authenticate to Foreman using the Foreman web UI.

  2. Users authenticate to Foreman using the Foreman CLI.

You must decide on how you want your users to authenticate in advance because both methods require different Foreman clients to be registered to Keycloak and configured. The steps to register and configure Foreman client in Keycloak are distinguished within the procedure.

You can also register two different Foreman clients to Keycloak if you want to use both authentication methods and configure both clients accordingly.

Procedure
  1. On Foreman server, install the following packages:

    # dnf install mod_auth_openidc keycloak-httpd-client-install python3-lxml
  2. Register Foreman to Keycloak as a client. Note that you the registration process for logging in using the web UI and the CLI are different. You can register two clients Foreman clients to Keycloak to be able to log in to Foreman from the web UI and the CLI.

    • If you want you users to authenticate to Foreman using the web UI, create a client as follows:

      # keycloak-httpd-client-install --app-name foreman-openidc \
      --keycloak-server-url "https://keycloak.example.com" \
      --keycloak-admin-username "admin" \
      --keycloak-realm "Foreman_Realm" \
      --keycloak-admin-realm master \
      --keycloak-auth-role root-admin \
      -t openidc -l /users/extlogin --force

      Enter the password for the administer account when prompted. This command creates a client for Foreman in Keycloak.

      Then, configure Foreman to use Keycloak as an authentication source:

      # foreman-installer --foreman-keycloak true \
      --foreman-keycloak-app-name "foreman-openidc" \
      --foreman-keycloak-realm "Foreman_Realm"
    • If you want your users to authenticate to Foreman using the CLI, create a client as follows:

      # keycloak-httpd-client-install --app-name hammer-openidc \
      --keycloak-server-url "https://keycloak.example.com" \
      --keycloak-admin-username "admin" \
      --keycloak-realm "Foreman_Realm" \
      --keycloak-admin-realm master \
      --keycloak-auth-role root-admin \
      -t openidc -l /users/extlogin --force

      Enter the password for the administer account when prompted. This command creates a client for Foreman in Keycloak.

  3. Restart the httpd service:

    # systemctl restart httpd

5.4.3. Configuring the Foreman client in Wildfly-based Keycloak

Use this procedure to configure the Foreman client in the Wildfly-based Keycloak web UI and create group and audience mappers for the Foreman client.

Procedure
  1. In the Wildfly-based Keycloak web UI, navigate to the created Foreman realm, then Clients and click the Foreman client.

  2. Configure access type:

    • If you want your users to authenticate to Foreman using the Foreman web UI, from the Access Type list, select confidential.

    • If you want your users to authenticate to Foreman using the CLI, from the Access Type list, select public.

  3. In the Valid redirect URI fields, add a valid redirect URI.

    • If you want your users to authenticate to Foreman using the Foreman web UI, in the blank field below the existing URI, enter a URI in the form https://foreman.example.com/users/extlogin. Note that you must add the string /users/extlogin after the Foreman FQDN.

      After completing this step, the Foreman client for logging in using the Foreman web UI must have the following Valid Redirect URIs:

      https://foreman.example.com/users/extlogin/redirect_uri
      https://foreman.example.com/users/extlogin
    • If you want your users to authenticate to Foreman using the CLI, in the blank field below the existing URI, enter urn:ietf:wg:oauth:2.0:oob.

      After completing this step, the Foreman client for logging in using the CLI must have the following Valid Redirect URIs:

      https://foreman.example.com/users/extlogin/redirect_uri
      urn:ietf:wg:oauth:2.0:oob
  4. Click Save.

  5. Click the Mappers tab and click Create to add an audience mapper.

  6. In the Name field, enter a name for the audience mapper.

  7. From the Mapper Type list, select Audience.

  8. From the Included Client Audience list, select the Foreman client.

  9. Click Save.

  10. Click Create to add a group mapper so that you can specify authorization in Foreman based on group membership.

  11. In the Name field, enter a name for the group mapper.

  12. From the Mapper Type list, select Group Membership.

  13. In the Token Claim Name field, enter groups.

  14. Set the Full group path setting to OFF.

  15. Click Save.

5.4.4. Configuring Foreman settings for Wildfly-based Keycloak authentication using the web UI

Use this procedure to configure Foreman settings for Wildfly-based Keycloak authentication using the Foreman web UI.

Note that you can navigate to the following URL within your realm to obtain values to configure Foreman settings: https://keycloak.example.com/auth/realms/Foreman_Realm/.well-known/openid-configuration

Prerequisites
  • Ensure that the Access Type setting in the Foreman client in the Wildfly-based Keycloak web UI is set to confidential.

Procedure
  1. In the Foreman web UI, navigate to Administer > Settings, and click the Authentication tab.

  2. Locate the Authorize login delegation row, and in the Value column, set the value to Yes.

  3. Locate the Authorize login delegation auth source user autocreate row, and in the Value column, set the value to External.

  4. Locate the Login delegation logout URL row, and in the Value column, set the value to https://foreman.example.com/users/extlogout.

  5. Locate the OIDC Algorithm row, and in the Value column, set the algorithm for encoding on Wildfly-based Keycloak to RS256.

  6. Locate the OIDC Audience row, and in the Value column, set the value to the client ID for Wildfly-based Keycloak.

  7. Locate the OIDC Issuer row, and in the Value column, set the value to https://keycloak.example.com/auth/realms/Foreman_Realm.

  8. Locate the OIDC JWKs URL row, and in the Value column, set the value to https://keycloak.example.com/auth/realms/Foreman_Realm/protocol/openid-connect/certs.

  9. In the Foreman web UI, navigate to Administer > Authentication Sources, click the vertical ellipsis on the External card, and select Edit.

  10. Click the Locations tab and add locations that can use the Wildfly-based Keycloak authentication source.

  11. Click the Organizations tab and add organizations that can use the Wildfly-based Keycloak authentication source.

  12. Click Submit.

5.4.5. Configuring Foreman settings for Wildfly-based Keycloak authentication using the CLI

Use this procedure to configure Foreman settings for Wildfly-based Keycloak authentication using the Foreman CLI.

Note that you can navigate to the following URL within your realm to obtain values to configure Foreman settings: https://keycloak.example.com/auth/realms/Foreman_Realm/.well-known/openid-configuration

Prerequisites
  • Ensure that the Access Type setting in the Foreman client in the Wildfly-based Keycloak web UI is set to public.

Procedure
  1. On Foreman, set the login delegation to true so that users can authenticate using the Open IDC protocol:

    # hammer settings set --name authorize_login_delegation --value true
  2. Set the login delegation logout URL:

    # hammer settings set --name login_delegation_logout_url \
    --value https://foreman.example.com/users/extlogout
  3. Set the algorithm for encoding on Wildfly-based Keycloak, for example, RS256:

    # hammer settings set --name oidc_algorithm --value 'RS256'
  4. Open the keycloak.example.com/auth/realms/KEYCLOAK_REALM/.well-known/openid-configuration URL and note the values to populate the options in the following steps.

  5. Add the value for the Hammer client in the Open IDC audience:

    # hammer settings set --name oidc_audience \
    --value "['foreman.example.com-hammer-openidc']"
    Note

    If you register several Wildfly-based Keycloak clients to Foreman, ensure that you append all audiences in the array. For example:

    # hammer settings set --name oidc_audience \
    --value "['foreman.example.com-foreman-openidc', 'foreman.example.com-hammer-openidc']"
  6. Set the value for the Open IDC issuer:

    # hammer settings set --name oidc_issuer \
    --value "keycloak.example.com/auth/realms/KEYCLOAK_REALM"
  7. Set the value for Open IDC Java Web Token (JWT):

    # hammer settings set --name oidc_jwks_url \
    --value "{keycloak-example.com}/auth/realms/KEYCLOAK_REALM/protocol/openid-connect/certs"
  8. Retrieve the ID of the Wildfly-based Keycloak authentication source:

    # hammer auth-source external list
  9. Set the location and organization:

    # hammer auth-source external update --id Authentication Source ID \
    --location-ids Location ID --organization-ids Organization ID

5.4.6. Logging in to the Foreman web UI using Keycloak

Use this procedure to log in to the Foreman web UI using Keycloak.

Procedure
  • In your browser, log in to Foreman and enter your credentials.

5.4.7. Logging in to the Foreman CLI using Keycloak

Use this procedure to authenticate to the Foreman CLI using the code grant type.

Procedure
  1. To authenticate to the Foreman CLI using the code grant type, enter the following command:

    # hammer auth login oauth \
    --two-factor \
    --oidc-token-endpoint 'https://keycloak.example.com/auth/realms/ssl-realm/protocol/openid-connect/token' \
    --oidc-authorization-endpoint 'https://keycloak.example.com/auth' \
    --oidc-client-id 'foreman.example.com-foreman-openidc' \
    --oidc-redirect-uri urn:ietf:wg:oauth:2.0:oob

    The command prompts you to enter a success code.

  2. To retrieve the success code, navigate to the URL that the command returns and provide the required information.

  3. Copy the success code that the web UI returns.

  4. In the command prompt of hammer auth login oauth, enter the success code to authenticate to the Foreman CLI.

5.4.8. Configuring group mapping for Keycloak authentication

Optionally, to implement the Role Based Access Control (RBAC), create a group in Foreman, assign a role to this group, and then map an Active Directory group to the Foreman group. As a result, anyone in the given group in Keycloak are logged in under the corresponding Foreman group. This example configures users of the Foreman-admin user group in the Active Directory to authenticate as users with administrator privileges on Foreman.

Procedure
  1. In the Foreman web UI, navigate to Administer > User Groups.

  2. Click Create User Group.

  3. In the Name field, enter a name for the user group. The name should not be the same as in the Active Directory.

  4. Do not add users and user groups to the right-hand columns. Click the Roles tab.

  5. Select the Administer checkbox.

  6. Click the External Groups tab.

  7. Click Add external user group.

  8. In the Name field, enter the name of the Active Directory group.

  9. From the list, select EXTERNAL.

5.5. Configuring Wildfly-based Keycloak authentication with TOTP cards for Foreman

Use this section to configure Foreman to use Wildfly-based Keycloak as an OpenID provider for external authentication with TOTP cards.

5.5.1. Prerequisites for configuring Foreman with Wildfly-based Keycloak authentication

Before configuring Foreman with Wildfly-based Keycloak external authentication, ensure that you meet the following requirements:

  • A working installation of Wildfly-based Keycloak server that uses HTTPS instead of HTTP.

  • A Wildfly-based Keycloak account with admin privileges.

  • A realm for Foreman user accounts created in Wildfly-based Keycloak.

  • If the certificates or the CA are self-signed, ensure that they are added to the end-user certificate trust store.

  • Users imported or added to Wildfly-based Keycloak.

    If you have an existing user database configured such as LDAP or Kerberos, you can import users from it by configuring user federation. For more information, see User Storage Federation in the Red Hat Single Sign-On Server Administration Guide.

    If you do not have an existing user database configured, you can manually create users in Wildfly-based Keycloak. For more information, see Creating New Users in the Red Hat Single Sign-On Server Administration Guide.

5.5.2. Registering Foreman as a client of Keycloak

Use this procedure to register Foreman to Keycloak as a client and configure Foreman to use Keycloak as an authentication source.

You can configure Foreman and Keycloak with two different authentication methods:

  1. Users authenticate to Foreman using the Foreman web UI.

  2. Users authenticate to Foreman using the Foreman CLI.

You must decide on how you want your users to authenticate in advance because both methods require different Foreman clients to be registered to Keycloak and configured. The steps to register and configure Foreman client in Keycloak are distinguished within the procedure.

You can also register two different Foreman clients to Keycloak if you want to use both authentication methods and configure both clients accordingly.

Procedure
  1. On Foreman server, install the following packages:

    # dnf install mod_auth_openidc keycloak-httpd-client-install python3-lxml
  2. Register Foreman to Keycloak as a client. Note that you the registration process for logging in using the web UI and the CLI are different. You can register two clients Foreman clients to Keycloak to be able to log in to Foreman from the web UI and the CLI.

    • If you want you users to authenticate to Foreman using the web UI, create a client as follows:

      # keycloak-httpd-client-install --app-name foreman-openidc \
      --keycloak-server-url "https://keycloak.example.com" \
      --keycloak-admin-username "admin" \
      --keycloak-realm "Foreman_Realm" \
      --keycloak-admin-realm master \
      --keycloak-auth-role root-admin \
      -t openidc -l /users/extlogin --force

      Enter the password for the administer account when prompted. This command creates a client for Foreman in Keycloak.

      Then, configure Foreman to use Keycloak as an authentication source:

      # foreman-installer --foreman-keycloak true \
      --foreman-keycloak-app-name "foreman-openidc" \
      --foreman-keycloak-realm "Foreman_Realm"
    • If you want your users to authenticate to Foreman using the CLI, create a client as follows:

      # keycloak-httpd-client-install --app-name hammer-openidc \
      --keycloak-server-url "https://keycloak.example.com" \
      --keycloak-admin-username "admin" \
      --keycloak-realm "Foreman_Realm" \
      --keycloak-admin-realm master \
      --keycloak-auth-role root-admin \
      -t openidc -l /users/extlogin --force

      Enter the password for the administer account when prompted. This command creates a client for Foreman in Keycloak.

  3. Restart the httpd service:

    # systemctl restart httpd

5.5.3. Configuring the Foreman client in Wildfly-based Keycloak

Use this procedure to configure the Foreman client in the Wildfly-based Keycloak web UI and create group and audience mappers for the Foreman client.

Procedure
  1. In the Wildfly-based Keycloak web UI, navigate to the created Foreman realm, then Clients and click the Foreman client.

  2. Configure access type:

    • If you want your users to authenticate to Foreman using the Foreman web UI, from the Access Type list, select confidential.

    • If you want your users to authenticate to Foreman using the CLI, from the Access Type list, select public.

  3. In the Valid redirect URI fields, add a valid redirect URI.

    • If you want your users to authenticate to Foreman using the Foreman web UI, in the blank field below the existing URI, enter a URI in the form https://foreman.example.com/users/extlogin. Note that you must add the string /users/extlogin after the Foreman FQDN.

      After completing this step, the Foreman client for logging in using the Foreman web UI must have the following Valid Redirect URIs:

      https://foreman.example.com/users/extlogin/redirect_uri
      https://foreman.example.com/users/extlogin
    • If you want your users to authenticate to Foreman using the CLI, in the blank field below the existing URI, enter urn:ietf:wg:oauth:2.0:oob.

      After completing this step, the Foreman client for logging in using the CLI must have the following Valid Redirect URIs:

      https://foreman.example.com/users/extlogin/redirect_uri
      urn:ietf:wg:oauth:2.0:oob
  4. Click Save.

  5. Click the Mappers tab and click Create to add an audience mapper.

  6. In the Name field, enter a name for the audience mapper.

  7. From the Mapper Type list, select Audience.

  8. From the Included Client Audience list, select the Foreman client.

  9. Click Save.

  10. Click Create to add a group mapper so that you can specify authorization in Foreman based on group membership.

  11. In the Name field, enter a name for the group mapper.

  12. From the Mapper Type list, select Group Membership.

  13. In the Token Claim Name field, enter groups.

  14. Set the Full group path setting to OFF.

  15. Click Save.

5.5.4. Configuring Foreman settings for Wildfly-based Keycloak authentication using the web UI

Use this procedure to configure Foreman settings for Wildfly-based Keycloak authentication using the Foreman web UI.

Note that you can navigate to the following URL within your realm to obtain values to configure Foreman settings: https://keycloak.example.com/auth/realms/Foreman_Realm/.well-known/openid-configuration

Prerequisites
  • Ensure that the Access Type setting in the Foreman client in the Wildfly-based Keycloak web UI is set to confidential.

Procedure
  1. In the Foreman web UI, navigate to Administer > Settings, and click the Authentication tab.

  2. Locate the Authorize login delegation row, and in the Value column, set the value to Yes.

  3. Locate the Authorize login delegation auth source user autocreate row, and in the Value column, set the value to External.

  4. Locate the Login delegation logout URL row, and in the Value column, set the value to https://foreman.example.com/users/extlogout.

  5. Locate the OIDC Algorithm row, and in the Value column, set the algorithm for encoding on Wildfly-based Keycloak to RS256.

  6. Locate the OIDC Audience row, and in the Value column, set the value to the client ID for Wildfly-based Keycloak.

  7. Locate the OIDC Issuer row, and in the Value column, set the value to https://keycloak.example.com/auth/realms/Foreman_Realm.

  8. Locate the OIDC JWKs URL row, and in the Value column, set the value to https://keycloak.example.com/auth/realms/Foreman_Realm/protocol/openid-connect/certs.

  9. In the Foreman web UI, navigate to Administer > Authentication Sources, click the vertical ellipsis on the External card, and select Edit.

  10. Click the Locations tab and add locations that can use the Wildfly-based Keycloak authentication source.

  11. Click the Organizations tab and add organizations that can use the Wildfly-based Keycloak authentication source.

  12. Click Submit.

5.5.5. Configuring Foreman settings for Wildfly-based Keycloak authentication using the CLI

Use this procedure to configure Foreman settings for Wildfly-based Keycloak authentication using the Foreman CLI.

Note that you can navigate to the following URL within your realm to obtain values to configure Foreman settings: https://keycloak.example.com/auth/realms/Foreman_Realm/.well-known/openid-configuration

Prerequisites
  • Ensure that the Access Type setting in the Foreman client in the Wildfly-based Keycloak web UI is set to public.

Procedure
  1. On Foreman, set the login delegation to true so that users can authenticate using the Open IDC protocol:

    # hammer settings set --name authorize_login_delegation --value true
  2. Set the login delegation logout URL:

    # hammer settings set --name login_delegation_logout_url \
    --value https://foreman.example.com/users/extlogout
  3. Set the algorithm for encoding on Wildfly-based Keycloak, for example, RS256:

    # hammer settings set --name oidc_algorithm --value 'RS256'
  4. Open the keycloak.example.com/auth/realms/KEYCLOAK_REALM/.well-known/openid-configuration URL and note the values to populate the options in the following steps.

  5. Add the value for the Hammer client in the Open IDC audience:

    # hammer settings set --name oidc_audience \
    --value "['foreman.example.com-hammer-openidc']"
    Note

    If you register several Wildfly-based Keycloak clients to Foreman, ensure that you append all audiences in the array. For example:

    # hammer settings set --name oidc_audience \
    --value "['foreman.example.com-foreman-openidc', 'foreman.example.com-hammer-openidc']"
  6. Set the value for the Open IDC issuer:

    # hammer settings set --name oidc_issuer \
    --value "keycloak.example.com/auth/realms/KEYCLOAK_REALM"
  7. Set the value for Open IDC Java Web Token (JWT):

    # hammer settings set --name oidc_jwks_url \
    --value "{keycloak-example.com}/auth/realms/KEYCLOAK_REALM/protocol/openid-connect/certs"
  8. Retrieve the ID of the Wildfly-based Keycloak authentication source:

    # hammer auth-source external list
  9. Set the location and organization:

    # hammer auth-source external update --id Authentication Source ID \
    --location-ids Location ID --organization-ids Organization ID

5.5.6. Configuring Foreman with Keycloak for TOTP authentication

Use this procedure to configure Foreman to use Keycloak as an OpenID provider for external authentication with Time-based One-time Password (TOTP).

Procedure
  1. In the Keycloak web UI, navigate to the Foreman realm.

  2. Navigate to Authentication, and click the OTP Policy tab.

  3. Ensure that the Supported Applications field includes FreeOTP or Google Authenticator.

  4. Configure the OTP settings to suit your requirements.

  5. Optional: If you want to use TOTP authentication as a default authentication method for all users, click the Flows tab, and to the right of the OTP Form setting, select REQUIRED.

  6. Click the Required Actions tab.

  7. To the right of the Configure OTP row, select the Default Action checkbox.

5.5.7. Logging in to the Foreman web UI using Keycloak TOTP authentication

Use this procedure to log in to the Foreman web UI using Keycloak TOTP authentication.

Procedure
  1. Log in to Foreman, Foreman redirects you to the Keycloak login screen.

  2. Enter your username and password, and click Log In.

  3. The first attempt to log in, Keycloak requests you to configure your client by scanning the barcode and entering the pin displayed.

  4. After you configure your client and enter a valid PIN, Keycloak redirects you to Foreman and logs you in.

5.5.8. Logging in to the Foreman CLI using Keycloak

Use this procedure to authenticate to the Foreman CLI using the code grant type.

Procedure
  1. To authenticate to the Foreman CLI using the code grant type, enter the following command:

    # hammer auth login oauth \
    --two-factor \
    --oidc-token-endpoint 'https://keycloak.example.com/auth/realms/ssl-realm/protocol/openid-connect/token' \
    --oidc-authorization-endpoint 'https://keycloak.example.com/auth' \
    --oidc-client-id 'foreman.example.com-foreman-openidc' \
    --oidc-redirect-uri urn:ietf:wg:oauth:2.0:oob

    The command prompts you to enter a success code.

  2. To retrieve the success code, navigate to the URL that the command returns and provide the required information.

  3. Copy the success code that the web UI returns.

  4. In the command prompt of hammer auth login oauth, enter the success code to authenticate to the Foreman CLI.

5.5.9. Configuring group mapping for Keycloak authentication

Optionally, to implement the Role Based Access Control (RBAC), create a group in Foreman, assign a role to this group, and then map an Active Directory group to the Foreman group. As a result, anyone in the given group in Keycloak are logged in under the corresponding Foreman group. This example configures users of the Foreman-admin user group in the Active Directory to authenticate as users with administrator privileges on Foreman.

Procedure
  1. In the Foreman web UI, navigate to Administer > User Groups.

  2. Click Create User Group.

  3. In the Name field, enter a name for the user group. The name should not be the same as in the Active Directory.

  4. Do not add users and user groups to the right-hand columns. Click the Roles tab.

  5. Select the Administer checkbox.

  6. Click the External Groups tab.

  7. Click Add external user group.

  8. In the Name field, enter the name of the Active Directory group.

  9. From the list, select EXTERNAL.

5.6. Configuring Wildfly-based Keycloak authentication with PIV cards for Foreman

Use this section to configure Foreman to use Wildfly-based Keycloak as an OpenID provider for external authentication with PIV cards.

5.6.1. Prerequisites for configuring Foreman with Wildfly-based Keycloak authentication

Before configuring Foreman with Wildfly-based Keycloak external authentication, ensure that you meet the following requirements:

  • A working installation of Wildfly-based Keycloak server that uses HTTPS instead of HTTP.

  • A Wildfly-based Keycloak account with admin privileges.

  • A realm for Foreman user accounts created in Wildfly-based Keycloak.

  • If the certificates or the CA are self-signed, ensure that they are added to the end-user certificate trust store.

  • Users imported or added to Wildfly-based Keycloak.

    If you have an existing user database configured such as LDAP or Kerberos, you can import users from it by configuring user federation. For more information, see User Storage Federation in the Red Hat Single Sign-On Server Administration Guide.

    If you do not have an existing user database configured, you can manually create users in Wildfly-based Keycloak. For more information, see Creating New Users in the Red Hat Single Sign-On Server Administration Guide.

5.6.2. Registering Foreman as a client of Keycloak

Use this procedure to register Foreman to Keycloak as a client and configure Foreman to use Keycloak as an authentication source.

You can configure Foreman and Keycloak with two different authentication methods:

  1. Users authenticate to Foreman using the Foreman web UI.

  2. Users authenticate to Foreman using the Foreman CLI.

You must decide on how you want your users to authenticate in advance because both methods require different Foreman clients to be registered to Keycloak and configured. The steps to register and configure Foreman client in Keycloak are distinguished within the procedure.

You can also register two different Foreman clients to Keycloak if you want to use both authentication methods and configure both clients accordingly.

Procedure
  1. On Foreman server, install the following packages:

    # dnf install mod_auth_openidc keycloak-httpd-client-install python3-lxml
  2. Register Foreman to Keycloak as a client. Note that you the registration process for logging in using the web UI and the CLI are different. You can register two clients Foreman clients to Keycloak to be able to log in to Foreman from the web UI and the CLI.

    • If you want you users to authenticate to Foreman using the web UI, create a client as follows:

      # keycloak-httpd-client-install --app-name foreman-openidc \
      --keycloak-server-url "https://keycloak.example.com" \
      --keycloak-admin-username "admin" \
      --keycloak-realm "Foreman_Realm" \
      --keycloak-admin-realm master \
      --keycloak-auth-role root-admin \
      -t openidc -l /users/extlogin --force

      Enter the password for the administer account when prompted. This command creates a client for Foreman in Keycloak.

      Then, configure Foreman to use Keycloak as an authentication source:

      # foreman-installer --foreman-keycloak true \
      --foreman-keycloak-app-name "foreman-openidc" \
      --foreman-keycloak-realm "Foreman_Realm"
    • If you want your users to authenticate to Foreman using the CLI, create a client as follows:

      # keycloak-httpd-client-install --app-name hammer-openidc \
      --keycloak-server-url "https://keycloak.example.com" \
      --keycloak-admin-username "admin" \
      --keycloak-realm "Foreman_Realm" \
      --keycloak-admin-realm master \
      --keycloak-auth-role root-admin \
      -t openidc -l /users/extlogin --force

      Enter the password for the administer account when prompted. This command creates a client for Foreman in Keycloak.

  3. Restart the httpd service:

    # systemctl restart httpd

5.6.3. Configuring the Foreman client in Wildfly-based Keycloak

Use this procedure to configure the Foreman client in the Wildfly-based Keycloak web UI and create group and audience mappers for the Foreman client.

Procedure
  1. In the Wildfly-based Keycloak web UI, navigate to the created Foreman realm, then Clients and click the Foreman client.

  2. Configure access type:

    • If you want your users to authenticate to Foreman using the Foreman web UI, from the Access Type list, select confidential.

    • If you want your users to authenticate to Foreman using the CLI, from the Access Type list, select public.

  3. In the Valid redirect URI fields, add a valid redirect URI.

    • If you want your users to authenticate to Foreman using the Foreman web UI, in the blank field below the existing URI, enter a URI in the form https://foreman.example.com/users/extlogin. Note that you must add the string /users/extlogin after the Foreman FQDN.

      After completing this step, the Foreman client for logging in using the Foreman web UI must have the following Valid Redirect URIs:

      https://foreman.example.com/users/extlogin/redirect_uri
      https://foreman.example.com/users/extlogin
    • If you want your users to authenticate to Foreman using the CLI, in the blank field below the existing URI, enter urn:ietf:wg:oauth:2.0:oob.

      After completing this step, the Foreman client for logging in using the CLI must have the following Valid Redirect URIs:

      https://foreman.example.com/users/extlogin/redirect_uri
      urn:ietf:wg:oauth:2.0:oob
  4. Click Save.

  5. Click the Mappers tab and click Create to add an audience mapper.

  6. In the Name field, enter a name for the audience mapper.

  7. From the Mapper Type list, select Audience.

  8. From the Included Client Audience list, select the Foreman client.

  9. Click Save.

  10. Click Create to add a group mapper so that you can specify authorization in Foreman based on group membership.

  11. In the Name field, enter a name for the group mapper.

  12. From the Mapper Type list, select Group Membership.

  13. In the Token Claim Name field, enter groups.

  14. Set the Full group path setting to OFF.

  15. Click Save.

5.6.4. Configuring Foreman settings for Wildfly-based Keycloak authentication using the web UI

Use this procedure to configure Foreman settings for Wildfly-based Keycloak authentication using the Foreman web UI.

Note that you can navigate to the following URL within your realm to obtain values to configure Foreman settings: https://keycloak.example.com/auth/realms/Foreman_Realm/.well-known/openid-configuration

Prerequisites
  • Ensure that the Access Type setting in the Foreman client in the Wildfly-based Keycloak web UI is set to confidential.

Procedure
  1. In the Foreman web UI, navigate to Administer > Settings, and click the Authentication tab.

  2. Locate the Authorize login delegation row, and in the Value column, set the value to Yes.

  3. Locate the Authorize login delegation auth source user autocreate row, and in the Value column, set the value to External.

  4. Locate the Login delegation logout URL row, and in the Value column, set the value to https://foreman.example.com/users/extlogout.

  5. Locate the OIDC Algorithm row, and in the Value column, set the algorithm for encoding on Wildfly-based Keycloak to RS256.

  6. Locate the OIDC Audience row, and in the Value column, set the value to the client ID for Wildfly-based Keycloak.

  7. Locate the OIDC Issuer row, and in the Value column, set the value to https://keycloak.example.com/auth/realms/Foreman_Realm.

  8. Locate the OIDC JWKs URL row, and in the Value column, set the value to https://keycloak.example.com/auth/realms/Foreman_Realm/protocol/openid-connect/certs.

  9. In the Foreman web UI, navigate to Administer > Authentication Sources, click the vertical ellipsis on the External card, and select Edit.

  10. Click the Locations tab and add locations that can use the Wildfly-based Keycloak authentication source.

  11. Click the Organizations tab and add organizations that can use the Wildfly-based Keycloak authentication source.

  12. Click Submit.

5.6.5. Configuring Foreman settings for Wildfly-based Keycloak authentication using the CLI

Use this procedure to configure Foreman settings for Wildfly-based Keycloak authentication using the Foreman CLI.

Note that you can navigate to the following URL within your realm to obtain values to configure Foreman settings: https://keycloak.example.com/auth/realms/Foreman_Realm/.well-known/openid-configuration

Prerequisites
  • Ensure that the Access Type setting in the Foreman client in the Wildfly-based Keycloak web UI is set to public.

Procedure
  1. On Foreman, set the login delegation to true so that users can authenticate using the Open IDC protocol:

    # hammer settings set --name authorize_login_delegation --value true
  2. Set the login delegation logout URL:

    # hammer settings set --name login_delegation_logout_url \
    --value https://foreman.example.com/users/extlogout
  3. Set the algorithm for encoding on Wildfly-based Keycloak, for example, RS256:

    # hammer settings set --name oidc_algorithm --value 'RS256'
  4. Open the keycloak.example.com/auth/realms/KEYCLOAK_REALM/.well-known/openid-configuration URL and note the values to populate the options in the following steps.

  5. Add the value for the Hammer client in the Open IDC audience:

    # hammer settings set --name oidc_audience \
    --value "['foreman.example.com-hammer-openidc']"
    Note

    If you register several Wildfly-based Keycloak clients to Foreman, ensure that you append all audiences in the array. For example:

    # hammer settings set --name oidc_audience \
    --value "['foreman.example.com-foreman-openidc', 'foreman.example.com-hammer-openidc']"
  6. Set the value for the Open IDC issuer:

    # hammer settings set --name oidc_issuer \
    --value "keycloak.example.com/auth/realms/KEYCLOAK_REALM"
  7. Set the value for Open IDC Java Web Token (JWT):

    # hammer settings set --name oidc_jwks_url \
    --value "{keycloak-example.com}/auth/realms/KEYCLOAK_REALM/protocol/openid-connect/certs"
  8. Retrieve the ID of the Wildfly-based Keycloak authentication source:

    # hammer auth-source external list
  9. Set the location and organization:

    # hammer auth-source external update --id Authentication Source ID \
    --location-ids Location ID --organization-ids Organization ID

5.6.6. Configuring Keycloak settings for authentication with PIV cards

You must configure Keycloak settings for authentication with PIV cards.

Procedure
  1. In the Keycloak web UI, navigate to the Authentication tab.

  2. From the Flows list, select Browser.

  3. Click Copy to copy this flow.

  4. In the Copy Authentication Flow window, enter a new name for the flow and click OK.

  5. In the copied flow, delete Username Password Form and OTP Form entries.

  6. Click Add execution.

  7. From the Provider list, select X509/Validate Username Form.

  8. Click Save.

  9. In the X509/Validate Username Form raw, select ALTERNATIVE.

  10. In the X509/Validate Username Form raw, click Actions > Config.

  11. In the Alias field, enter a name for this configuration.

  12. From the User Identity Source list, select Subject’s Common Name,

  13. From the User mapping method list, select Username or Email.

  14. Click Save.

  15. Navigate to Authentication > Bindings.

  16. From the Browser Flow list, select the created flow.

5.6.7. Configuring users' OS for Keycloak authentication with PIV cards

Complete this procedure on each system from which you want to be able to log in to Foreman using Keycloak PIV cards.

Procedure
  1. Install the required package:

    # dnf install opensc
  2. Install the Firefox browser if not installed.

  3. Launch Firefox and navigate to Preferences.

  4. Click the Privacy and Security tab.

  5. Click Security Devices.

  6. Click Load.

  7. In the Load PKCS#11 Device Driver window, in the Module Name field, enter a name for this device.

  8. In the Module filename field, enter /usr/lib64/pkcs11/opensc-pkcs11.so.

  9. Click OK.

  10. If the PIV card is connected to system, restart the pcscd service.

5.6.8. Logging in to the Foreman web UI using Wildfly-based Keycloak PIV cards

Use this procedure to log in to the Foreman web UI using the Wildfly-based Keycloak PIV cards.

Procedure
  1. In Firefox, log in to Foreman and enter your credentials.

  2. When prompted, enter the PIN of the PIV card.

  3. Choose the certificate for authentication. Browser verifies this certificate with Wildfly-based Keycloak. Once authenticated, browser redirects you back to Foreman and logs you in.

5.6.9. Logging in to the Foreman CLI using Keycloak

Use this procedure to authenticate to the Foreman CLI using the code grant type.

Procedure
  1. To authenticate to the Foreman CLI using the code grant type, enter the following command:

    # hammer auth login oauth \
    --two-factor \
    --oidc-token-endpoint 'https://keycloak.example.com/auth/realms/ssl-realm/protocol/openid-connect/token' \
    --oidc-authorization-endpoint 'https://keycloak.example.com/auth' \
    --oidc-client-id 'foreman.example.com-foreman-openidc' \
    --oidc-redirect-uri urn:ietf:wg:oauth:2.0:oob

    The command prompts you to enter a success code.

  2. To retrieve the success code, navigate to the URL that the command returns and provide the required information.

  3. Copy the success code that the web UI returns.

  4. In the command prompt of hammer auth login oauth, enter the success code to authenticate to the Foreman CLI.

5.6.10. Configuring group mapping for Keycloak authentication

Optionally, to implement the Role Based Access Control (RBAC), create a group in Foreman, assign a role to this group, and then map an Active Directory group to the Foreman group. As a result, anyone in the given group in Keycloak are logged in under the corresponding Foreman group. This example configures users of the Foreman-admin user group in the Active Directory to authenticate as users with administrator privileges on Foreman.

Procedure
  1. In the Foreman web UI, navigate to Administer > User Groups.

  2. Click Create User Group.

  3. In the Name field, enter a name for the user group. The name should not be the same as in the Active Directory.

  4. Do not add users and user groups to the right-hand columns. Click the Roles tab.

  5. Select the Administer checkbox.

  6. Click the External Groups tab.

  7. Click Add external user group.

  8. In the Name field, enter the name of the Active Directory group.

  9. From the list, select EXTERNAL.

5.7. Configuring Quarkus-based Keycloak authentication for Foreman

Use this section to configure Foreman to use Quarkus-based Keycloak as an OpenID provider for external authentication.

5.7.1. Prerequisites for configuring Foreman with Quarkus-based Keycloak authentication

Before configuring Foreman with Quarkus-based Keycloak external authentication, ensure that you meet the following requirements:

  • A working installation of Quarkus-based Keycloak server that uses HTTPS instead of HTTP.

  • Configuring Quarkus-based Quarkus-based Keycloak authentication requires the --http-relative-path=/auth context path to be configured in your Quarkus-based Keycloak system setup. If you want to use a different context path, make manual adjustments after the initialisation with /auth or fully set up the foreman-openidc_oidc_keycloak_Foreman_Realm.conf file of the httpd service manually.

    For more information, see Different context-path on reverse proxy in the Quarkus-based Keycloak Administration Guide.

  • A Quarkus-based Keycloak account with admin privileges.

  • A realm for Foreman user accounts created in Quarkus-based Keycloak.

  • If the certificates or the CA are self-signed, ensure that they are added to the end-user certificate trust store.

  • Users imported or added to Quarkus-based Keycloak.

    If you have an existing user database configured such as LDAP or Kerberos, you can import users from it by configuring user federation. For more information, see User Storage Federation in the Quarkus-based Keycloak Administration Guide.

    If you do not have an existing user database configured, you can manually create users in Quarkus-based Keycloak. For more information, see Creating New Users in the Quarkus-based Keycloak Administration Guide.

5.7.2. Registering Foreman as a client of Keycloak

Use this procedure to register Foreman to Keycloak as a client and configure Foreman to use Keycloak as an authentication source.

You can configure Foreman and Keycloak with two different authentication methods:

  1. Users authenticate to Foreman using the Foreman web UI.

  2. Users authenticate to Foreman using the Foreman CLI.

You must decide on how you want your users to authenticate in advance because both methods require different Foreman clients to be registered to Keycloak and configured. The steps to register and configure Foreman client in Keycloak are distinguished within the procedure.

You can also register two different Foreman clients to Keycloak if you want to use both authentication methods and configure both clients accordingly.

Procedure
  1. On Foreman server, install the following packages:

    # dnf install mod_auth_openidc keycloak-httpd-client-install python3-lxml
  2. Register Foreman to Keycloak as a client. Note that you the registration process for logging in using the web UI and the CLI are different. You can register two clients Foreman clients to Keycloak to be able to log in to Foreman from the web UI and the CLI.

    • If you want you users to authenticate to Foreman using the web UI, create a client as follows:

      # keycloak-httpd-client-install --app-name foreman-openidc \
      --keycloak-server-url "https://keycloak.example.com" \
      --keycloak-admin-username "admin" \
      --keycloak-realm "Foreman_Realm" \
      --keycloak-admin-realm master \
      --keycloak-auth-role root-admin \
      -t openidc -l /users/extlogin --force

      Enter the password for the administer account when prompted. This command creates a client for Foreman in Keycloak.

      Then, configure Foreman to use Keycloak as an authentication source:

      # foreman-installer --foreman-keycloak true \
      --foreman-keycloak-app-name "foreman-openidc" \
      --foreman-keycloak-realm "Foreman_Realm"
    • If you want your users to authenticate to Foreman using the CLI, create a client as follows:

      # keycloak-httpd-client-install --app-name hammer-openidc \
      --keycloak-server-url "https://keycloak.example.com" \
      --keycloak-admin-username "admin" \
      --keycloak-realm "Foreman_Realm" \
      --keycloak-admin-realm master \
      --keycloak-auth-role root-admin \
      -t openidc -l /users/extlogin --force

      Enter the password for the administer account when prompted. This command creates a client for Foreman in Keycloak.

  3. Restart the httpd service:

    # systemctl restart httpd

5.7.3. Configuring the Foreman client in Quarkus-based Keycloak

Use this procedure to configure the Foreman client in the Quarkus-based Keycloak web UI and create group and audience mappers for the Foreman client.

Procedure
  1. In the Quarkus-based Keycloak web UI, navigate to the created Foreman realm, then Clients and click the Foreman client.

  2. Configure access type:

    • If you want your users to authenticate to Foreman using the Foreman web UI, set the Client authentication setting to ON.

    • If you want your users to authenticate to Foreman using the CLI, set the Client authentication setting to OFF.

  3. In the Valid redirect URI fields, add a valid redirect URI.

    • If you want your users to authenticate to Foreman using the Foreman web UI, in the blank field below the existing URI, enter a URI in the form https://foreman.example.com/users/extlogin. Note that you must add the string /users/extlogin after the Foreman FQDN.

      After completing this step, the Foreman client for logging in using the Foreman web UI must have the following Valid Redirect URIs:

      https://foreman.example.com/users/extlogin/redirect_uri
      https://foreman.example.com/users/extlogin
    • If you want your users to authenticate to Foreman using the CLI, in the blank field below the existing URI, enter urn:ietf:wg:oauth:2.0:oob.

      After completing this step, the Foreman client for logging in using the CLI must have the following Valid Redirect URIs:

      https://foreman.example.com/users/extlogin/redirect_uri
      urn:ietf:wg:oauth:2.0:oob
  4. Click Save.

  5. Click the Client Scopes tab and enter the scope called like the client ending with -dedicated.

  6. Click Add mapper, followed by By configuration (or if no mappers are configured Configure a new mapper) and select the Audience mapper.

  7. In the Name field, enter a name for the audience mapper.

  8. From the Included Client Audience list, select the Foreman client.

  9. Set the Add to ID token setting to ON.

  10. Click Save.

  11. Click Add mapper, followed by By configuration and select the Group Membership mapper to add a group mapper so that you can specify authorization in Foreman based on group membership.

  12. In the Name field, enter a name for the group mapper.

  13. In the Token Claim Name field, enter groups.

  14. Set the Full group path setting to OFF.

  15. Click Save.

5.7.4. Configuring Foreman settings for Quarkus-based Keycloak authentication using the web UI

Use this procedure to configure Foreman settings for Quarkus-based Keycloak authentication using the Foreman web UI.

Note that you can navigate to the following URL within your realm to obtain values to configure Foreman settings: https://keycloak.example.com/auth/realms/Foreman_Realm/.well-known/openid-configuration

Prerequisites
  • Ensure that the Client authentication setting in the Foreman client in the Quarkus-based Keycloak web UI is set to ON.

Procedure
  1. In the Foreman web UI, navigate to Administer > Settings, and click the Authentication tab.

  2. Locate the Authorize login delegation row, and in the Value column, set the value to Yes.

  3. Locate the Authorize login delegation auth source user autocreate row, and in the Value column, set the value to External.

  4. Locate the Login delegation logout URL row, and in the Value column, set the value to https://foreman.example.com/users/extlogout.

  5. Locate the OIDC Algorithm row, and in the Value column, set the algorithm for encoding on Quarkus-based Keycloak to RS256.

  6. Locate the OIDC Audience row, and in the Value column, set the value to the client ID for Quarkus-based Keycloak.

  7. Locate the OIDC Issuer row, and in the Value column, set the value to https://keycloak.example.com/auth/realms/Foreman_Realm.

  8. Locate the OIDC JWKs URL row, and in the Value column, set the value to https://keycloak.example.com/auth/realms/Foreman_Realm/protocol/openid-connect/certs.

  9. In the Foreman web UI, navigate to Administer > Authentication Sources, click the vertical ellipsis on the External card, and select Edit.

  10. Click the Locations tab and add locations that can use the Quarkus-based Keycloak authentication source.

  11. Click the Organizations tab and add organizations that can use the Quarkus-based Keycloak authentication source.

  12. Click Submit.

5.7.5. Configuring Foreman settings for Quarkus-based Keycloak authentication using the CLI

Use this procedure to configure Foreman settings for Quarkus-based Keycloak authentication using the Foreman CLI.

Note that you can navigate to the following URL within your realm to obtain values to configure Foreman settings: https://keycloak.example.com/auth/realms/Foreman_Realm/.well-known/openid-configuration

Prerequisites
  • Ensure that the Client authentication setting in the Foreman client in the Quarkus-based Keycloak web UI is set to OFF.

Procedure
  1. On Foreman, set the login delegation to true so that users can authenticate using the Open IDC protocol:

    # hammer settings set --name authorize_login_delegation --value true
  2. Set the login delegation logout URL:

    # hammer settings set --name login_delegation_logout_url \
    --value https://foreman.example.com/users/extlogout
  3. Set the algorithm for encoding on Quarkus-based Keycloak, for example, RS256:

    # hammer settings set --name oidc_algorithm --value 'RS256'
  4. Open the keycloak.example.com/auth/realms/KEYCLOAK_REALM/.well-known/openid-configuration URL and note the values to populate the options in the following steps.

  5. Add the value for the Hammer client in the Open IDC audience:

    # hammer settings set --name oidc_audience \
    --value "['foreman.example.com-hammer-openidc']"
    Note

    If you register several Quarkus-based Keycloak clients to Foreman, ensure that you append all audiences in the array. For example:

    # hammer settings set --name oidc_audience \
    --value "['foreman.example.com-foreman-openidc', 'foreman.example.com-hammer-openidc']"
  6. Set the value for the Open IDC issuer:

    # hammer settings set --name oidc_issuer \
    --value "keycloak.example.com/auth/realms/KEYCLOAK_REALM"
  7. Set the value for Open IDC Java Web Token (JWT):

    # hammer settings set --name oidc_jwks_url \
    --value "keycloak.example.com/auth/realms/KEYCLOAK_REALM/protocol/openid-connect/certs"
  8. Retrieve the ID of the Quarkus-based Keycloak authentication source:

    # hammer auth-source external list
  9. Set the location and organization:

    # hammer auth-source external update --id Authentication Source ID \
    --location-ids Location ID --organization-ids Organization ID

5.7.6. Logging in to the Foreman web UI using Keycloak

Use this procedure to log in to the Foreman web UI using Keycloak.

Procedure
  • In your browser, log in to Foreman and enter your credentials.

5.7.7. Logging in to the Foreman CLI using Keycloak

Use this procedure to authenticate to the Foreman CLI using the code grant type.

Procedure
  1. To authenticate to the Foreman CLI using the code grant type, enter the following command:

    # hammer auth login oauth \
    --two-factor \
    --oidc-token-endpoint 'https://keycloak.example.com/auth/realms/ssl-realm/protocol/openid-connect/token' \
    --oidc-authorization-endpoint 'https://keycloak.example.com/auth' \
    --oidc-client-id 'foreman.example.com-foreman-openidc' \
    --oidc-redirect-uri urn:ietf:wg:oauth:2.0:oob

    The command prompts you to enter a success code.

  2. To retrieve the success code, navigate to the URL that the command returns and provide the required information.

  3. Copy the success code that the web UI returns.

  4. In the command prompt of hammer auth login oauth, enter the success code to authenticate to the Foreman CLI.

5.7.8. Configuring group mapping for Keycloak authentication

Optionally, to implement the Role Based Access Control (RBAC), create a group in Foreman, assign a role to this group, and then map an Active Directory group to the Foreman group. As a result, anyone in the given group in Keycloak are logged in under the corresponding Foreman group. This example configures users of the Foreman-admin user group in the Active Directory to authenticate as users with administrator privileges on Foreman.

Procedure
  1. In the Foreman web UI, navigate to Administer > User Groups.

  2. Click Create User Group.

  3. In the Name field, enter a name for the user group. The name should not be the same as in the Active Directory.

  4. Do not add users and user groups to the right-hand columns. Click the Roles tab.

  5. Select the Administer checkbox.

  6. Click the External Groups tab.

  7. Click Add external user group.

  8. In the Name field, enter the name of the Active Directory group.

  9. From the list, select EXTERNAL.

5.8. Configuring Quarkus-based Keycloak authentication with TOTP cards for Foreman

Use this section to configure Foreman to use Quarkus-based Keycloak as an OpenID provider for external authentication with TOTP cards.

5.8.1. Prerequisites for configuring Foreman with Quarkus-based Keycloak authentication

Before configuring Foreman with Quarkus-based Keycloak external authentication, ensure that you meet the following requirements:

  • A working installation of Quarkus-based Keycloak server that uses HTTPS instead of HTTP.

  • Configuring Quarkus-based Quarkus-based Keycloak authentication requires the --http-relative-path=/auth context path to be configured in your Quarkus-based Keycloak system setup. If you want to use a different context path, make manual adjustments after the initialisation with /auth or fully set up the foreman-openidc_oidc_keycloak_Foreman_Realm.conf file of the httpd service manually.

    For more information, see Different context-path on reverse proxy in the Quarkus-based Keycloak Administration Guide.

  • A Quarkus-based Keycloak account with admin privileges.

  • A realm for Foreman user accounts created in Quarkus-based Keycloak.

  • If the certificates or the CA are self-signed, ensure that they are added to the end-user certificate trust store.

  • Users imported or added to Quarkus-based Keycloak.

    If you have an existing user database configured such as LDAP or Kerberos, you can import users from it by configuring user federation. For more information, see User Storage Federation in the Quarkus-based Keycloak Administration Guide.

    If you do not have an existing user database configured, you can manually create users in Quarkus-based Keycloak. For more information, see Creating New Users in the Quarkus-based Keycloak Administration Guide.

5.8.2. Registering Foreman as a client of Keycloak

Use this procedure to register Foreman to Keycloak as a client and configure Foreman to use Keycloak as an authentication source.

You can configure Foreman and Keycloak with two different authentication methods:

  1. Users authenticate to Foreman using the Foreman web UI.

  2. Users authenticate to Foreman using the Foreman CLI.

You must decide on how you want your users to authenticate in advance because both methods require different Foreman clients to be registered to Keycloak and configured. The steps to register and configure Foreman client in Keycloak are distinguished within the procedure.

You can also register two different Foreman clients to Keycloak if you want to use both authentication methods and configure both clients accordingly.

Procedure
  1. On Foreman server, install the following packages:

    # dnf install mod_auth_openidc keycloak-httpd-client-install python3-lxml
  2. Register Foreman to Keycloak as a client. Note that you the registration process for logging in using the web UI and the CLI are different. You can register two clients Foreman clients to Keycloak to be able to log in to Foreman from the web UI and the CLI.

    • If you want you users to authenticate to Foreman using the web UI, create a client as follows:

      # keycloak-httpd-client-install --app-name foreman-openidc \
      --keycloak-server-url "https://keycloak.example.com" \
      --keycloak-admin-username "admin" \
      --keycloak-realm "Foreman_Realm" \
      --keycloak-admin-realm master \
      --keycloak-auth-role root-admin \
      -t openidc -l /users/extlogin --force

      Enter the password for the administer account when prompted. This command creates a client for Foreman in Keycloak.

      Then, configure Foreman to use Keycloak as an authentication source:

      # foreman-installer --foreman-keycloak true \
      --foreman-keycloak-app-name "foreman-openidc" \
      --foreman-keycloak-realm "Foreman_Realm"
    • If you want your users to authenticate to Foreman using the CLI, create a client as follows:

      # keycloak-httpd-client-install --app-name hammer-openidc \
      --keycloak-server-url "https://keycloak.example.com" \
      --keycloak-admin-username "admin" \
      --keycloak-realm "Foreman_Realm" \
      --keycloak-admin-realm master \
      --keycloak-auth-role root-admin \
      -t openidc -l /users/extlogin --force

      Enter the password for the administer account when prompted. This command creates a client for Foreman in Keycloak.

  3. Restart the httpd service:

    # systemctl restart httpd

5.8.3. Configuring the Foreman client in Quarkus-based Keycloak

Use this procedure to configure the Foreman client in the Quarkus-based Keycloak web UI and create group and audience mappers for the Foreman client.

Procedure
  1. In the Quarkus-based Keycloak web UI, navigate to the created Foreman realm, then Clients and click the Foreman client.

  2. Configure access type:

    • If you want your users to authenticate to Foreman using the Foreman web UI, set the Client authentication setting to ON.

    • If you want your users to authenticate to Foreman using the CLI, set the Client authentication setting to OFF.

  3. In the Valid redirect URI fields, add a valid redirect URI.

    • If you want your users to authenticate to Foreman using the Foreman web UI, in the blank field below the existing URI, enter a URI in the form https://foreman.example.com/users/extlogin. Note that you must add the string /users/extlogin after the Foreman FQDN.

      After completing this step, the Foreman client for logging in using the Foreman web UI must have the following Valid Redirect URIs:

      https://foreman.example.com/users/extlogin/redirect_uri
      https://foreman.example.com/users/extlogin
    • If you want your users to authenticate to Foreman using the CLI, in the blank field below the existing URI, enter urn:ietf:wg:oauth:2.0:oob.

      After completing this step, the Foreman client for logging in using the CLI must have the following Valid Redirect URIs:

      https://foreman.example.com/users/extlogin/redirect_uri
      urn:ietf:wg:oauth:2.0:oob
  4. Click Save.

  5. Click the Client Scopes tab and enter the scope called like the client ending with -dedicated.

  6. Click Add mapper, followed by By configuration (or if no mappers are configured Configure a new mapper) and select the Audience mapper.

  7. In the Name field, enter a name for the audience mapper.

  8. From the Included Client Audience list, select the Foreman client.

  9. Set the Add to ID token setting to ON.

  10. Click Save.

  11. Click Add mapper, followed by By configuration and select the Group Membership mapper to add a group mapper so that you can specify authorization in Foreman based on group membership.

  12. In the Name field, enter a name for the group mapper.

  13. In the Token Claim Name field, enter groups.

  14. Set the Full group path setting to OFF.

  15. Click Save.

5.8.4. Configuring Foreman settings for Quarkus-based Keycloak authentication using the web UI

Use this procedure to configure Foreman settings for Quarkus-based Keycloak authentication using the Foreman web UI.

Note that you can navigate to the following URL within your realm to obtain values to configure Foreman settings: https://keycloak.example.com/auth/realms/Foreman_Realm/.well-known/openid-configuration

Prerequisites
  • Ensure that the Client authentication setting in the Foreman client in the Quarkus-based Keycloak web UI is set to ON.

Procedure
  1. In the Foreman web UI, navigate to Administer > Settings, and click the Authentication tab.

  2. Locate the Authorize login delegation row, and in the Value column, set the value to Yes.

  3. Locate the Authorize login delegation auth source user autocreate row, and in the Value column, set the value to External.

  4. Locate the Login delegation logout URL row, and in the Value column, set the value to https://foreman.example.com/users/extlogout.

  5. Locate the OIDC Algorithm row, and in the Value column, set the algorithm for encoding on Quarkus-based Keycloak to RS256.

  6. Locate the OIDC Audience row, and in the Value column, set the value to the client ID for Quarkus-based Keycloak.

  7. Locate the OIDC Issuer row, and in the Value column, set the value to https://keycloak.example.com/auth/realms/Foreman_Realm.

  8. Locate the OIDC JWKs URL row, and in the Value column, set the value to https://keycloak.example.com/auth/realms/Foreman_Realm/protocol/openid-connect/certs.

  9. In the Foreman web UI, navigate to Administer > Authentication Sources, click the vertical ellipsis on the External card, and select Edit.

  10. Click the Locations tab and add locations that can use the Quarkus-based Keycloak authentication source.

  11. Click the Organizations tab and add organizations that can use the Quarkus-based Keycloak authentication source.

  12. Click Submit.

5.8.5. Configuring Foreman settings for Quarkus-based Keycloak authentication using the CLI

Use this procedure to configure Foreman settings for Quarkus-based Keycloak authentication using the Foreman CLI.

Note that you can navigate to the following URL within your realm to obtain values to configure Foreman settings: https://keycloak.example.com/auth/realms/Foreman_Realm/.well-known/openid-configuration

Prerequisites
  • Ensure that the Client authentication setting in the Foreman client in the Quarkus-based Keycloak web UI is set to OFF.

Procedure
  1. On Foreman, set the login delegation to true so that users can authenticate using the Open IDC protocol:

    # hammer settings set --name authorize_login_delegation --value true
  2. Set the login delegation logout URL:

    # hammer settings set --name login_delegation_logout_url \
    --value https://foreman.example.com/users/extlogout
  3. Set the algorithm for encoding on Quarkus-based Keycloak, for example, RS256:

    # hammer settings set --name oidc_algorithm --value 'RS256'
  4. Open the keycloak.example.com/auth/realms/KEYCLOAK_REALM/.well-known/openid-configuration URL and note the values to populate the options in the following steps.

  5. Add the value for the Hammer client in the Open IDC audience:

    # hammer settings set --name oidc_audience \
    --value "['foreman.example.com-hammer-openidc']"
    Note

    If you register several Quarkus-based Keycloak clients to Foreman, ensure that you append all audiences in the array. For example:

    # hammer settings set --name oidc_audience \
    --value "['foreman.example.com-foreman-openidc', 'foreman.example.com-hammer-openidc']"
  6. Set the value for the Open IDC issuer:

    # hammer settings set --name oidc_issuer \
    --value "keycloak.example.com/auth/realms/KEYCLOAK_REALM"
  7. Set the value for Open IDC Java Web Token (JWT):

    # hammer settings set --name oidc_jwks_url \
    --value "keycloak.example.com/auth/realms/KEYCLOAK_REALM/protocol/openid-connect/certs"
  8. Retrieve the ID of the Quarkus-based Keycloak authentication source:

    # hammer auth-source external list
  9. Set the location and organization:

    # hammer auth-source external update --id Authentication Source ID \
    --location-ids Location ID --organization-ids Organization ID

5.8.6. Configuring Foreman with Keycloak for TOTP authentication

Use this procedure to configure Foreman to use Keycloak as an OpenID provider for external authentication with Time-based One-time Password (TOTP).

Procedure
  1. In the Keycloak web UI, navigate to the Foreman realm.

  2. Navigate to Authentication, and click the OTP Policy tab.

  3. Ensure that the Supported Applications field includes FreeOTP or Google Authenticator.

  4. Configure the OTP settings to suit your requirements.

  5. Optional: If you want to use TOTP authentication as a default authentication method for all users, click the Flows tab, and to the right of the OTP Form setting, select REQUIRED.

  6. Click the Required Actions tab.

  7. To the right of the Configure OTP row, select the Default Action checkbox.

5.8.7. Logging in to the Foreman web UI using Keycloak TOTP authentication

Use this procedure to log in to the Foreman web UI using Keycloak TOTP authentication.

Procedure
  1. Log in to Foreman, Foreman redirects you to the Keycloak login screen.

  2. Enter your username and password, and click Log In.

  3. The first attempt to log in, Keycloak requests you to configure your client by scanning the barcode and entering the pin displayed.

  4. After you configure your client and enter a valid PIN, Keycloak redirects you to Foreman and logs you in.

5.8.8. Logging in to the Foreman CLI using Keycloak

Use this procedure to authenticate to the Foreman CLI using the code grant type.

Procedure
  1. To authenticate to the Foreman CLI using the code grant type, enter the following command:

    # hammer auth login oauth \
    --two-factor \
    --oidc-token-endpoint 'https://keycloak.example.com/auth/realms/ssl-realm/protocol/openid-connect/token' \
    --oidc-authorization-endpoint 'https://keycloak.example.com/auth' \
    --oidc-client-id 'foreman.example.com-foreman-openidc' \
    --oidc-redirect-uri urn:ietf:wg:oauth:2.0:oob

    The command prompts you to enter a success code.

  2. To retrieve the success code, navigate to the URL that the command returns and provide the required information.

  3. Copy the success code that the web UI returns.

  4. In the command prompt of hammer auth login oauth, enter the success code to authenticate to the Foreman CLI.

5.8.9. Configuring group mapping for Keycloak authentication

Optionally, to implement the Role Based Access Control (RBAC), create a group in Foreman, assign a role to this group, and then map an Active Directory group to the Foreman group. As a result, anyone in the given group in Keycloak are logged in under the corresponding Foreman group. This example configures users of the Foreman-admin user group in the Active Directory to authenticate as users with administrator privileges on Foreman.

Procedure
  1. In the Foreman web UI, navigate to Administer > User Groups.

  2. Click Create User Group.

  3. In the Name field, enter a name for the user group. The name should not be the same as in the Active Directory.

  4. Do not add users and user groups to the right-hand columns. Click the Roles tab.

  5. Select the Administer checkbox.

  6. Click the External Groups tab.

  7. Click Add external user group.

  8. In the Name field, enter the name of the Active Directory group.

  9. From the list, select EXTERNAL.

5.9. Configuring Quarkus-based Keycloak authentication with PIV cards for Foreman

Use this section to configure Foreman to use Quarkus-based Keycloak as an OpenID provider for external authentication with PIV cards.

5.9.1. Prerequisites for configuring Foreman with Quarkus-based Keycloak authentication

Before configuring Foreman with Quarkus-based Keycloak external authentication, ensure that you meet the following requirements:

  • A working installation of Quarkus-based Keycloak server that uses HTTPS instead of HTTP.

  • Configuring Quarkus-based Quarkus-based Keycloak authentication requires the --http-relative-path=/auth context path to be configured in your Quarkus-based Keycloak system setup. If you want to use a different context path, make manual adjustments after the initialisation with /auth or fully set up the foreman-openidc_oidc_keycloak_Foreman_Realm.conf file of the httpd service manually.

    For more information, see Different context-path on reverse proxy in the Quarkus-based Keycloak Administration Guide.

  • A Quarkus-based Keycloak account with admin privileges.

  • A realm for Foreman user accounts created in Quarkus-based Keycloak.

  • If the certificates or the CA are self-signed, ensure that they are added to the end-user certificate trust store.

  • Users imported or added to Quarkus-based Keycloak.

    If you have an existing user database configured such as LDAP or Kerberos, you can import users from it by configuring user federation. For more information, see User Storage Federation in the Quarkus-based Keycloak Administration Guide.

    If you do not have an existing user database configured, you can manually create users in Quarkus-based Keycloak. For more information, see Creating New Users in the Quarkus-based Keycloak Administration Guide.

5.9.2. Registering Foreman as a client of Keycloak

Use this procedure to register Foreman to Keycloak as a client and configure Foreman to use Keycloak as an authentication source.

You can configure Foreman and Keycloak with two different authentication methods:

  1. Users authenticate to Foreman using the Foreman web UI.

  2. Users authenticate to Foreman using the Foreman CLI.

You must decide on how you want your users to authenticate in advance because both methods require different Foreman clients to be registered to Keycloak and configured. The steps to register and configure Foreman client in Keycloak are distinguished within the procedure.

You can also register two different Foreman clients to Keycloak if you want to use both authentication methods and configure both clients accordingly.

Procedure
  1. On Foreman server, install the following packages:

    # dnf install mod_auth_openidc keycloak-httpd-client-install python3-lxml
  2. Register Foreman to Keycloak as a client. Note that you the registration process for logging in using the web UI and the CLI are different. You can register two clients Foreman clients to Keycloak to be able to log in to Foreman from the web UI and the CLI.

    • If you want you users to authenticate to Foreman using the web UI, create a client as follows:

      # keycloak-httpd-client-install --app-name foreman-openidc \
      --keycloak-server-url "https://keycloak.example.com" \
      --keycloak-admin-username "admin" \
      --keycloak-realm "Foreman_Realm" \
      --keycloak-admin-realm master \
      --keycloak-auth-role root-admin \
      -t openidc -l /users/extlogin --force

      Enter the password for the administer account when prompted. This command creates a client for Foreman in Keycloak.

      Then, configure Foreman to use Keycloak as an authentication source:

      # foreman-installer --foreman-keycloak true \
      --foreman-keycloak-app-name "foreman-openidc" \
      --foreman-keycloak-realm "Foreman_Realm"
    • If you want your users to authenticate to Foreman using the CLI, create a client as follows:

      # keycloak-httpd-client-install --app-name hammer-openidc \
      --keycloak-server-url "https://keycloak.example.com" \
      --keycloak-admin-username "admin" \
      --keycloak-realm "Foreman_Realm" \
      --keycloak-admin-realm master \
      --keycloak-auth-role root-admin \
      -t openidc -l /users/extlogin --force

      Enter the password for the administer account when prompted. This command creates a client for Foreman in Keycloak.

  3. Restart the httpd service:

    # systemctl restart httpd

5.9.3. Configuring the Foreman client in Quarkus-based Keycloak

Use this procedure to configure the Foreman client in the Quarkus-based Keycloak web UI and create group and audience mappers for the Foreman client.

Procedure
  1. In the Quarkus-based Keycloak web UI, navigate to the created Foreman realm, then Clients and click the Foreman client.

  2. Configure access type:

    • If you want your users to authenticate to Foreman using the Foreman web UI, set the Client authentication setting to ON.

    • If you want your users to authenticate to Foreman using the CLI, set the Client authentication setting to OFF.

  3. In the Valid redirect URI fields, add a valid redirect URI.

    • If you want your users to authenticate to Foreman using the Foreman web UI, in the blank field below the existing URI, enter a URI in the form https://foreman.example.com/users/extlogin. Note that you must add the string /users/extlogin after the Foreman FQDN.

      After completing this step, the Foreman client for logging in using the Foreman web UI must have the following Valid Redirect URIs:

      https://foreman.example.com/users/extlogin/redirect_uri
      https://foreman.example.com/users/extlogin
    • If you want your users to authenticate to Foreman using the CLI, in the blank field below the existing URI, enter urn:ietf:wg:oauth:2.0:oob.

      After completing this step, the Foreman client for logging in using the CLI must have the following Valid Redirect URIs:

      https://foreman.example.com/users/extlogin/redirect_uri
      urn:ietf:wg:oauth:2.0:oob
  4. Click Save.

  5. Click the Client Scopes tab and enter the scope called like the client ending with -dedicated.

  6. Click Add mapper, followed by By configuration (or if no mappers are configured Configure a new mapper) and select the Audience mapper.

  7. In the Name field, enter a name for the audience mapper.

  8. From the Included Client Audience list, select the Foreman client.

  9. Set the Add to ID token setting to ON.

  10. Click Save.

  11. Click Add mapper, followed by By configuration and select the Group Membership mapper to add a group mapper so that you can specify authorization in Foreman based on group membership.

  12. In the Name field, enter a name for the group mapper.

  13. In the Token Claim Name field, enter groups.

  14. Set the Full group path setting to OFF.

  15. Click Save.

5.9.4. Configuring Foreman settings for Quarkus-based Keycloak authentication using the web UI

Use this procedure to configure Foreman settings for Quarkus-based Keycloak authentication using the Foreman web UI.

Note that you can navigate to the following URL within your realm to obtain values to configure Foreman settings: https://keycloak.example.com/auth/realms/Foreman_Realm/.well-known/openid-configuration

Prerequisites
  • Ensure that the Client authentication setting in the Foreman client in the Quarkus-based Keycloak web UI is set to ON.

Procedure
  1. In the Foreman web UI, navigate to Administer > Settings, and click the Authentication tab.

  2. Locate the Authorize login delegation row, and in the Value column, set the value to Yes.

  3. Locate the Authorize login delegation auth source user autocreate row, and in the Value column, set the value to External.

  4. Locate the Login delegation logout URL row, and in the Value column, set the value to https://foreman.example.com/users/extlogout.

  5. Locate the OIDC Algorithm row, and in the Value column, set the algorithm for encoding on Quarkus-based Keycloak to RS256.

  6. Locate the OIDC Audience row, and in the Value column, set the value to the client ID for Quarkus-based Keycloak.

  7. Locate the OIDC Issuer row, and in the Value column, set the value to https://keycloak.example.com/auth/realms/Foreman_Realm.

  8. Locate the OIDC JWKs URL row, and in the Value column, set the value to https://keycloak.example.com/auth/realms/Foreman_Realm/protocol/openid-connect/certs.

  9. In the Foreman web UI, navigate to Administer > Authentication Sources, click the vertical ellipsis on the External card, and select Edit.

  10. Click the Locations tab and add locations that can use the Quarkus-based Keycloak authentication source.

  11. Click the Organizations tab and add organizations that can use the Quarkus-based Keycloak authentication source.

  12. Click Submit.

5.9.5. Configuring Foreman settings for Quarkus-based Keycloak authentication using the CLI

Use this procedure to configure Foreman settings for Quarkus-based Keycloak authentication using the Foreman CLI.

Note that you can navigate to the following URL within your realm to obtain values to configure Foreman settings: https://keycloak.example.com/auth/realms/Foreman_Realm/.well-known/openid-configuration

Prerequisites
  • Ensure that the Client authentication setting in the Foreman client in the Quarkus-based Keycloak web UI is set to OFF.

Procedure
  1. On Foreman, set the login delegation to true so that users can authenticate using the Open IDC protocol:

    # hammer settings set --name authorize_login_delegation --value true
  2. Set the login delegation logout URL:

    # hammer settings set --name login_delegation_logout_url \
    --value https://foreman.example.com/users/extlogout
  3. Set the algorithm for encoding on Quarkus-based Keycloak, for example, RS256:

    # hammer settings set --name oidc_algorithm --value 'RS256'
  4. Open the keycloak.example.com/auth/realms/KEYCLOAK_REALM/.well-known/openid-configuration URL and note the values to populate the options in the following steps.

  5. Add the value for the Hammer client in the Open IDC audience:

    # hammer settings set --name oidc_audience \
    --value "['foreman.example.com-hammer-openidc']"
    Note

    If you register several Quarkus-based Keycloak clients to Foreman, ensure that you append all audiences in the array. For example:

    # hammer settings set --name oidc_audience \
    --value "['foreman.example.com-foreman-openidc', 'foreman.example.com-hammer-openidc']"
  6. Set the value for the Open IDC issuer:

    # hammer settings set --name oidc_issuer \
    --value "keycloak.example.com/auth/realms/KEYCLOAK_REALM"
  7. Set the value for Open IDC Java Web Token (JWT):

    # hammer settings set --name oidc_jwks_url \
    --value "keycloak.example.com/auth/realms/KEYCLOAK_REALM/protocol/openid-connect/certs"
  8. Retrieve the ID of the Quarkus-based Keycloak authentication source:

    # hammer auth-source external list
  9. Set the location and organization:

    # hammer auth-source external update --id Authentication Source ID \
    --location-ids Location ID --organization-ids Organization ID

5.9.6. Configuring Keycloak settings for authentication with PIV cards

You must configure Keycloak settings for authentication with PIV cards.

Procedure
  1. In the Keycloak web UI, navigate to the Authentication tab.

  2. From the Flows list, select Browser.

  3. Click Copy to copy this flow.

  4. In the Copy Authentication Flow window, enter a new name for the flow and click OK.

  5. In the copied flow, delete Username Password Form and OTP Form entries.

  6. Click Add execution.

  7. From the Provider list, select X509/Validate Username Form.

  8. Click Save.

  9. In the X509/Validate Username Form raw, select ALTERNATIVE.

  10. In the X509/Validate Username Form raw, click Actions > Config.

  11. In the Alias field, enter a name for this configuration.

  12. From the User Identity Source list, select Subject’s Common Name,

  13. From the User mapping method list, select Username or Email.

  14. Click Save.

  15. Navigate to Authentication > Bindings.

  16. From the Browser Flow list, select the created flow.

5.9.7. Configuring users' OS for Keycloak authentication with PIV cards

Complete this procedure on each system from which you want to be able to log in to Foreman using Keycloak PIV cards.

Procedure
  1. Install the required package:

    # dnf install opensc
  2. Install the Firefox browser if not installed.

  3. Launch Firefox and navigate to Preferences.

  4. Click the Privacy and Security tab.

  5. Click Security Devices.

  6. Click Load.

  7. In the Load PKCS#11 Device Driver window, in the Module Name field, enter a name for this device.

  8. In the Module filename field, enter /usr/lib64/pkcs11/opensc-pkcs11.so.

  9. Click OK.

  10. If the PIV card is connected to system, restart the pcscd service.

5.9.8. Logging in to the Foreman web UI using Wildfly-based Keycloak PIV cards

Use this procedure to log in to the Foreman web UI using the Wildfly-based Keycloak PIV cards.

Procedure
  1. In Firefox, log in to Foreman and enter your credentials.

  2. When prompted, enter the PIN of the PIV card.

  3. Choose the certificate for authentication. Browser verifies this certificate with Wildfly-based Keycloak. Once authenticated, browser redirects you back to Foreman and logs you in.

5.9.9. Logging in to the Foreman CLI using Keycloak

Use this procedure to authenticate to the Foreman CLI using the code grant type.

Procedure
  1. To authenticate to the Foreman CLI using the code grant type, enter the following command:

    # hammer auth login oauth \
    --two-factor \
    --oidc-token-endpoint 'https://keycloak.example.com/auth/realms/ssl-realm/protocol/openid-connect/token' \
    --oidc-authorization-endpoint 'https://keycloak.example.com/auth' \
    --oidc-client-id 'foreman.example.com-foreman-openidc' \
    --oidc-redirect-uri urn:ietf:wg:oauth:2.0:oob

    The command prompts you to enter a success code.

  2. To retrieve the success code, navigate to the URL that the command returns and provide the required information.

  3. Copy the success code that the web UI returns.

  4. In the command prompt of hammer auth login oauth, enter the success code to authenticate to the Foreman CLI.

5.9.10. Configuring group mapping for Keycloak authentication

Optionally, to implement the Role Based Access Control (RBAC), create a group in Foreman, assign a role to this group, and then map an Active Directory group to the Foreman group. As a result, anyone in the given group in Keycloak are logged in under the corresponding Foreman group. This example configures users of the Foreman-admin user group in the Active Directory to authenticate as users with administrator privileges on Foreman.

Procedure
  1. In the Foreman web UI, navigate to Administer > User Groups.

  2. Click Create User Group.

  3. In the Name field, enter a name for the user group. The name should not be the same as in the Active Directory.

  4. Do not add users and user groups to the right-hand columns. Click the Roles tab.

  5. Select the Administer checkbox.

  6. Click the External Groups tab.

  7. Click Add external user group.

  8. In the Name field, enter the name of the Active Directory group.

  9. From the list, select EXTERNAL.

5.10. Configuring Active Directory as an external identity provider for Foreman

This section shows how to use direct Active Directory (AD) as an external authentication source for Foreman server.

Note

You can attach Active Directory as an external authentication source with no single sign-on support. For more information, see Configuring an LDAP server as an external identity provider for Foreman. For an example configuration, see How to configure Active Directory authentication with TLS on Foreman.

Direct AD integration means that Foreman server is joined directly to the AD domain where the identity is stored. The recommended setup consists of two steps:

5.10.1. GSS-Proxy

The traditional process of Kerberos authentication in Apache requires the Apache process to have read access to the keytab file. GSS-Proxy allows you to implement stricter privilege separation for the Apache server by removing access to the keytab file while preserving Kerberos authentication functionality. When using AD as an external authentication source for Foreman, it is recommended to implement GSS-proxy, because the keys in the keytab file are the same as the host keys.

Perform the following procedures on Enterprise Linux that acts as a base operating system for your Foreman server. For the examples in this section EXAMPLE.ORG is the Kerberos realm for the AD domain. By completing the procedures, users that belong to the EXAMPLE.ORG realm can log in to Foreman server.

5.10.2. Enrolling Foreman server with the AD server

In the Foreman CLI, enroll Foreman server with the Active Directory server.

Prerequisites
  • GSS-proxy and nfs-utils are installed.

    Installing GSS-proxy and nfs-utils:

    # dnf install gssproxy nfs-utils
Procedure
  1. Install the required packages:

    # dnf install sssd adcli realmd ipa-python-compat krb5-workstation samba-common-tools
  2. Enroll Foreman server with the AD server. You may need to have administrator permissions to perform the following command:

    # realm join -v EXAMPLE.ORG --membership-software=samba -U Administrator
    Note

    You must use the Samba client software to enroll with the AD server to create the HTTP keytab in Configuring direct AD integration with GSS-proxy.

5.10.3. Configuring direct AD integration with GSS-proxy

In the Foreman CLI, configure the direct Active Directory integration with GSS-proxy.

Prerequisites
Procedure
  1. Create the /etc/ipa/ directory and the default.conf file:

    # mkdir /etc/ipa
    # touch /etc/ipa/default.conf
  2. To the default.conf file, add the following content:

    [global]
    server = unused
    realm = EXAMPLE.ORG
  3. Create the /etc/net-keytab.conf file with the following content:

    [global]
    workgroup = EXAMPLE
    realm = EXAMPLE.ORG
    kerberos method = system keytab
    security = ads
  4. Determine the effective user ID of the Apache user:

    # id apache

    Apache user must not have access to the keytab file.

  5. Create the /etc/gssproxy/00-http.conf file with the following content:

    [service/HTTP]
    mechs = krb5
    cred_store = keytab:/etc/httpd/conf/http.keytab
    cred_store = ccache:/var/lib/gssproxy/clients/krb5cc_%U
    euid = ID_of_Apache_User
  6. Create a keytab entry:

    # KRB5_KTNAME=FILE:/etc/httpd/conf/http.keytab net ads keytab add HTTP -U administrator -d3 -s /etc/net-keytab.conf
    # chown root.apache /etc/httpd/conf/http.keytab
    # chmod 640 /etc/httpd/conf/http.keytab
  7. Enable IPA authentication in Foreman:

    # foreman-installer --foreman-ipa-authentication=true
  8. Start and enable the gssproxy service:

    # systemctl restart gssproxy
    # systemctl enable --now gssproxy
  9. To configure the Apache server to use the gssproxy service, create a systemd drop-in file and add the following content to it:

    # mkdir -p /etc/systemd/system/httpd.service.d/
    # vi /etc/systemd/system/httpd.service.d/gssproxy.conf
    [Service]
    Environment=GSS_USE_PROXY=1
  10. Apply changes to the service:

    # systemctl daemon-reload
  11. Start and enable the httpd service:

    # systemctl restart httpd
Important

With direct AD integration, HBAC through FreeIPA is not available. As an alternative, you can use Group Policy Objects (GPO) that enable administrators to centrally manage policies in AD environments. To ensure correct GPO to PAM service mapping, add the following SSSD configuration to /etc/sssd/sssd.conf:

access_provider = ad
ad_gpo_access_control = enforcing
ad_gpo_map_service = +foreman

Here, foreman is the PAM service name.

Verification

Verify that SSO is working as expected.

With a running Apache server, users making HTTP requests against the server are authenticated if the client has a valid Kerberos ticket.

  1. Retrieve the Kerberos ticket of the LDAP user, using the following command:

    # kinit ldapuser
  2. View the Kerberos ticket, using the following command:

    # klist
  3. View output from successful SSO-based authentication, using the following command:

    # curl -k -u : --negotiate https://foreman.example.com/users/extlogin

    This returns the following response:

    <html><body>You are being <a href="https://foreman.example.com/users/4-ldapuserexample-com/edit">redirected</a>.</body></html>

5.10.4. Kerberos configuration in web browsers

For information about configuring Firefox, see Configuring Firefox to use Kerberos for single sign-on in Red Hat Enterprise Linux 9 Configuring authentication and authorization in RHEL.

If you use the Internet Explorer browser, add Foreman server to the list of Local Intranet or Trusted sites, and turn on the Enable Integrated Windows Authentication setting. See the Internet Explorer documentation for details.

5.10.5. Configuring the FreeIPA server to use cross-forest trust

On the FreeIPA server, configure the server to use cross-forest trust.

Procedure
  1. Enable HBAC:

    1. Create an external group and add the AD group to it.

    2. Add the new external group to a POSIX group.

    3. Use the POSIX group in a HBAC rule.

  2. Configure sssd to transfer additional attributes of AD users.

    • Add the AD user attributes to the nss and domain sections in /etc/sssd/sssd.conf. For example:

      [nss]
      user_attributes=+mail, +sn, +givenname
      [domain/EXAMPLE.com]
      ...
      krb5_store_password_if_offline = True
      ldap_user_extra_attrs=email:mail, lastname:sn, firstname:givenname
      
      [ifp]
      allowed_uids = ipaapi, root
      user_attributes=+email, +firstname, +lastname
    • Verify the AD attributes value.

      # dbus-send --print-reply --system --dest=org.freedesktop.sssd.infopipe /org/freedesktop/sssd/infopipe org.freedesktop.sssd.infopipe.GetUserAttr string:ad-user@ad-domain array:string:email,firstname,lastname

5.11. Configuring Foreman to manage the lifecycle of a host registered to a FreeIPA realm

As well as providing access to Foreman server, hosts provisioned with Foreman can also be integrated with FreeIPA realms. Foreman has a realm feature that automatically manages the lifecycle of any system registered to a realm or domain provider.

Use this section to configure Foreman server or Smart Proxy server for FreeIPA realm support, then add hosts to the FreeIPA realm group.

Prerequisites
  • Foreman server that is registered to the Content Delivery Network or an external Smart Proxy server that is registered to Foreman server.

  • A deployed realm or domain provider such as FreeIPA.

To install and configure FreeIPA packages on Foreman server or Smart Proxy server:

To use FreeIPA for provisioned hosts, complete the following steps to install and configure FreeIPA packages on Foreman server or Smart Proxy server:

  1. Install the ipa-client package on Foreman server or Smart Proxy server:

    # dnf install ipa-client
  2. Configure the server as a FreeIPA client:

    # ipa-client-install
  3. Create a realm proxy user, realm-smart-proxy, and the relevant roles in FreeIPA:

    # foreman-prepare-realm admin realm-smart-proxy

    Note the principal name that returns and your FreeIPA server configuration details because you require them for the following procedure.

To configure Foreman server or Smart Proxy server for FreeIPA realm support:

Complete the following procedure on Foreman and every Smart Proxy that you want to use:

  1. Copy the /root/freeipa.keytab file to any Smart Proxy server that you want to include in the same principal and realm:

    # scp /root/freeipa.keytab root@smartproxy.example.com:/etc/foreman-proxy/freeipa.keytab
  2. Move the /root/freeipa.keytab file to the /etc/foreman-proxy directory and set the ownership settings to the foreman-proxy user:

    # mv /root/freeipa.keytab /etc/foreman-proxy
    # chown foreman-proxy:foreman-proxy /etc/foreman-proxy/freeipa.keytab
  3. Enter the following command on all Smart Proxies that you want to include in the realm. If you use the integrated Smart Proxy on Foreman, enter this command on Foreman server:

    # foreman-installer --foreman-proxy-realm true \
    --foreman-proxy-realm-keytab /etc/foreman-proxy/freeipa.keytab \
    --foreman-proxy-realm-principal realm-smart-proxy@EXAMPLE.COM \
    --foreman-proxy-realm-provider freeipa

    You can also use these options when you first configure the Foreman server.

  4. Ensure that the most updated versions of the ca-certificates package is installed and trust the FreeIPA Certificate Authority:

    # cp /etc/ipa/ca.crt /etc/pki/ca-trust/source/anchors/ipa.crt
    # update-ca-trust enable
    # update-ca-trust
  5. Optional: If you configure FreeIPA on an existing Foreman server or Smart Proxy server, complete the following steps to ensure that the configuration changes take effect:

    1. Restart the foreman-proxy service:

      # systemctl restart foreman-proxy
    2. In the Foreman web UI, navigate to Infrastructure > Smart Proxies.

    3. Locate the Smart Proxy you have configured for FreeIPA and from the list in the Actions column, select Refresh.

To create a realm for the FreeIPA-enabled Smart Proxy

After you configure your integrated or external Smart Proxy with FreeIPA, you must create a realm and add the FreeIPA-configured Smart Proxy to the realm.

Procedure
  1. In the Foreman web UI, navigate to Infrastructure > Realms and click Create Realm.

  2. In the Name field, enter a name for the realm.

  3. From the Realm Type list, select the type of realm.

  4. From the Realm Smart Proxy list, select Smart Proxy server where you have configured FreeIPA.

  5. Click the Locations tab and from the Locations list, select the location where you want to add the new realm.

  6. Click the Organizations tab and from the Organizations list, select the organization where you want to add the new realm.

  7. Click Submit.

Updating host groups with realm information

You must update any host groups that you want to use with the new realm information.

  1. In the Foreman web UI, navigate to Configure > Host Groups, select the host group that you want to update, and click the Network tab.

  2. From the Realm list, select the realm you create as part of this procedure, and then click Submit.

Adding hosts to a FreeIPA host group

FreeIPA supports the ability to set up automatic membership rules based on a system’s attributes. Foreman’s realm feature provides administrators with the ability to map the Foreman host groups to the FreeIPA parameter userclass which allow administrators to configure automembership.

When nested host groups are used, they are sent to the FreeIPA server as they are displayed in the Foreman User Interface. For example, "Parent/Child/Child".

Foreman server or Smart Proxy server sends updates to the FreeIPA server, however automembership rules are only applied at initial registration.

To add hosts to a FreeIPA host group:
  1. On the FreeIPA server, create a host group:

    # ipa hostgroup-add hostgroup_name --desc=hostgroup_description
  2. Create an automembership rule:

    # ipa automember-add --type=hostgroup hostgroup_name automember_rule

    Where you can use the following options:

    • automember-add flags the group as an automember group.

    • --type=hostgroup identifies that the target group is a host group, not a user group.

    • automember_rule adds the name you want to identify the automember rule by.

  3. Define an automembership condition based on the userclass attribute:

    # ipa automember-add-condition --key=userclass --type=hostgroup --inclusive-regex=^webserver hostgroup_name
    ----------------------------------
    Added condition(s) to "hostgroup_name"
    ----------------------------------
    Automember Rule: automember_rule
    Inclusive Regex: userclass=^webserver
    ----------------------------
    Number of conditions added 1
    ----------------------------

    Where you can use the following options:

    • automember-add-condition adds regular expression conditions to identify group members.

    • --key=userclass specifies the key attribute as userclass.

    • --type=hostgroup identifies that the target group is a host group, not a user group.

    • --inclusive-regex= ^webserver identifies matching values with a regular expression pattern.

    • hostgroup_name – identifies the target host group’s name.

When a system is added to Foreman server’s hostgroup_name host group, it is added automatically to the FreeIPA server’s "hostgroup_name" host group. FreeIPA host groups allow for Host-Based Access Controls (HBAC), sudo policies and other FreeIPA functions.

5.12. Configuring external user groups

Foreman does not associate external users with their user group automatically. You must create a user group with the same name as in the external source on Foreman. Members of the external user group then automatically become members of the Foreman user group and receive the associated permissions.

The configuration of external user groups depends on the type of external authentication.

To assign additional permissions to an external user, add this user to an internal user group that has no external mapping specified. Then assign the required roles to this group.

Prerequisites
  • If you use an LDAP server, configure Foreman to use LDAP authentication. For more information, see Configuring an LDAP server as an external identity provider for Foreman.

    When using external user groups from an LDAP source, you cannot use the $login variable as a substitute for the account user name. You must use either an anonymous or dedicated service user.

  • If you use a FreeIPA or AD server, configure Foreman to use FreeIPA or AD authentication. For more information, see Configuring External Authentication in Installing Foreman Server with Katello 4.13 plugin on Enterprise Linux.

  • Ensure that at least one external user authenticates for the first time.

  • Retain a copy of the external group names you want to use. To find the group membership of external users, enter the following command:

    # id username
Procedure
  1. In the Foreman web UI, navigate to Administer > User Groups, and click Create User Group.

  2. Specify the name of the new user group. Do not select any users to avoid adding users automatically when you refresh the external user group.

  3. Click the Roles tab and select the roles you want to assign to the user group. Alternatively, select the Administrator checkbox to assign all available permissions.

  4. Click the External groups tab, then click Add external user group, and select an authentication source from the Auth source drop-down menu.

    Specify the exact name of the external group in the Name field.

  5. Click Submit.

5.13. Refreshing external user groups for LDAP

To set the LDAP source to synchronize user group membership automatically on user login, in the Auth Source page, select the Usergroup Sync option. If this option is not selected, LDAP user groups are refreshed automatically through a scheduled cron job synchronizing the LDAP Authentication source every 30 minutes by default.

If the user groups in the LDAP Authentication source change in the lapse of time between scheduled tasks, the user can be assigned to incorrect external user groups. This is corrected automatically when the scheduled task runs.

Use this procedure to refresh the LDAP source manually.

Procedure
  1. In the Foreman web UI, navigate to Administer > Usergroups and select a user group.

  2. On the External Groups tab, click Refresh to the right of the required user group.

CLI procedure
  • Enter the following command:

    # foreman-rake ldap:refresh_usergroups

5.14. Refreshing external user groups for FreeIPA or AD

External user groups based on FreeIPA or AD are refreshed only when a group member logs in to Foreman. It is not possible to alter user membership of external user groups in the Foreman web UI, such changes are overwritten on the next group refresh.

5.15. Configuring the Hammer CLI to use FreeIPA user authentication

This section describes how to configure the Foreman Hammer command-line interface (CLI) tool to use FreeIPA (IdM) to authenticate users.

Prerequisites
  • You are logged in to the host from which you want to access Foreman by using Hammer.

Procedure
  1. Enable sessions in the ~/.hammer/cli.modules.d/foreman.yml Hammer configuration file by adding the :use_sessions: true line to the foreman parameters:

    :foreman:
      :use_sessions: true

    Adding the line enforces session usage in Hammer. This means that Hammer performs the authentication request only once instead of with each hammer command.

  2. Optional: Enable negotiate authentication in the ~/.hammer/cli.modules.d/foreman.yml Hammer configuration file by adding the :default_auth_type: 'Negotiate_Auth' line to the foreman parameters:

    :foreman:
      :default_auth_type: 'Negotiate_Auth'
      :use_sessions: true

    Adding this line means that your authentication is negotiated when you enter the first hammer command. If this entry is present, Hammer tries to communicate with Foreman server using the negotiation protocol.

5.16. Disabling Keycloak authentication

If you want to disable Keycloak authentication in Foreman, complete this procedure.

Procedure
  • Reset Keycloak support to the default value:

    # foreman-installer --reset-foreman-keycloak

6. Configuring Foreman server with external services

If you do not want to configure the DNS, DHCP, and TFTP services on Foreman server, use this section to configure your Foreman server to work with external DNS, DHCP, and TFTP services.

6.1. Configuring Foreman server with external DNS

You can configure Foreman server with external DNS. Foreman server uses the nsupdate utility to update DNS records on the remote server.

To make any changes persistent, you must enter the foreman-installer command with the options appropriate for your environment.

Prerequisites
  • You must have a configured external DNS server.

  • This guide assumes you have an existing installation.

Procedure
  1. Copy the /etc/rndc.key file from the external DNS server to Foreman server:

    # scp root@dns.example.com:/etc/rndc.key /etc/foreman-proxy/rndc.key
  2. Configure the ownership, permissions, and SELinux context:

    # restorecon -v /etc/foreman-proxy/rndc.key
    # chown -v root:foreman-proxy /etc/foreman-proxy/rndc.key
    # chmod -v 640 /etc/foreman-proxy/rndc.key
  3. To test the nsupdate utility, add a host remotely:

    # echo -e "server DNS_IP_Address\n \
    update add aaa.example.com 3600 IN A Host_IP_Address\n \
    send\n" | nsupdate -k /etc/foreman-proxy/rndc.key
    # nslookup aaa.example.com DNS_IP_Address
    # echo -e "server DNS_IP_Address\n \
    update delete aaa.example.com 3600 IN A Host_IP_Address\n \
    send\n" | nsupdate -k /etc/foreman-proxy/rndc.key
  4. Enter the foreman-installer command to make the following persistent changes to the /etc/foreman-proxy/settings.d/dns.yml file:

    # foreman-installer --foreman-proxy-dns=true \
    --foreman-proxy-dns-managed=false \
    --foreman-proxy-dns-provider=nsupdate \
    --foreman-proxy-dns-server="DNS_IP_Address" \
    --foreman-proxy-keyfile=/etc/foreman-proxy/rndc.key
  5. In the Foreman web UI, navigate to Infrastructure > Smart Proxies.

  6. Locate the Foreman server and select Refresh from the list in the Actions column.

  7. Associate the DNS service with the appropriate subnets and domain.

6.2. Configuring Foreman server with external DHCP

To configure Foreman server with external DHCP, you must complete the following procedures:

6.2.1. Configuring an external DHCP server to use with Foreman server

To configure an external DHCP server running Enterprise Linux to use with Foreman server, you must install the ISC DHCP Service and Berkeley Internet Name Domain (BIND) utilities packages. You must also share the DHCP configuration and lease files with Foreman server. The example in this procedure uses the distributed Network File System (NFS) protocol to share the DHCP configuration and lease files.

Note

If you use dnsmasq as an external DHCP server, enable the dhcp-no-override setting. This is required because Foreman creates configuration files on the TFTP server under the grub2/ subdirectory. If the dhcp-no-override setting is disabled, hosts fetch the bootloader and its configuration from the root directory, which might cause an error.

If you do not use firewall-cmd to configure the Linux firewall, implement using the command of your choice.

Procedure
  1. On your Enterprise Linux host, install the ISC DHCP Service and Berkeley Internet Name Domain (BIND) utilities packages:

    # dnf install dhcp-server bind-utils
  2. Generate a security token:

    # dnssec-keygen -a HMAC-MD5 -b 512 -n HOST omapi_key

    As a result, a key pair that consists of two files is created in the current directory.

  3. Copy the secret hash from the key:

    # grep ^Key Komapi_key.+*.private | cut -d ' ' -f2
  4. Edit the dhcpd configuration file for all subnets and add the key. The following is an example:

    # cat /etc/dhcp/dhcpd.conf
    default-lease-time 604800;
    max-lease-time 2592000;
    log-facility local7;
    
    subnet 192.168.38.0 netmask 255.255.255.0 {
    	range 192.168.38.10 192.168.38.100;
    	option routers 192.168.38.1;
    	option subnet-mask 255.255.255.0;
    	option domain-search "virtual.lan";
    	option domain-name "virtual.lan";
    	option domain-name-servers 8.8.8.8;
    }
    
    omapi-port 7911;
    key omapi_key {
    	algorithm HMAC-MD5;
    	secret "My_Secret";
    };
    omapi-key omapi_key;

    Note that the option routers value is the IP address of your Foreman server or Smart Proxy server that you want to use with an external DHCP service.

  5. Delete the two key files from the directory that they were created in.

  6. On Foreman server, define each subnet. Do not set DHCP Smart Proxy for the defined Subnet yet.

    To prevent conflicts, set up the lease and reservation ranges separately. For example, if the lease range is 192.168.38.10 to 192.168.38.100, in the Foreman web UI define the reservation range as 192.168.38.101 to 192.168.38.250.

  7. Configure the firewall for external access to the DHCP server:

    # firewall-cmd --add-service dhcp
  8. Make the changes persistent:

    # firewall-cmd --runtime-to-permanent
  9. On Foreman server, determine the UID and GID of the foreman user:

    # id -u foreman
    993
    # id -g foreman
    990
  10. On the DHCP server, create the foreman user and group with the same IDs as determined in a previous step:

    # groupadd -g 990 foreman
    # useradd -u 993 -g 990 -s /sbin/nologin foreman
  11. To ensure that the configuration files are accessible, restore the read and execute flags:

    # chmod o+rx /etc/dhcp/
    # chmod o+r /etc/dhcp/dhcpd.conf
    # chattr +i /etc/dhcp/ /etc/dhcp/dhcpd.conf
  12. Enable and start the DHCP service:

    # systemctl enable --now dhcpd
  13. Export the DHCP configuration and lease files using NFS:

    # dnf install nfs-utils
    # systemctl enable --now nfs-server
  14. Create directories for the DHCP configuration and lease files that you want to export using NFS:

    # mkdir -p /exports/var/lib/dhcpd /exports/etc/dhcp
  15. To create mount points for the created directories, add the following line to the /etc/fstab file:

    /var/lib/dhcpd /exports/var/lib/dhcpd none bind,auto 0 0
    /etc/dhcp /exports/etc/dhcp none bind,auto 0 0
  16. Mount the file systems in /etc/fstab:

    # mount -a
  17. Ensure the following lines are present in /etc/exports:

    /exports 192.168.38.1(rw,async,no_root_squash,fsid=0,no_subtree_check)
    
    /exports/etc/dhcp 192.168.38.1(ro,async,no_root_squash,no_subtree_check,nohide)
    
    /exports/var/lib/dhcpd 192.168.38.1(ro,async,no_root_squash,no_subtree_check,nohide)

    Note that the IP address that you enter is the Foreman or Smart Proxy IP address that you want to use with an external DHCP service.

  18. Reload the NFS server:

    # exportfs -rva
  19. Configure the firewall for DHCP omapi port 7911:

    # firewall-cmd --add-port=7911/tcp
  20. Optional: Configure the firewall for external access to NFS. Clients are configured using NFSv3.

    # firewall-cmd \
    --add-service mountd \
    --add-service nfs \
    --add-service rpc-bind \
    --zone public
  21. Make the changes persistent:

    # firewall-cmd --runtime-to-permanent

6.2.2. Configuring Foreman server with an external DHCP server

You can configure Foreman server with an external DHCP server.

Prerequisites
Procedure
  1. Install the nfs-utils package:

    # dnf install nfs-utils
  2. Create the DHCP directories for NFS:

    # mkdir -p /mnt/nfs/etc/dhcp /mnt/nfs/var/lib/dhcpd
  3. Change the file owner:

    # chown -R foreman-proxy /mnt/nfs
  4. Verify communication with the NFS server and the Remote Procedure Call (RPC) communication paths:

    # showmount -e DHCP_Server_FQDN
    # rpcinfo -p DHCP_Server_FQDN
  5. Add the following lines to the /etc/fstab file:

    DHCP_Server_FQDN:/exports/etc/dhcp /mnt/nfs/etc/dhcp nfs
    ro,vers=3,auto,nosharecache,context="system_u:object_r:dhcp_etc_t:s0" 0 0
    
    DHCP_Server_FQDN:/exports/var/lib/dhcpd /mnt/nfs/var/lib/dhcpd nfs
    ro,vers=3,auto,nosharecache,context="system_u:object_r:dhcpd_state_t:s0" 0 0
  6. Mount the file systems on /etc/fstab:

    # mount -a
  7. To verify that the foreman-proxy user can access the files that are shared over the network, display the DHCP configuration and lease files:

    # su foreman-proxy -s /bin/bash
    $ cat /mnt/nfs/etc/dhcp/dhcpd.conf
    $ cat /mnt/nfs/var/lib/dhcpd/dhcpd.leases
    $ exit
  8. Enter the foreman-installer command to make the following persistent changes to the /etc/foreman-proxy/settings.d/dhcp.yml file:

    # foreman-installer \
    --enable-foreman-proxy-plugin-dhcp-remote-isc \
    --foreman-proxy-dhcp-provider=remote_isc \
    --foreman-proxy-dhcp-server=My_DHCP_Server_FQDN \
    --foreman-proxy-dhcp=true \
    --foreman-proxy-plugin-dhcp-remote-isc-dhcp-config /mnt/nfs/etc/dhcp/dhcpd.conf \
    --foreman-proxy-plugin-dhcp-remote-isc-dhcp-leases /mnt/nfs/var/lib/dhcpd/dhcpd.leases \
    --foreman-proxy-plugin-dhcp-remote-isc-key-name=omapi_key \
    --foreman-proxy-plugin-dhcp-remote-isc-key-secret=My_Secret \
    --foreman-proxy-plugin-dhcp-remote-isc-omapi-port=7911
  9. Associate the DHCP service with the appropriate subnets and domain.

6.3. Configuring Foreman server with external TFTP

You can configure Foreman server with external TFTP services.

Procedure
  1. Create the TFTP directory for NFS:

    # mkdir -p /mnt/nfs/var/lib/tftpboot
  2. In the /etc/fstab file, add the following line:

    TFTP_Server_IP_Address:/exports/var/lib/tftpboot /mnt/nfs/var/lib/tftpboot nfs rw,vers=3,auto,nosharecache,context="system_u:object_r:tftpdir_rw_t:s0" 0 0
  3. Mount the file systems in /etc/fstab:

    # mount -a
  4. Enter the foreman-installer command to make the following persistent changes to the /etc/foreman-proxy/settings.d/tftp.yml file:

    # foreman-installer \
    --foreman-proxy-tftp-root /mnt/nfs/var/lib/tftpboot \
    --foreman-proxy-tftp=true
  5. If the TFTP service is running on a different server than the DHCP service, update the tftp_servername setting with the FQDN or IP address of the server that the TFTP service is running on:

    # foreman-installer --foreman-proxy-tftp-servername=TFTP_Server_FQDN
  6. In the Foreman web UI, navigate to Infrastructure > Smart Proxies.

  7. Locate the Foreman server and select Refresh from the list in the Actions column.

  8. Associate the TFTP service with the appropriate subnets and domain.

6.4. Configuring Foreman server with external IdM DNS

When Foreman server adds a DNS record for a host, it first determines which Smart Proxy is providing DNS for that domain. It then communicates with the Smart Proxy that is configured to provide DNS service for your deployment and adds the record. The hosts are not involved in this process. Therefore, you must install and configure the IdM client on the Foreman or Smart Proxy that is currently configured to provide a DNS service for the domain you want to manage using the IdM server.

Foreman server can be configured to use a Red Hat Identity Management (IdM) server to provide DNS service.

To configure Foreman server to use a Red Hat Identity Management (IdM) server to provide DNS service, use one of the following procedures:

To revert to internal DNS service, use the following procedure:

Note
You are not required to use Foreman server to manage DNS. When you are using the realm enrollment feature of Foreman, where provisioned hosts are enrolled automatically to IdM, the ipa-client-install script creates DNS records for the client. Configuring Foreman server with external IdM DNS and realm enrollment are mutually exclusive. For more information about configuring realm enrollment, see Configuring Foreman to manage the lifecycle of a host registered to a FreeIPA realm.

6.4.1. Configuring dynamic DNS update with GSS-TSIG authentication

You can configure the IdM server to use the generic security service algorithm for secret key transaction (GSS-TSIG) technology defined in RFC3645. To configure the IdM server to use the GSS-TSIG technology, you must install the IdM client on the Foreman server base operating system.

Prerequisites
  • You must ensure the IdM server is deployed and the host-based firewall is configured correctly.

  • You must contact the IdM server administrator to ensure that you obtain an account on the IdM server with permissions to create zones on the IdM server.

  • You should create a backup of the answer file. You can use the backup to restore the answer file to its original state if it becomes corrupted. For more information, see Configuring Foreman server.

Procedure

To configure dynamic DNS update with GSS-TSIG authentication, complete the following steps:

Creating a Kerberos principal on the IdM server
  1. Obtain a Kerberos ticket for the account obtained from the IdM administrator:

    # kinit idm_user
  2. Create a new Kerberos principal for Foreman server to use to authenticate on the IdM server:

    # ipa service-add smartproxy/foreman.example.com
Installing and configuring the idM client
  1. On the base operating system of either the Foreman or Smart Proxy that is managing the DNS service for your deployment, install the ipa-client package:

    # dnf install ipa-client
  2. Configure the IdM client by running the installation script and following the on-screen prompts:

    # ipa-client-install
  3. Obtain a Kerberos ticket:

    # kinit admin
  4. Remove any preexisting keytab:

    # rm /etc/foreman-proxy/dns.keytab
  5. Obtain the keytab for this system:

    # ipa-getkeytab -p smartproxy/foreman.example.com@EXAMPLE.COM \
    -s idm1.example.com -k /etc/foreman-proxy/dns.keytab
    Note

    When adding a keytab to a standby system with the same host name as the original system in service, add the r option to prevent generating new credentials and rendering the credentials on the original system invalid.

  6. For the dns.keytab file, set the group and owner to foreman-proxy:

    # chown foreman-proxy:foreman-proxy /etc/foreman-proxy/dns.keytab
  7. Optional: To verify that the keytab file is valid, enter the following command:

    # kinit -kt /etc/foreman-proxy/dns.keytab \
    smartproxy/foreman.example.com@EXAMPLE.COM
Configuring DNS zones in the IdM web UI
  1. Create and configure the zone that you want to manage:

    1. Navigate to Network Services > DNS > DNS Zones.

    2. Select Add and enter the zone name. For example, example.com.

    3. Click Add and Edit.

    4. Click the Settings tab and in the BIND update policy box, add the following to the semi-colon separated list:

      grant smartproxy\047foreman.example.com@EXAMPLE.COM wildcard * ANY;
    5. Set Dynamic update to True.

    6. Enable Allow PTR sync.

    7. Click Save to save the changes.

  2. Create and configure the reverse zone:

    1. Navigate to Network Services > DNS > DNS Zones.

    2. Click Add.

    3. Select Reverse zone IP network and add the network address in CIDR format to enable reverse lookups.

    4. Click Add and Edit.

    5. Click the Settings tab and in the BIND update policy box, add the following to the semi-colon separated list:

      grant smartproxy\047foreman.example.com@EXAMPLE.COM wildcard * ANY;
    6. Set Dynamic update to True.

    7. Click Save to save the changes.

Configuring the Foreman or Smart Proxy server that manages the DNS service for the domain
  1. Configure your Foreman server or Smart Proxy server to connect to your DNS service:

    # foreman-installer \
    --foreman-proxy-dns-managed=false \
    --foreman-proxy-dns-provider=nsupdate_gss \
    --foreman-proxy-dns-server="idm1.example.com" \
    --foreman-proxy-dns-tsig-keytab=/etc/foreman-proxy/dns.keytab \
    --foreman-proxy-dns-tsig-principal="smartproxy/foreman.example.com@EXAMPLE.COM" \
    --foreman-proxy-dns=true
  2. For each affected Smart Proxy, update the configuration of that Smart Proxy in the Foreman web UI:

    1. In the Foreman web UI, navigate to Infrastructure > Smart Proxies, locate the Foreman server, and from the list in the Actions column, select Refresh.

    2. Configure the domain:

      1. In the Foreman web UI, navigate to Infrastructure > Domains and select the domain name.

      2. In the Domain tab, ensure DNS Smart Proxy is set to the Smart Proxy where the subnet is connected.

    3. Configure the subnet:

      1. In the Foreman web UI, navigate to Infrastructure > Subnets and select the subnet name.

      2. In the Subnet tab, set IPAM to None.

      3. In the Domains tab, select the domain that you want to manage using the IdM server.

      4. In the Smart Proxies tab, ensure Reverse DNS Smart Proxy is set to the Smart Proxy where the subnet is connected.

      5. Click Submit to save the changes.

6.4.2. Configuring dynamic DNS update with TSIG authentication

You can configure an IdM server to use the secret key transaction authentication for DNS (TSIG) technology that uses the rndc.key key file for authentication. The TSIG protocol is defined in RFC2845.

Prerequisites
  • You must ensure the IdM server is deployed and the host-based firewall is configured correctly.

  • You must obtain root user access on the IdM server.

  • You must confirm whether Foreman server or Smart Proxy server is configured to provide DNS service for your deployment.

  • You must configure DNS, DHCP and TFTP services on the base operating system of either the Foreman or Smart Proxy that is managing the DNS service for your deployment.

  • You must create a backup of the answer file. You can use the backup to restore the answer file to its original state if it becomes corrupted. For more information, see Configuring Foreman server.

Procedure

To configure dynamic DNS update with TSIG authentication, complete the following steps:

Enabling external updates to the DNS zone in the IdM server
  1. On the IdM Server, add the following to the top of the /etc/named.conf file:

    ########################################################################
    
    include "/etc/rndc.key";
    controls  {
    inet _IdM_Server_IP_Address_ port 953 allow { _Foreman_IP_Address_; } keys { "rndc-key"; };
    };
    ########################################################################
  2. Reload the named service to make the changes take effect:

    # systemctl reload named
  3. In the IdM web UI, navigate to Network Services > DNS > DNS Zones and click the name of the zone. In the Settings tab, apply the following changes:

    1. Add the following in the BIND update policy box:

      grant "rndc-key" zonesub ANY;
    2. Set Dynamic update to True.

    3. Click Update to save the changes.

  4. Copy the /etc/rndc.key file from the IdM server to the base operating system of your Foreman server. Enter the following command:

    # scp /etc/rndc.key root@foreman.example.com:/etc/rndc.key
  5. To set the correct ownership, permissions, and SELinux context for the rndc.key file, enter the following command:

    # restorecon -v /etc/rndc.key
    # chown -v root:named /etc/rndc.key
    # chmod -v 640 /etc/rndc.key
  6. Assign the foreman-proxy user to the named group manually. Normally, foreman-installer ensures that the foreman-proxy user belongs to the named UNIX group, however, in this scenario Foreman does not manage users and groups, therefore you need to assign the foreman-proxy user to the named group manually.

    # usermod -a -G named foreman-proxy
  7. On Foreman server, enter the following foreman-installer command to configure Foreman to use the external DNS server:

    # foreman-installer \
    --foreman-proxy-dns-managed=false \
    --foreman-proxy-dns-provider=nsupdate \
    --foreman-proxy-dns-server="IdM_Server_IP_Address" \
    --foreman-proxy-dns-ttl=86400 \
    --foreman-proxy-dns=true \
    --foreman-proxy-keyfile=/etc/rndc.key
Testing external updates to the DNS zone in the IdM server
  1. Ensure that the key in the /etc/rndc.key file on Foreman server is the same key file that is used on the IdM server:

    key "rndc-key" {
            algorithm hmac-md5;
            secret "secret-key==";
    };
  2. On Foreman server, create a test DNS entry for a host. For example, host test.example.com with an A record of 192.168.25.20 on the IdM server at 192.168.25.1.

    # echo -e "server 192.168.25.1\n \
    update add test.example.com 3600 IN A 192.168.25.20\n \
    send\n" | nsupdate -k /etc/rndc.key
  3. On Foreman server, test the DNS entry:

    # nslookup test.example.com 192.168.25.1
    Server:		192.168.25.1
    Address:	192.168.25.1#53
    
    Name:	test.example.com
    Address: 192.168.25.20
  4. To view the entry in the IdM web UI, navigate to Network Services > DNS > DNS Zones. Click the name of the zone and search for the host by name.

  5. If resolved successfully, remove the test DNS entry:

    # echo -e "server 192.168.25.1\n \
    update delete test.example.com 3600 IN A 192.168.25.20\n \
    send\n" | nsupdate -k /etc/rndc.key
  6. Confirm that the DNS entry was removed:

    # nslookup test.example.com 192.168.25.1

    The above nslookup command fails and returns the SERVFAIL error message if the record was successfully deleted.

6.4.3. Reverting to internal DNS service

You can revert to using Foreman server and Smart Proxy server as your DNS providers. You can use a backup of the answer file that was created before configuring external DNS, or you can create a backup of the answer file. For more information about answer files, see Configuring Foreman server.

Procedure

On the Foreman or Smart Proxy server that you want to configure to manage DNS service for the domain, complete the following steps:

Configuring Foreman or Smart Proxy as a DNS server
  • If you have created a backup of the answer file before configuring external DNS, restore the answer file and then enter the foreman-installer command:

    # foreman-installer
  • If you do not have a suitable backup of the answer file, create a backup of the answer file now. To configure Foreman or Smart Proxy as DNS server without using an answer file, enter the following foreman-installer command on Foreman or Smart Proxy:

    # foreman-installer \
    --foreman-proxy-dns-managed=true \
    --foreman-proxy-dns-provider=nsupdate \
    --foreman-proxy-dns-server="127.0.0.1" \
    --foreman-proxy-dns=true

After you run the foreman-installer command to make any changes to your Smart Proxy configuration, you must update the configuration of each affected Smart Proxy in the Foreman web UI.

Updating the configuration in the Foreman web UI
  1. In the Foreman web UI, navigate to Infrastructure > Smart Proxies.

  2. For each Smart Proxy that you want to update, from the Actions list, select Refresh.

  3. Configure the domain:

    1. In the Foreman web UI, navigate to Infrastructure > Domains and click the domain name that you want to configure.

    2. In the Domain tab, set DNS Smart Proxy to the Smart Proxy where the subnet is connected.

  4. Configure the subnet:

    1. In the Foreman web UI, navigate to Infrastructure > Subnets and select the subnet name.

    2. In the Subnet tab, set IPAM to DHCP or Internal DB.

    3. In the Domains tab, select the domain that you want to manage using Foreman or Smart Proxy.

    4. In the Smart Proxies tab, set Reverse DNS Smart Proxy to the Smart Proxy where the subnet is connected.

    5. Click Submit to save the changes.

Appendix A: Troubleshooting DNF modules

If DNF modules fails to enable, it can mean an incorrect module is enabled. In that case, you have to resolve dependencies manually as follows. List the enabled modules:

# dnf module list --enabled

Ruby

If Ruby module fails to enable, it can mean an incorrect module is enabled. In that case, you have to resolve dependencies manually as follows:

List the enabled modules:

# dnf module list --enabled

If the Ruby 2.5 module has already been enabled, perform a module reset:

# dnf module reset ruby

PostgreSQL

If PostgreSQL module fails to enable, it can mean an incorrect module is enabled. In that case, you have to resolve dependencies manually as follows:

List the enabled modules:

# dnf module list --enabled

If the PostgreSQL 10 module has already been enabled, perform a module reset:

# dnf module reset postgresql

If a database was previously created using PostgreSQL 10, perform an upgrade:

  1. Enable the DNF modules:

    # dnf module enable katello:el8
  2. Install the PostgreSQL upgrade package:

    # dnf install postgresql-upgrade
  3. Perform the upgrade:

    # postgresql-setup --upgrade

Appendix B: Troubleshooting sync errors

"[Errno 1] Operation not permitted: …​" during repository syncing
# chown --recursive pulp.pulp /var/lib/pulp/media/
"{"policy":[""" is not a valid choice."]}" during Debian repository syncing
# foreman-rake katello:migrate_deb_content_attributes_to_pulp3
500 API error during syncing with "cryptography.fernet.InvalidToken" in /var/log/messages traceback

Run this on the Katello server and every smart proxy.

# sudo -u pulp PULP_SETTINGS='/etc/pulp/settings.py' pulpcore-manager datarepair-2327 --dry-run

If you see values greater than 0 returned from the dry-run:

# sudo -u pulp PULP_SETTINGS='/etc/pulp/settings.py' pulpcore-manager datarepair-2327

Appendix C: Applying custom configuration to Foreman

When you install and configure Foreman for the first time using foreman-installer, you can specify that the DNS and DHCP configuration files are not to be managed by Puppet using the installer flags --foreman-proxy-dns-managed=false and --foreman-proxy-dhcp-managed=false. If these flags are not specified during the initial installer run, rerunning of the installer overwrites all manual changes, for example, rerun for upgrade purposes. If changes are overwritten, you must run the restore procedure to restore the manual changes. For more information, see Restoring Manual Changes Overwritten by a Puppet Run.

To view all installer flags available for custom configuration, run foreman-installer --scenario katello --full-help. Some Puppet classes are not exposed to the Foreman installer. To manage them manually and prevent the installer from overwriting their values, specify the configuration values by adding entries to configuration file /etc/foreman-installer/custom-hiera.yaml. This configuration file is in YAML format, consisting of one entry per line in the format of <puppet class>::<parameter name>: <value>. Configuration values specified in this file persist across installer reruns.

Common examples include:

  • For Apache, to set the ServerTokens directive to only return the Product name:

    apache::server_tokens: Prod
  • To turn off the Apache server signature entirely:

    apache::server_signature: Off

The Puppet modules for the Foreman installer are stored under /usr/share/foreman-installer/modules. Check the .pp files (for example: moduleName/manifests/example.pp) to look up the classes, parameters, and values. Alternatively, use the grep command to do keyword searches.

Setting some values may have unintended consequences that affect the performance or functionality of Foreman. Consider the impact of the changes before you apply them, and test the changes in a non-production environment first. If you do not have a non-production Foreman environment, run the Foreman installer with the --noop and --verbose options. If your changes cause problems, remove the offending lines from custom-hiera.yaml and rerun the Foreman installer. If you have any specific questions about whether a particular value is safe to alter, contact Red Hat support.

Appendix D: Restoring manual changes overwritten by a Puppet run

If your manual configuration has been overwritten by a Puppet run, you can restore the files to the previous state. The following example shows you how to restore a DHCP configuration file overwritten by a Puppet run.

Procedure
  1. Copy the file you intend to restore. This allows you to compare the files to check for any mandatory changes required by the upgrade. This is not common for DNS or DHCP services.

    # cp /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.backup
  2. Check the log files to note down the md5sum of the overwritten file. For example:

    # journalctl -xe
    ...
    /Stage[main]/Dhcp/File[/etc/dhcp/dhcpd.conf]: Filebucketed /etc/dhcp/dhcpd.conf to puppet with sum 622d9820b8e764ab124367c68f5fa3a1
    ...
  3. Restore the overwritten file:

    # puppet filebucket restore --local --bucket \
    /var/lib/puppet/clientbucket /etc/dhcp/dhcpd.conf \ 622d9820b8e764ab124367c68f5fa3a1
  4. Compare the backup file and the restored file, and edit the restored file to include any mandatory changes required by the upgrade.