1. Accessing Foreman

After Foreman has been installed and configured, use the Foreman web UI interface to log in to Foreman for further configuration.

1.1. Logging on to Foreman

Use the web user interface to log on to Foreman for further configuration.

Procedure
  1. Access Foreman server using a web browser pointed to the fully qualified domain name:

    https://foreman.example.com/
  2. Enter the user name and password created during the configuration process. If a user was not created during the configuration process, the default user name is admin. If you have problems logging on, you can reset the password. For more information, see Resetting the Administrative User Password.

Use the navigation tabs to browse the Foreman web UI.

Navigation Tabs Description

Any Context

Clicking this tab changes the organization and location. If no organization or location is selected, the default organization is Any Organization and the default location is Any Location. Use this tab to change to different values.

Monitor

Provides summary dashboards and reports.

Content

Provides content management tools. This includes Content Views, Activation Keys, and Life Cycle Environments.

Hosts

Provides host inventory and provisioning configuration tools.

Configure

Provides general configuration tools and data including Host Groups and Puppet data.

Infrastructure

Provides tools on configuring how Foreman interacts with the environment.

User Name

Provides user administration where users can edit their personal information.

notification bell

Provides event notifications to keep administrators informed of important environment changes.

Administer

Provides advanced configuration for settings such as Users and RBAC, as well as general settings.

1.3. Changing the Password

These steps show how to change your password.

Procedure
  1. Click your user name at the top right corner.

  2. Select My Account from the menu.

  3. In the Current Password field, enter the current password.

  4. In the Password field, enter a new password.

  5. In the Verify field, enter the new password again.

  6. Click the Submit button to save your new password.

1.4. Resetting the Administrative User Password

Use the following procedures to reset the administrative password to randomly generated characters or to set a new administrative password.

To Reset the Administrative User Password
  1. Log on to the base operating system where Foreman server is installed.

  2. Enter the following command to reset the password:

    # foreman-rake permissions:reset
    Reset to user: admin, password: qwJxBptxb7Gfcjj5
  3. Use this password to reset the password in the Foreman web UI.

  4. Edit the ~/.hammer/cli.modules.d/foreman.yml file on Foreman server to add the new password:

    # vi ~/.hammer/cli.modules.d/foreman.yml

Unless you update the ~/.hammer/cli.modules.d/foreman.yml file, you cannot use the new password with Hammer CLI.

To Set a New Administrative User Password
  1. Log on to the base operating system where Foreman server is installed.

  2. To set the password, enter the following command:

    # foreman-rake permissions:reset password=new_password
  3. Edit the ~/.hammer/cli.modules.d/foreman.yml file on Foreman server to add the new password:

    # vi ~/.hammer/cli.modules.d/foreman.yml

Unless you update the ~/.hammer/cli.modules.d/foreman.yml file, you cannot use the new password with Hammer CLI.

1.5. Setting a Custom Message on the Login Page

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

  2. Click the edit button next to Login page footer text, and enter the desired text to be displayed on the login page. For example, this text may be a warning message required by your company.

  3. Click Save.

  4. Log out of the Foreman web UI and verify that the custom text is now displayed on the login page below the Foreman version number.

2. Managing Foreman with Ansible Collections

Foreman Ansible Collections is a set of Ansible modules that interact with the Foreman API. You can use Foreman Ansible Collections to manage and automate many aspects of Foreman.

2.1. Installing the Foreman Ansible Modules

Use this procedure to install the Foreman Ansible modules.

Procedure
  • Install the package using the following command:

    # apt-get install ansible-collection-theforeman-foreman

2.2. Viewing the Foreman Ansible Modules

Starting with Ansible 2.10, you can view the installed Foreman Ansible modules by running:

# ansible-doc -l theforeman.foreman

When using Ansible before 2.10, you can view the installed Foreman Ansible modules by listing the content of the following directory:

# ls /usr/share/ansible/collections/ansible_collections/theforeman/foreman/plugins/modules/

Alternatively, you can also see the complete list of Foreman Ansible modules and other related information at Ansible Galaxy.

All modules are in the theforeman.foreman namespace and can be referred to in the format theforeman.foreman._module_name_. For example, to display information about the activation_key module, enter the following command:

$ ansible-doc theforeman.foreman.activation_key

3. Managing Users and Roles

A User defines a set of details for individuals using the system. Users can be associated with organizations and environments, so that when they create new entities, the default settings are automatically used. Users can also have one or more roles attached, which grants them rights to view and manage organizations and environments. See User Management for more information on working with users.

You can manage permissions of several users at once by organizing them into user groups. User groups themselves can be further grouped to create a hierarchy of permissions. For more information on creating user groups, see Creating and Managing User Groups.

Roles define a set of permissions and access levels. Each role contains one on more permission filters that specify the actions allowed for the role. Actions are grouped according to the Resource type. Once a role has been created, users and user groups can be associated with that role. This way, you can assign the same set of permissions to large groups of users. Foreman provides a set of predefined roles and also enables creating custom roles and permission filters as described in Creating and Managing Roles.

3.1. User Management

As an administrator, you can create, modify and remove Foreman users. You can also configure access permissions for a user or a group of users by assigning them different roles.

3.1.1. Creating a User

Use this procedure to create a user. To use the CLI instead of the Foreman web UI, see the CLI procedure.

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

  2. Click Create User.

  3. In the Login field, enter a username for the user.

  4. In the Firstname and Lastname fields, enter the real first name and last name of the user.

  5. In the Mail field, enter the user’s email address.

  6. In the Description field, add a description of the new user.

  7. Select a specific language for the user from the Language list.

  8. Select a timezone for the user from the Timezone list.

    By default, Foreman server uses the language and timezone settings of the user’s browser.

  9. Set a password for the user:

    1. From the Authorized by list, select the source by which the user is authenticated.

    2. Enter an initial password for the user in the Password field and the Verify field.

  10. Click Submit to create the user.

CLI procedure
  • To create a user, enter the following command:

    # hammer user create \
    --auth-source-id My_Authentication_Source \
    --login My_User_Name \
    --mail My_User_Mail \
    --organization-ids My_Organization_ID_1,My_Organization_ID_2 \
    --password My_User_Password

    The --auth-source-id 1 setting means that the user is authenticated internally, you can specify an external authentication source as an alternative. Add the --admin option to grant administrator privileges to the user. Specifying organization IDs is not required, you can modify the user details later using the update subcommand.

For more information about user related subcommands, enter hammer user --help.

3.1.2. Assigning Roles to a User

Use this procedure to assign roles to a user. To use the CLI instead of the Foreman web UI, see the CLI procedure.

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

  2. Click the username of the user to be assigned one or more roles.

    Note

    If a user account is not listed, check that you are currently viewing the correct organization. To list all the users in Foreman, click Default Organization and then Any Organization.

  3. Click the Locations tab, and select a location if none is assigned.

  4. Click the Organizations tab, and check that an organization is assigned.

  5. Click the Roles tab to display the list of available roles.

  6. Select the roles to assign from the Roles list.

    To grant all the available permissions, select the Admin checkbox.

  7. Click Submit.

To view the roles assigned to a user, click the Roles tab; the assigned roles are listed under Selected items. To remove an assigned role, click the role name in Selected items.

CLI procedure
  • To assign roles to a user, enter the following command:

    # hammer user add-role --id user_id --role role_name

3.1.3. Impersonating a Different User Account

Administrators can impersonate other authenticated users for testing and troubleshooting purposes by temporarily logging on to the Foreman web UI as a different user. When impersonating another user, the administrator has permissions to access exactly what the impersonated user can access in the system, including the same menus.

Audits are created to record the actions that the administrator performs while impersonating another user. However, all actions that an administrator performs while impersonating another user are recorded as having been performed by the impersonated user.

Prerequisites
  • Ensure that you are logged on to the Foreman web UI as a user with administrator privileges for Foreman.

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

  2. To the right of the user that you want to impersonate, from the list in the Actions column, select Impersonate.

When you want to stop the impersonation session, in the upper right of the main menu, click the impersonation icon.

3.1.4. Creating an API-Only User

You can create users that can interact only with the Foreman API.

Prerequisite
  1. You have created a user and assigned roles to them. Note that this user must be authorized internally. For more information, see Creating a User and Assigning Roles to a User.

Procedure
  1. Log in to your Foreman as admin.

  2. Navigate to Administer > Users and select a user.

  3. On the User tab, set a password. Do not save or communicate this password with others. You can create pseudo-random strings on your console:

    # openssl rand -hex 32
  4. Create a Personal Access Token for the user. For more information, see Creating a Personal Access Token.

3.2. SSH Key Management

Adding SSH keys to a user allows deployment of SSH keys during provisioning. For information on deploying SSH keys during provisioning, see Deploying SSH Keys during Provisioning in the Provisioning guide.

For information on SSH keys and SSH key creation, see Using SSH-based Authentication in the Red Hat Enterprise Linux 8 Configuring Basic System Settings Guide.

3.2.1. Managing SSH Keys for a User

Use this procedure to add or remove SSH keys for a user. To use the CLI instead of the Foreman web UI, see the CLI procedure.

Prerequisites

Ensure that you are logged in to the Foreman web UI as an Admin user of Foreman or a user with the create_ssh_key permission enabled for adding SSH key and destroy_ssh_key permission for removing a key.

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

  2. From the Username column, click on the username of the required user.

  3. Click on the SSH Keys tab.

    • To Add SSH key

      1. Prepare the content of the public SSH key in a clipboard.

      2. Click Add SSH Key.

      3. In the Key field, paste the public SSH key content from the clipboard.

      4. In the Name field, enter a name for the SSH key.

      5. Click Submit.

    • To Remove SSH key

      1. Click Delete on the row of the SSH key to be deleted.

      2. Click OK in the confirmation prompt.

CLI procedure

To add an SSH key to a user, you must specify either the path to the public SSH key file, or the content of the public SSH key copied to the clipboard.

  • If you have the public SSH key file, enter the following command:

    # hammer user ssh-keys add \
    --user-id user_id \
    --name key_name \
    --key-file ~/.ssh/id_rsa.pub
  • If you have the content of the public SSH key, enter the following command:

    # hammer user ssh-keys add \
    --user-id user_id \
    --name key_name \
    --key ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNtYAAABBBHHS2KmNyIYa27Qaa7EHp+2l99ucGStx4P77e03ZvE3yVRJEFikpoP3MJtYYfIe8k 1/46MTIZo9CPTX4CYUHeN8= host@user

To delete an SSH key from a user, enter the following command:

# hammer user ssh-keys delete --id key_id --user-id user_id

To view an SSH key attached to a user, enter the following command:

# hammer user ssh-keys info --id key_id --user-id user_id

To list SSH keys attached to a user, enter the following command:

# hammer user ssh-keys list --user-id user_id

3.3. Managing Personal Access Tokens

Personal Access Tokens allow you to authenticate API requests without using your password. You can set an expiration date for your Personal Access Token and you can revoke it if you decide it should expire before the expiration date.

3.3.1. Creating a Personal Access Token

Use this procedure to create a Personal Access Token.

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

  2. Select a user for which you want to create a Personal Access Token.

  3. On the Personal Access Tokens tab, click Add Personal Access Token.

  4. Enter a Name for you Personal Access Token.

  5. Optional: Select the Expires date to set an expiration date. If you do not set an expiration date, your Personal Access Token will never expire unless revoked.

  6. Click Submit. You now have the Personal Access Token available to you on the Personal Access Tokens tab.

    Important

    Ensure to store your Personal Access Token as you will not be able to access it again after you leave the page or create a new Personal Access Token. You can click Copy to clipboard to copy your Personal Access Token.

Verification
  1. Make an API request to your Foreman server and authenticate with your Personal Access Token:

    # curl https://foreman.example.com/api/status --user My_Username:My_Personal_Access_Token
  2. You should receive a response with status 200, for example:

    {"foreman_version":"2.5.0","result":"ok","status":200,"version":"3.5.1.10","api_version":2}

    If you go back to Personal Access Tokens tab, you can see the updated Last Used time next to your Personal Access Token.

3.3.2. Revoking a Personal Access Token

Use this procedure to revoke a Personal Access Token before its expiration date.

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

  2. Select a user for which you want to revoke the Personal Access Token.

  3. On the Personal Access Tokens tab, locate the Personal Access Token you want to revoke.

  4. Click Revoke in the Actions column next to the Personal Access Token you want to revoke.

Verification
  1. Make an API request to your Foreman server and try to authenticate with the revoked Personal Access Token:

    # curl https://foreman.example.com/api/status --user My_Username:My_Personal_Access_Token
  2. You receive the following error message:

    {
      "error": {"message":"Unable to authenticate user My_Username"}
    }

3.4. Creating and Managing User Groups

3.4.1. User Groups

With Foreman, you can assign permissions to groups of users. You can also create user groups as collections of other user groups. If using an external authentication source, you can map Foreman user groups to external user groups as described in Configuring External User Groups.

User groups are defined in an organizational context, meaning that you must select an organization before you can access user groups.

3.4.2. Creating a User Group

Use this procedure to create a user group.

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

  2. Click Create User group.

  3. On the User Group tab, specify the name of the new user group and select group members:

    • Select the previously created user groups from the User Groups list.

    • Select users from the Users list.

  4. On the Roles tab, select the roles you want to assign to the user group. Alternatively, select the Admin checkbox to assign all available permissions.

  5. Click Submit.

CLI procedure
  • To create a user group, enter the following command:

    # hammer user-group create \
    --name My_User_Group_Name \
    --role-ids My_Role_ID_1,My_Role_ID_2 \
    --user-ids My_User_ID_1,My_User_ID_2

3.4.3. Removing a User Group

Use the Foreman web UI to remove a user group.

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

  2. Click Delete to the right of the user group you want to delete.

  3. In the alert box that appears, click OK to delete a user group.

3.5. Creating and Managing Roles

Foreman provides a set of predefined roles with permissions sufficient for standard tasks, as listed in Predefined Roles Available in Foreman. It is also possible to configure custom roles, and assign one or more permission filters to them. Permission filters define the actions allowed for a certain resource type. Certain Foreman plug-ins create roles automatically.

3.5.1. Creating a Role

Use this procedure to create a role.

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

  2. Click Create Role.

  3. Provide a Name for the role.

  4. Click Submit to save your new role.

CLI procedure
  • To create a role, enter the following command:

    # hammer role create --name My_Role_Name

To serve its purpose, a role must contain permissions. After creating a role, proceed to Adding Permissions to a Role.

3.5.2. Cloning a Role

Use the Foreman web UI to clone a role.

Procedure
  1. In the Foreman web UI, navigate to Administer > Roles and select Clone from the drop-down menu to the right of the required role.

  2. Provide a Name for the role.

  3. Click Submit to clone the role.

  4. Click the name of the cloned role and navigate to Filters.

  5. Edit the permissions as required.

  6. Click Submit to save your new role.

3.5.3. Adding Permissions to a Role

Use this procedure to add permissions to a role. To use the CLI instead of the Foreman web UI, see the CLI procedure.

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

  2. Select Add Filter from the drop-down list to the right of the required role.

  3. Select the Resource type from the drop-down list. The (Miscellaneous) group gathers permissions that are not associated with any resource group.

  4. Click the permissions you want to select from the Permission list.

  5. Depending on the Resource type selected, you can select or deselect the Unlimited and Override checkbox. The Unlimited checkbox is selected by default, which means that the permission is applied on all resources of the selected type. When you disable the Unlimited checkbox, the Search field activates. In this field you can specify further filtering with use of the Foreman search syntax. For more information, see Granular Permission Filtering. When you enable the Override checkbox, you can add additional locations and organizations to allow the role to access the resource type in the additional locations and organizations; you can also remove an already associated location and organization from the resource type to restrict access.

  6. Click Next.

  7. Click Submit to save changes.

CLI procedure
  1. List all available permissions:

    # hammer filter available-permissions
  2. Add permissions to a role:

    # hammer filter create \
    --permission-ids My_Permission_ID_1,My_Permission_ID_2 \
    --role My_Role_Name

For more information about roles and permissions parameters, enter the hammer role --help and hammer filter --help commands.

3.5.4. Viewing Permissions of a Role

Use the Foreman web UI to view the permissions of a role.

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

  2. Click Filters to the right of the required role to get to the Filters page.

The Filters page contains a table of permissions assigned to a role grouped by the resource type. It is also possible to generate a complete table of permissions and actions that you can use on your Foreman system. For more information, see Creating a Complete Permission Table.

3.5.5. Creating a Complete Permission Table

Use the Foreman CLI to create a permission table.

Procedure
  1. Ensure that the required packages are installed. Execute the following command on Foreman server:

    # apt-get install foreman-console
  2. Start the Foreman console with the following command:

    # foreman-rake console

    Insert the following code into the console:

    f = File.open('/tmp/table.html', 'w')
    
    result = Foreman::AccessControl.permissions {|a,b| a.security_block <=> b.security_block}.collect do |p|
          actions = p.actions.collect { |a| "<li>#{a}</li>" }
          "<tr><td>#{p.name}</td><td><ul>#{actions.join('')}</ul></td><td>#{p.resource_type}</td></tr>"
    end.join("\n")
    
    f.write(result)

    The above syntax creates a table of permissions and saves it to the /tmp/table.html file.

  3. Press Ctrl + D to exit the Foreman console. Insert the following text at the first line of /tmp/table.html:

    <table border="1"><tr><td>Permission name</td><td>Actions</td><td>Resource type</td></tr>

    Append the following text at the end of /tmp/table.html:

    </table>
  4. Open /tmp/table.html in a web browser to view the table.

3.5.6. Removing a Role

Use the Foreman web UI to remove a role.

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

  2. Select Delete from the drop-down list to the right of the role to be deleted.

  3. In an alert box that appears, click OK to delete the role.

3.6. Predefined Roles Available in Foreman

The following table provides an overview of permissions that predefined roles in Foreman grant to a user.

To view the exact set of permissions a predefined role grants, display the role in Foreman web UI as the privileged user. For more information, see Viewing Permissions of a Role.

Table 1. Permissions provided by role
Role Permissions Provided by Role

Access Insights Admin

Add and edit Insights rules.

Access Insights Viewer

View Insight reports.

Ansible Roles Manager

Play roles on hosts and host groups. View, destroy, and import Ansible roles. View, edit, create, destroy, and import Ansible variables.

Ansible Tower Inventory Reader

View facts, hosts, and host groups.

Bookmarks manager

Create, edit, and delete bookmarks.

Boot disk access

Download the boot disk.

Compliance manager

View, create, edit, and destroy SCAP content files, compliance policies, and tailoring files. View compliance reports.

Compliance viewer

View compliance reports.

Create ARF report

Create compliance reports.

Default role

The set of permissions that every user is granted, irrespective of any other roles.

Discovery Manager

View, provision, edit, and destroy discovered hosts and manage discovery rules.

Discovery Reader

View hosts and discovery rules.

Edit hosts

View, create, edit, destroy, and build hosts.

Edit partition tables

View, create, edit and destroy partition tables.

Manager

View and edit global settings.

Organization admin

All permissions except permissions for managing organizations.

An administrator role defined per organization. The role has no visibility into resources in other organizations.

By cloning this role and assigning an organization, you can delegate administration of that organization to a user.

Red Hat Access Logs

View the log viewer and the logs.

Remote Execution Manager

Control which roles have permission to run infrastructure jobs.

Remote Execution User

Run remote execution jobs against hosts.

Site manager

A restrained version of the Manager role.

System admin

  • Edit global settings in Administer > Settings.

  • View, create, edit and destroy users, user groups, and roles.

  • View, create, edit, destroy, and assign organizations and locations but not view resources within them.

Users with this role can create users and assign all roles to them. Therefore, ensure to give this role only to trusted users.

Tasks manager

View and edit Foreman tasks.

Tasks reader

A role that can only view Foreman tasks.

Viewer

A passive role that provides the ability to view the configuration of every element of the Foreman structure, logs, reports, and statistics.

View hosts

A role that can only view hosts.

Virt-who Manager

A role with full virt-who permissions.

Virt-who Reporter

Upload reports generated by virt-who to Foreman. It can be used if you configure virt-who manually and require a user role that has limited virt-who permissions.

Virt-who Viewer

View virt-who configurations. Users with this role can deploy virt-who instances using existing virt-who configurations.

3.7. Granular Permission Filtering

3.7.1. Granular Permission Filter

As mentioned in Adding Permissions to a Role, Foreman provides the ability to limit the configured user permissions to selected instances of a resource type. These granular filters are queries to the Foreman database and are supported by the majority of resource types.

3.7.2. Creating a Granular Permission Filter

Use this procedure to create a granular filter. To use the CLI instead of the Foreman web UI, see the CLI procedure.

Foreman does not apply search conditions to create actions. For example, limiting the create_locations action with name = "Default Location" expression in the search field does not prevent the user from assigning a custom name to the newly created location.

Procedure

Specify a query in the Search field on the Edit Filter page. Deselect the Unlimited checkbox for the field to be active. Queries have the following form:

field_name operator value
  • field_name marks the field to be queried. The range of available field names depends on the resource type. For example, the Partition Table resource type offers family, layout, and name as query parameters.

  • operator specifies the type of comparison between field_name and value. See Supported Operators for Granular Search for an overview of applicable operators.

  • value is the value used for filtering. This can be for example a name of an organization. Two types of wildcard characters are supported: underscore (_) provides single character replacement, while percent sign (%) replaces zero or more characters.

For most resource types, the Search field provides a drop-down list suggesting the available parameters. This list appears after placing the cursor in the search field. For many resource types, you can combine queries using logical operators such as and, not and has operators.

CLI procedure
  • To create a granular filter, enter the hammer filter create command with the --search option to limit permission filters, for example:

    # hammer filter create \
    --permission-ids 91 \
    --search "name ~ ccv*" \
    --role qa-user

This command adds to the qa-user role a permission to view, create, edit, and destroy Content Views that only applies to Content Views with name starting with ccv.

3.7.3. Examples of Using Granular Permission Filters

As an administrator, you can allow selected users to make changes in a certain part of the environment path. The following filter allows you to work with content while it is in the development stage of the application life cycle, but the content becomes inaccessible once is pushed to production.

Applying Permissions for the Host Resource Type

The following query applies any permissions specified for the Host resource type only to hosts in the group named host-editors.

hostgroup = host-editors

The following query returns records where the name matches XXXX, Yyyy, or zzzz example strings:

name ^ (XXXX, Yyyy, zzzz)

You can also limit permissions to a selected environment. To do so, specify the environment name in the Search field, for example:

Dev

You can limit user permissions to a certain organization or location with the use of the granular permission filter in the Search field. However, some resource types provide a GUI alternative, an Override checkbox that provides the Locations and Organizations tabs. On these tabs, you can select from the list of available organizations and locations. For more information, see Creating an Organization Specific Manager Role.

Creating an Organization Specific Manager Role

Use the Foreman web UI to create an administrative role restricted to a single organization named org-1.

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

  2. Clone the existing Organization admin role. Select Clone from the drop-down list next to the Filters button. You are then prompted to insert a name for the cloned role, for example org-1 admin.

  3. Click the desired locations and organizations to associate them with the role.

  4. Click Submit to create the role.

  5. Click org-1 admin, and click Filters to view all associated filters. The default filters work for most use cases. However, you can optionally click Edit to change the properties for each filter. For some filters, you can enable the Override option if you want the role to be able to access resources in additional locations and organizations. For example, by selecting the Domain resource type, the Override option, and then additional locations and organizations using the Locations and Organizations tabs, you allow this role to access domains in the additional locations and organizations that is not associated with this role. You can also click New filter to associate new filters with this role.

3.7.4. Supported Operators for Granular Search

Table 2. Logical Operators

Operator

Description

and

Combines search criteria.

not

Negates an expression.

has

Object must have a specified property.

Table 3. Symbolic Operators

Operator

Description

=

Is equal to. An equality comparison that is case-sensitive for text fields.

!=

Is not equal to. An inversion of the = operator.

~

Like. A case-insensitive occurrence search for text fields.

!~

Not like. An inversion of the ~ operator.

^

In. An equality comparison that is case-sensitive search for text fields. This generates a different SQL query to the Is equal to comparison, and is more efficient for multiple value comparison.

!^

Not in. An inversion of the ^ operator.

>, >=

Greater than, greater than or equal to. Supported for numerical fields only.

<, ⇐

Less than, less than or equal to. Supported for numerical fields only.

4. Email Notifications

Email notifications are created by Foreman server periodically or after completion of certain events. The periodic notifications can be sent daily, weekly or monthly.

The events that trigger a notification are the following:

  • Host build

  • Content View promotion

  • Error reported by host

  • Repository sync

Users do not receive any email notifications by default. An administrator can configure users to receive notifications based on criteria such as the type of notification, and frequency.

Note

If you want email notifications sent to a group’s email address, instead of an individual’s email address, create a user account with the group’s email address and minimal Foreman permissions, then subscribe the user account to the desired notification types.

Important

Foreman server does not enable outgoing emails by default, therefore you must review your email configuration. For more information, see Configuring Foreman server for Outgoing Emails in Installing Foreman server from a Connected Network.

4.1. Configuring Email Notifications

You can configure Foreman to send email messages to individual users registered to Foreman. Foreman sends the email to the email address that has been added to the account, if present. Users can edit the email address by clicking on their name in the top-right of the Foreman web UI and selecting My account.

Configure email notifications for a user from the Foreman web UI.

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

  2. Click the Username of the user you want to edit.

  3. On the User tab, verify the value of the Mail field. Email notifications will be sent to the address in this field.

  4. On the Email Preferences tab, select Mail Enabled.

  5. Select the notifications you want the user to receive using the drop-down menus next to the notification types.

    Note

    The Audit Summary notification can be filtered by entering the required query in the Mail Query text box.

  6. Click Submit.

    The user will start receiving the notification emails.

4.2. Testing Email Delivery

To verify the delivery of emails, send a test email to a user. If the email gets delivered, the settings are correct.

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

  2. Click on the username.

  3. On the Email Preferences tab, click Test email.

    A test email message is sent immediately to the user’s email address.

If the email is delivered, the verification is complete. Otherwise, you must perform the following diagnostic steps:

  1. Verify the user’s email address.

  2. Verify Foreman server’s email configuration.

  3. Examine firewall and mail server logs.

4.3. Testing Email Notifications

To verify that users are correctly subscribed to notifications, trigger the notifications manually.

Procedure
  • To trigger the notifications, execute the following command:

    # foreman-rake reports:_My_Frequency_

    Replace My_Frequency with one of the following:

  • daily

  • weekly

  • monthly

This triggers all notifications scheduled for the specified frequency for all the subscribed users. If every subscribed user receives the notifications, the verification succeeds.

Note

Sending manually triggered notifications to individual users is currently not supported.

4.4. Notification Types

The following are the notifications created by Foreman:

  • Audit summary: A summary of all activity audited by Foreman server.

  • Host built: A notification sent when a host is built.

  • Host errata advisory: A summary of applicable and installable errata for hosts managed by the user.

  • OpenSCAP policy summary: A summary of OpenSCAP policy reports and their results.

  • Promote errata: A notification sent only after a Content View promotion. It contains a summary of errata applicable and installable to hosts registered to the promoted Content View. This allows a user to monitor what updates have been applied to which hosts.

  • Puppet error state: A notification sent after a host reports an error related to Puppet.

  • Puppet summary: A summary of Puppet reports.

  • Sync errata: A notification sent only after synchronizing a repository. It contains a summary of new errata introduced by the synchronization.

4.5. Changing Email Notification Settings for a Host

Foreman can send event notifications for a host to the host’s registered owner. You can configure Foreman to send email notifications either to an individual user or a user group. When set to a user group, all group members who are subscribed to the email type receive a message.

Receiving email notifications for a host can be useful, but also overwhelming if you are expecting to receive frequent errors, for example, because of a known issue or error you are working around.

Procedure
  1. In the Foreman web UI, navigate to Hosts > All Hosts, locate the host that you want to view, and click Edit in the Actions column.

  2. Go to the Additional Information tab. If the checkbox Include this host within Foreman reporting is checked, then the email notifications are enabled on that host.

  3. Optional: Toggle the checkbox to enable or disable the email notifications.

    Note

    If you want to receive email notifications, ensure that you have an email address set in your user settings.

5. Maintaining Foreman server

This chapter provides information on how to maintain a Foreman server, including information on how to work with audit records, how to clean unused tasks, and how to recover Pulp from a full disk.

5.1. Deleting Audit Records

Audit records are created automatically in Foreman. You can use the foreman-rake audits:expire command to remove audits at any time. You can also use a cron job to schedule audit record deletions at the set interval that you want.

By default, using the foreman-rake audits:expire command removes audit records that are older than 90 days. You can specify the number of days to keep the audit records by adding the days option and add the number of days.

For example, if you want to delete audit records that are older than seven days, enter the following command:

# foreman-rake audits:expire days=7

5.2. Anonymizing Audit Records

You can use the foreman-rake audits:anonymize command to remove any user account or IP information while maintaining the audit records in the database. You can also use a cron job to schedule anonymizing the audit records at the set interval that you want.

By default, using the foreman-rake audits:anonymize command anonymizes audit records that are older than 90 days. You can specify the number of days to keep the audit records by adding the days option and add the number of days.

For example, if you want to anonymize audit records that are older than seven days, enter the following command:

# foreman-rake audits:anonymize days=7

5.3. Deleting Report Records

Report records are created automatically in Foreman. You can use the foreman-rake reports:expire command to remove reports at any time. You can also use a cron job to schedule report record deletions at the set interval that you want.

By default, using the foreman-rake reports:expire command removes report records that are older than 90 days. You can specify the number of days to keep the report records by adding the days option and add the number of days.

For example, if you want to delete report records that are older than seven days, enter the following command:

# foreman-rake reports:expire days=7

5.4. Configuring the Cleaning Unused Tasks Feature

Foreman performs regular cleaning to reduce disc space in the database and limit the rate of disk growth. As a result, Foreman backup completes faster and overall performance is higher.

By default, Foreman executes a cron job that cleans tasks every day at 19:45. Foreman removes the following tasks during the cleaning:

  • Tasks that have run successfully and are older than thirty days

  • All tasks that are older than a year

You can configure the cleaning unused tasks feature using these options:

  • To configure the time at which Foreman runs the cron job, set the --foreman-plugin-tasks-cron-line parameter to the time you want in cron format. For example, to schedule the cron job to run every day at 15:00, enter the following command:

    # foreman-installer --foreman-plugin-tasks-cron-line "00 15 * * *"
  • To configure the period after which Foreman deletes the tasks, edit the :rules: section in the /etc/foreman/plugins/foreman-tasks.yaml file.

  • To disable regular task cleanup on Foreman, enter the following command:

    # foreman-installer --foreman-plugin-tasks-automatic-cleanup false
  • To reenable regular task cleanup on Foreman, enter the following command:

    # foreman-installer --foreman-plugin-tasks-automatic-cleanup true

5.5. Deleting Task Records

Task records are created automatically in Foreman. You can use the foreman-rake foreman_tasks:cleanup command to remove tasks at any time. You can also use a cron job to schedule Task record deletions at the set interval that you want.

For example, if you want to delete task records from successful repository synchronizations, enter the following command:

# foreman-rake foreman_tasks:cleanup TASK_SEARCH='label = Actions::Katello::Repository::Sync' STATES='stopped'

5.6. Deleting a Task by ID

You can delete tasks by ID, for example if you have submitted confidential data by mistake.

Procedure
  1. Connect to your Foreman server using SSH:

    # ssh root@foreman.example.com
  2. Optional: View the task:

    # hammer task info --id My_Task_ID
  3. Delete the task:

    # foreman-rake foreman_tasks:cleanup TASK_SEARCH="id=My_Task_ID"
  4. Optional: Ensure the task has been removed from Foreman server:

    # hammer task info --id My_Task_ID

    Note that because the task is deleted, this command returns a non-zero exit code.

6. Logging and Reporting Problems

This chapter provides information on how to log and report problems in Foreman, including information on relevant log files, how to enable debug logging, how to open a support case and attach the relevant log tar files, and how to access support cases within the Foreman web UI.

For more information about Foreman logging settings, use foreman-installer with the --full-help option:

# foreman-installer --full-help | grep logging

6.1. Enabling Debug Logging

Debug logging provides the most detailed log information and can help with troubleshooting issues that can arise with Foreman and its components. In the Foreman CLI, enable debug logging to log detailed debugging information for Foreman.

Procedure
  1. To enable debug logging, enter the following command:

    # foreman-installer --foreman-logging-level debug
  2. After you complete debugging, reset the logging level to the default value:

    # foreman-installer --reset-foreman-logging-level

6.2. Increasing the Logging Levels to Help with Debugging

By default, Foreman comes with :INFO level logging enabled. You can increase or decrease the log levels on your Foreman.

6.2.1. Increasing the Logging Level For Hammer

You can find the log for Hammer in ~/.hammer/log/hammer.log. Edit /etc/hammer/cli_config.yml and set the :log_level::

:log_level: 'debug'

6.2.2. Increasing the Logging Level On Smart Proxy

You can find the log for Smart Proxy in /var/log/foreman-proxy/proxy.log. Uncomment the DEBUG line in /etc/foreman-proxy/settings.yml:

:log_level: DEBUG

Ensure to restart the foreman-proxy service afterwards:

# systemctl restart foreman-proxy
Caution

Running the installer will revert this change back.

6.2.3. Increasing the Logging Level On Foreman

You can find the log for Foreman in /var/log/foreman/production.log.

Foreman stores logs for Apache in:

  • /var/log/httpd/foreman_error.log

  • /var/log/httpd/foreman_access.log

  • /var/log/httpd/foreman_ssl_error.log

  • /var/log/httpd/foreman_ssl_access.log

Procedure
  1. Set the logging level in /etc/foreman/settings.yaml:

    :logging:
      :production:
        :type: file
        :layout: pattern
        :level: debug
  2. Enable selected loggers in /etc/foreman/settings.yaml:

    :loggers:
      :ldap:
        :enabled: true
      :permissions:
        :enabled: true
      :sql:
        :enabled: true

    Note that to see logging from some area, debug logging has to be set.

  3. Restart Foreman services:

    # foreman-maintain service restart

You can find the complete list of loggers with their default values in /usr/share/foreman/config/application.rb in the Foreman::Logging.add_loggers command.

6.2.4. Increasing the Logging Level For Redis

You can find the log for Redis in /var/log/redis/redis.log. Set the log level in /etc/opt/rh/rh-redis5/redis.conf:

loglevel debug

Ensure to restart the Redis service afterwards:

# systemctl restart rh-redis5-redis

6.2.5. Increasing the Logging Level For Postgres

You can find the log for Postgres in /var/opt/rh/rh-postgresql12/lib/pgsql/data/log/. Uncomment the log_statement in /var/opt/rh/rh-postgresql12/lib/pgsql/data/postgresql.conf:

log_statement = 'all'

Ensure to restart Foreman services afterwards:

# foreman-maintain service restart
Caution

Based on the size of your Foreman installation, this can cause disk space to fill up very quickly. Only turn this on if absolutely needed.

For more debug log settings, refer to the Postgresql documentation.

6.2.6. Increasing the Logging Level For Foreman Installer

You can find the log files in /var/log/foreman-installer/. To increase the log level of the Foreman Installer during an install:

# foreman-installer --verbose-log-level debug

6.2.7. Increasing the Logging Level For Puppet Agent

You can increase the logging level for Puppet agent on your Foreman server.

Procedure
  1. Add the following line to the [agent] block in the /etc/puppetlabs/puppet/puppet.conf file:

    [agent]
        log_level = debug

You can find the logs in /var/log/puppetlabs/puppet/

6.2.8. Increasing the Logging Level For Puppet Server

You can increase the logging level for Puppet server on your Foreman server.

Procedure
  1. Add the following line to the [master] block in /etc/puppetlabs/puppet/puppet.conf file:

    [master]
        log_level = debug
  2. Restart the Puppet server:

    # foreman-maintain service restart --only puppetserver

You can find the logs in /var/log/puppetlabs/puppetserver/.

6.3. Retrieving the Status of Services

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

  2. On the Smart Proxies tab, you can view the status of all Smart Proxies.

  3. On the Compute Resources tab, you can view the status of attached compute resource providers.

  4. In the Backend System Status table, you can view the status of all back-end services.

CLI procedure
  • Run hammer ping to get information from the database and Foreman services:

    # hammer ping
  • Use foreman-maintain to check the status of the services running in systemd:

    # foreman-maintain service status
  • Use foreman-maintain to perform a health check:

    $ foreman-maintain health check

6.4. Restarting Services

Foreman uses a set of back-end services to perform tasks. You you experience an issue with your Foreman, check the status of Foreman services.

Procedure
  • Use foreman-maintain to restart Foreman services:

    # foreman-maintain service restart
Tip

Run foreman-maintain --help for more information.

6.5. Enabling Individual Loggers

You can enable individual loggers for selective logging. Foreman uses the following loggers:

app

Logs web requests and all general application messages. Default value: true.

audit

Logs additional fact statistics, numbers of added, updated, and removed facts. Default value: true.

background

Logs information from the background processing component.

blob

Logs contents of rendered templates for auditing purposes.

Important
The blob logger might contain sensitive data.
dynflow

Logs information from the Dynflow process.

ldap

Logs high level LDAP queries and LDAP operations. Default value: false.

notifications

Logs information from the notifications component.

permissions

Logs queries to user roles, filters, and permissions when loading pages. Default value: false.

sql

Logs SQL queries made through Rails ActiveRecord. Default value: false.

telemetry

Logs debugging information from telemetry.

templates

Logs information from the template renderer component.

Procedure
  1. Enable the individual loggers that you want. For example, to enable sql and ldap loggers, enter the following command:

    # foreman-installer \
    --foreman-loggers ldap:true \
    --foreman-loggers sql:true
  2. Optional: To reset loggers to their default values, enter the following command:

    # foreman-installer --reset-foreman-loggers

6.6. Configuring Logging to Journal or File-based Logging

Foreman uses file-based logging by default. You can use the foreman-installer command to reconfigure logging.

Procedure for configuring logging with Journal
  1. Enter the following foreman-installer command to configure logging to the journald service:

    # foreman-installer \
    --foreman-logging-layout pattern \
    --foreman-logging-type journald \
    --foreman-proxy-log JOURNAL
  2. Optional: To inspect the log messages, use the journalctl utility. For example:

    • journalctl --unit foreman and journalctl --unit foreman-proxy show messages for the foreman and foreman-proxy units

    • journalctl REQUEST=request_ID shows messages for a specified request

Procedure for configuring file-based logging
  1. Enter the following foreman-installer command to configure file-based logging:

    # foreman-installer \
    --reset-foreman-logging-layout \
    --reset-foreman-logging-type \
    --reset-foreman-proxy-log
  2. Optional: To inspect the log messages, view these files:

    • /var/log/foreman/production.log

    • /var/log/foreman-proxy.log

6.7. Log File Directories Provided by Foreman

Foreman provides system information in the form of notifications and log files.

Table 4. Log File Directories for Reporting and Troubleshooting
Log File Directories Description of Log File Content

/var/log/candlepin

Subscription management

/var/log/foreman-installer

Installer

/var/log/foreman-maintain

Foreman maintain

/var/log/foreman-proxy

Foreman proxy

/var/log/foreman

Foreman

/var/log/httpd

Apache HTTP server

/var/log/messages

Various other log messages

/var/log/puppetlabs/puppet

Configuration management

/var/log/rhsm

Subscription management

/var/log/tomcat

Candlepin webservice logs

You can also use the foreman-tail command to follow many of the log files related to Foreman. You can run foreman-tail -l to list the processes and services that it follows.

6.8. Utilities for Collecting Log Information

You can collect information from log files to troubleshoot Foreman.

foreman-debug

The foreman-debug command collects configuration and log file data for Foreman, its back-end services, and system information. This information is collected and written to a tar file. By default, the output tar file is located at /tmp/foreman-debug-xxx.tar.xz.

Additionally, the foreman-debug command exports tasks run during the last 60 days. By default, the output tar file is located at /tmp/task-export-xxx.tar.xz. If the file is missing, see the file /tmp/task-export.log to learn why task export was unsuccessful. There is no timeout when running this command.

For more information, run foreman-debug -h.

Important

The collection process removes security information such as passwords, tokens, and keys while collecting information. However, the tar files can still contain sensitive information about the Foreman server. Foreman community recommends that you send this information directly to the intended recipient and not to a public target.

6.9. System Journal Metadata

The following table lists metadata that the journald service uses in Foreman. You can use this metadata to filter your queries.

Table 5. System Journal Metadata
Name Description

AUDIT_ACTION

Audit action performed

Example: Create, update, or delete

AUDIT_TYPE

Audit resource type

Example: Host, Subnet, or ContentView

AUDIT_ID

Audit resource database ID as a number

AUDIT_ATTRIBUTE

Audit resource field or an updated database column

AUDIT_FIELD_OLD

Old audit value of an update action

AUDIT_FIELD_NEW

New audit value of an update action

AUDIT_ID

Record database ID of the audit subject

AUDIT_ATTRIBUTE

Attribute name or column on which an action was performed

Example: Name or description

EXCEPTION_MESSAGE

Exception message when error is logged

EXCEPTION_CLASS

Exception Ruby class when error is logged

EXCEPTION_BACKTRACE

Exception backtrace as a multiline string when error is logged

LOC_ID

Location database ID

LOC_NAME

Location name

LOC_LABEL

Location label

LOGGER

Logger name

To see the current list of loggers enabled by default, enter this command:

# awk '/add_loggers/,/^$/' /usr/share/foreman/config/application.rb

ORG_ID

Organization database ID

ORG_NAME

Organization name

ORG_LABEL

Organization label

REMOTE_IP

Remote IP address of a client

REQUEST

Request ID generated by the Action Dispatch module

SESSION

Random ID generated per session or a request for a sessionless request

TEMPLATE_NAME

Template name

TEMPLATE_DIGEST

Digest (SHA256) of rendered template contents

TEMPLATE_HOST_NAME

Host name for a rendered template if present

TEMPLATE_HOST_ID

Host database ID for a rendered template if present

USER_LOGIN

User login name

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

# cat /etc/passwd | grep 'puppet\|apache\|foreman\|foreman-proxy'
# cat /etc/group | grep 'puppet\|apache\|foreman\|foreman-proxy'
Scenarios for Configuring External Authentication

Foreman supports the following general scenarios for configuring external authentication:

  • Using Lightweight Directory Access Protocol (LDAP) server as an external identity provider. LDAP is a set of open protocols used to access centrally stored information over a network. With Foreman, you can manage LDAP entirely through the Foreman web UI. For more information, see Using LDAP. Though you can use LDAP to connect to a FreeIPA or AD server, the setup does not support server discovery, cross-forest trusts, or single sign-on with Kerberos in Foreman’s web UI.

  • Using a FreeIPA server as an external identity provider. FreeIPA deals with the management of individual identities, their credentials and privileges used in a networking environment. Configuration using FreeIPA cannot be completed using only the Foreman web UI and requires some interaction with the CLI. For more information see Using FreeIPA.

  • Using Active Directory (AD) integrated with FreeIPA through cross-forest Kerberos trust as an external identity provider. For more information see Active Directory with Cross-Forest Trust.

  • Using Keycloak as an OpenID provider for external authentication to Foreman. For more information, see Configuring Foreman with Keycloak Authentication.

  • Using Keycloak as an OpenID provider for external authentication to Foreman with TOTP. For more information, see Configuring Keycloak Authentication with TOTP.

  • Using Keycloak as an OpenID provider for external authentication to Foreman with PIV cards. For more information, see Configuring Keycloak Authentication with PIV Cards.

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 life cycle of any system registered to a realm or domain provider. For more information, see External Authentication for Provisioned Hosts.

Table 6. Authentication Overview
Type Authentication User Groups

FreeIPA

Kerberos or LDAP

Yes

Active Directory

Kerberos or LDAP

Yes

POSIX

LDAP

Yes

7.1. Using LDAP

Foreman supports LDAP authentication using one or multiple LDAP directories.

If you require Foreman to use TLS to establish a secure LDAP connection (LDAPS), first obtain certificates used by the LDAP server you are connecting to and mark them as trusted on the base operating system of your Foreman server as described below. If your LDAP server uses a certificate chain with intermediate certificate authorities, all of the root and intermediate certificates in the chain must be trusted, so ensure all certificates are obtained. If you do not require secure LDAP at this time, proceed to Configuring Foreman to use LDAP.

Important

Users cannot use both FreeIPA and LDAP as an authentication method. Once a user authenticates using one method, they cannot use the other method.

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

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

7.1.1. Configuring TLS for Secure LDAP

Use the Foreman CLI to configure TLS for secure LDAP (LDAPS).

Procedure
  1. Obtain the Certificate from the LDAP Server.

    1. If you use Active Directory Certificate Services, export the Enterprise PKI CA Certificate using the Base-64 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 onto Foreman server and remove it when finished.

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

  2. Trust the Certificate from the LDAP Server.

    Foreman server requires the CA certificates for LDAP authentication to be individual files in /etc/pki/tls/certs/ directory.

    1. Use the install command to install the imported certificate into the /etc/pki/tls/certs/ directory with the correct permissions:

      # install /tmp/example.crt /etc/pki/tls/certs/
    2. Enter the following command as root to trust the example.crt certificate obtained from the LDAP server:

      # 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

7.1.2. Configuring Foreman to use LDAP

In the Foreman web UI, configure Foreman to use LDAP.

Note that if you need single sign-on functionality with Kerberos on Foreman web UI, you should use FreeIPA and AD external authentication instead. For more information, see:

Procedure
  1. Set the Network Information System (NIS) service boolean to true to prevent SELinux from stopping outgoing LDAP connections:

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

  3. Click Create LDAP Authentication Source.

  4. On the LDAP server tab, enter the LDAP server’s name, host name, port, and server type. The default port is 389, the default server type is POSIX (alternatively you can select FreeIPA or Active Directory depending on the type of authentication server). For TLS encrypted connections, select the LDAPS checkbox to enable encryption. The port should change to 636, which is the default for LDAPS.

  5. On the Account tab, enter the account information and domain name details. See Description of LDAP Settings for descriptions and examples.

  6. On the Attribute mappings tab, map LDAP attributes to Foreman attributes. You can map login name, first name, last name, email address, and photo attributes. See Example Settings for LDAP Connections for examples.

  7. On the Locations tab, select locations from the left table. Selected locations are assigned to users created from the LDAP authentication source, and available after their first login.

  8. On the Organizations tab, select organizations from the left table. Selected organizations are assigned to users created from the LDAP authentication source, and available after their first login.

  9. Click Submit.

  10. Configure new accounts for LDAP users:

    • If you did not select Automatically Create Accounts In Foreman checkbox, see Creating a User to create user accounts manually.

    • If you selected the Automatically Create Accounts In Foreman checkbox, LDAP users can now log in to Foreman using their LDAP accounts and passwords. After they log in for the first time, the Foreman administrator has to assign roles to them manually. See Assigning Roles to a User to assign user accounts appropriate roles in Foreman.

7.1.3. Description of LDAP Settings

The following table provides a description for each setting in the Account tab.

Table 7. Account Tab Settings
Setting Description

Account

The user name of the LDAP account that has read access to the LDAP server. User name is not required if the server allows anonymous reading, otherwise use the full path to the user’s object. For example:

uid=$login,cn=users,cn=accounts,dc=example,dc=com

The $login variable stores the username entered on the login page as a literal string. The value is accessed when the variable is expanded.

The variable cannot be used with external user groups from an LDAP source because Foreman needs to retrieve the group list without the user logging in. Use either an anonymous, or dedicated service user.

Account password

The LDAP password for the user defined in the Account username field. This field can remain blank if the Account username is using the $login variable.

Base DN

The top level domain name of the LDAP directory.

Groups base DN

The top level domain name of the LDAP directory tree that contains groups.

LDAP filter

A filter to restrict LDAP queries.

Automatically Create Accounts In Foreman

If this checkbox is selected, Foreman creates user accounts for LDAP users when they log in to Foreman for the first time. After they log in for the first time, the Foreman administrator has to assign roles to them manually. See Assigning Roles to a User to assign user accounts appropriate roles in Foreman.

Usergroup Sync

If this option is selected, the user group membership of a user is automatically synchronized when the user logs in, which ensures the membership is always up to date. If this option is cleared, Foreman relies on a cron job to regularly synchronize group membership (every 30 minutes by default). For more information, see Configuring External User Groups.

7.1.4. Example Settings for LDAP Connections

The following table shows example settings for different types of LDAP connections. The example below uses a dedicated service account called redhat that has bind, read, and search permissions on the user and group entries. Note that LDAP attribute names are case sensitive.

Table 8. Example Settings for Active Directory, Free IPA or Red Hat Identity Management and POSIX LDAP Connections
Setting Active Directory FreeIPA or Red Hat Identity Management POSIX (OpenLDAP)

Account

DOMAIN\redhat

uid=redhat,cn=users, cn=accounts,dc=example, dc=com

uid=redhat,ou=users, dc=example,dc=com

Account password

P@ssword

-

-

Base DN

DC=example,DC=COM

dc=example,dc=com

dc=example,dc=com

Groups Base DN

CN=Users,DC=example,DC=com

cn=groups,cn=accounts, dc=example,dc=com

cn=employee,ou=userclass, dc=example,dc=com

Login name attribute

userPrincipalName

uid

uid

First name attribute

givenName

givenName

givenName

Last name attribute

sn

sn

sn

Email address attribute

mail

mail

mail

Photo attribute

thumbnailPhoto

-

-

Note

userPrincipalName allows the use of whitespace in usernames. The login name attribute sAMAccountName (which is not listed in the table above) provides backwards compatibility with legacy Microsoft systems. sAMAccountName does not allow the use of whitespace in usernames.

7.1.5. Example LDAP Filters

As an administrator, you can create LDAP filters to restrict the access of specific users to Foreman.

Table 9. Example filters for allowing specific users to login
User 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)

Note

Group Users is a nested group that contains groups Group1 and Group2. If you want to filter all users from a nested group, you must add memberOf:1.2.840.113556.1.4.1941:= before the nested group name. See the last example in the table above.

LDAP directory structure

The LDAP directory structure that the filters in the example use:

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

The group membership that the filters in the example use:

Group Members

Group1

User1, User3

Group2

User2, User3

7.2. 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 Using LDAP.

Important

Users cannot use both FreeIPA and LDAP as an authentication method. Once a user authenticates using one method, they cannot use the other method.

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

Prerequisite
  • 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 8 Installing Identity Management Guide.

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

    For more information on host configuration properties, see About Host Entry Configuration Properties in the Red Hat Enterprise Linux 7 Linux Domain Identity, Authentication, and Policy guide.

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

    # ipa service-add HTTP/hostname

    For more information on managing services, see Managing Services in the Red Hat Enterprise Linux 7 Linux Domain Identity, Authentication, and Policy guide.

  5. On Foreman server, install the IPA client:

    # apt-get 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. If Foreman server is running on Red Hat Enterprise Linux 7, execute the following command:

    # subscription-manager repos --enable rhel-7-server-optional-rpms

    The installer is dependent on packages which, on Red Hat Enterprise Linux 7, are in the optional repository rhel-7-server-optional-rpms.

  8. If Foreman server is running on Debian, ensure that the hostname is set to the fully qualified domain name (FQDN); the short name is not sufficient:

    # hostname
    foreman.example.com

    Otherwise the installer cannot generate the right principal name that is needed to join the realm.

  9. Set foreman-ipa-authentication to true, using the following command:

    # foreman-installer --foreman-ipa-authentication=true
  10. 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. If the user in FreeIPA is configured for 2FA, and Foreman server is running on Red Hat Enterprise Linux 7, this user can also authenticate to Foreman with an OTP.

7.2.2. 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 Managing IdM Users, Groups, Hosts, and Access Control Rules Guide.

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

7.3. Using Active Directory

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 Using LDAP. 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:

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

7.3.2. Enrolling Foreman server with the AD Server

In the Foreman CLI, enroll Foreman server with the Active Directory server.

Prerequisite
  • GSS-proxy and nfs-utils are installed.

    Installing GSS-proxy and nfs-utils:

    # apt-get install gssproxy nfs-utils
Procedure
  1. Install the required packages:

    # apt-get 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

7.3.3. Configuring Direct AD Integration with GSS-Proxy

In the Foreman CLI, configure the direct Active Directory integration with GSS-proxy.

Prerequisite
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.service
    # systemctl enable gssproxy.service
  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.service
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>

7.3.4. Kerberos Configuration in Web Browsers

For information on configuring the Firefox browser see Configuring Firefox to Use Kerberos for Single Sign-On in the Red Hat Enterprise Linux System-Level Authentication guide.

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.

7.3.5. 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. For more information on cross-forest trusts, see Creating Cross-forest Trusts with Active Directory and Identity Management in the Red Hat Enterprise Linux Windows Integration guide.

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.

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

7.4. 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 Using LDAP.

    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.

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

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

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

7.7. External Authentication for Provisioned Hosts

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:

    # apt-get 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.

7.8. Configuring Foreman with Keycloak Authentication

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

7.8.1. Prerequisites for Configuring Foreman with Keycloak Authentication

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

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

  • A Keycloak account with admin privileges.

  • A realm for Foreman user accounts created in 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 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 Keycloak. For more information, see Creating New Users in the Red Hat Single Sign-On Server Administration Guide.

7.8.2. Registering Foreman as a Keycloak Client

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 the Foreman server, install the following packages:

    # apt-get install mod_auth_openidc keycloak-httpd-client-install
  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

7.8.3. Configuring the Foreman Client in Keycloak

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

Procedure
  1. In the Keycloak web UI, navigate to 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.

7.8.4. Configuring Foreman Settings for Keycloak Authentication

Use this section to configure Foreman for Keycloak authentication using the Foreman web UI or the CLI.

Configuring Foreman Settings for Keycloak Authentication Using the Web UI

Use this procedure to configure Foreman settings for 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

Prerequisite
  • Ensure that the Access Type setting in the Foreman client in the 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 Keycloak to RS256.

  6. Locate the OIDC Audience row, and in the Value column, set the value to the client ID for 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 Keycloak authentication source.

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

  12. Click Submit.

Configuring Foreman Settings for Keycloak Authentication Using the CLI

Use this procedure to configure Foreman settings for 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

Prerequisite
  • Ensure that the Access Type setting in the Foreman client in the 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 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 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 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

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

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

7.8.7. 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, and click the Create User Group button.

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

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

  4. Select the Administer checkbox.

  5. Click the External Groups tab.

  6. Click Add external user group.

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

  8. From the list, select EXTERNAL.

7.9. Configuring Keycloak Authentication with TOTP

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

7.9.1. Prerequisites for Configuring Foreman with Keycloak Authentication

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

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

  • A Keycloak account with admin privileges.

  • A realm for Foreman user accounts created in 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 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 Keycloak. For more information, see Creating New Users in the Red Hat Single Sign-On Server Administration Guide.

7.9.2. Registering Foreman as a Keycloak Client

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 the Foreman server, install the following packages:

    # apt-get install mod_auth_openidc keycloak-httpd-client-install
  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

7.9.3. Configuring the Foreman Client in Keycloak

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

Procedure
  1. In the Keycloak web UI, navigate to 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.

7.9.4. Configuring Foreman Settings for Keycloak Authentication

Use this section to configure Foreman for Keycloak authentication using the Foreman web UI or the CLI.

Configuring Foreman Settings for Keycloak Authentication Using the Web UI

Use this procedure to configure Foreman settings for 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

Prerequisite
  • Ensure that the Access Type setting in the Foreman client in the 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 Keycloak to RS256.

  6. Locate the OIDC Audience row, and in the Value column, set the value to the client ID for 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 Keycloak authentication source.

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

  12. Click Submit.

Configuring Foreman Settings for Keycloak Authentication Using the CLI

Use this procedure to configure Foreman settings for 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

Prerequisite
  • Ensure that the Access Type setting in the Foreman client in the 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 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 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 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

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

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

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

7.9.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, and click the Create User Group button.

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

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

  4. Select the Administer checkbox.

  5. Click the External Groups tab.

  6. Click Add external user group.

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

  8. From the list, select EXTERNAL.

7.10. Configuring Keycloak Authentication with PIV Cards

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

7.10.1. Prerequisites for Configuring Foreman with Keycloak Authentication

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

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

  • A Keycloak account with admin privileges.

  • A realm for Foreman user accounts created in 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 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 Keycloak. For more information, see Creating New Users in the Red Hat Single Sign-On Server Administration Guide.

7.10.2. Registering Foreman as a Keycloak Client

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 the Foreman server, install the following packages:

    # apt-get install mod_auth_openidc keycloak-httpd-client-install
  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

7.10.3. Configuring the Foreman Client in Keycloak

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

Procedure
  1. In the Keycloak web UI, navigate to 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.

7.10.4. Configuring Foreman Settings for Keycloak Authentication

Use this section to configure Foreman for Keycloak authentication using the Foreman web UI or the CLI.

Configuring Foreman Settings for Keycloak Authentication Using the Web UI

Use this procedure to configure Foreman settings for 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

Prerequisite
  • Ensure that the Access Type setting in the Foreman client in the 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 Keycloak to RS256.

  6. Locate the OIDC Audience row, and in the Value column, set the value to the client ID for 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 Keycloak authentication source.

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

  12. Click Submit.

Configuring Foreman Settings for Keycloak Authentication Using the CLI

Use this procedure to configure Foreman settings for 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

Prerequisite
  • Ensure that the Access Type setting in the Foreman client in the 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 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 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 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

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

7.10.6. 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 required packages:

    apt-get install opensc -y
  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.

7.10.7. Logging in to the Foreman web UI Using Keycloak PIV Cards

Use this procedure to log in to the Foreman web UI using the 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 Keycloak. Once authenticated, browser redirects you back to Foreman and logs you in.

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

7.10.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, and click the Create User Group button.

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

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

  4. Select the Administer checkbox.

  5. Click the External Groups tab.

  6. Click Add external user group.

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

  8. From the list, select EXTERNAL.

7.11. Disabling Keycloak Authentication

If you want to disable Keycloak authentication in Foreman, complete this procedure.

Procedure
  • Enter the following command to disable Keycloak Authentication:

    # foreman-installer --reset-foreman-keycloak

8. Monitoring Resources

The following chapter details how to configure monitoring and reporting for managed systems. This includes host configuration, content views, compliance, subscriptions, registered hosts, promotions and synchronization.

8.1. Using the Foreman Content Dashboard

The Foreman content dashboard contains various widgets which provide an overview of the host configuration, Content Views, compliance reports, subscriptions and hosts currently registered, promotions and synchronization, and a list of the latest notifications.

In the Foreman web UI, navigate to Monitor > Dashboard to access the content dashboard. The dashboard can be rearranged by clicking on a widget and dragging it to a different position. The following widgets are available:

Host Configuration Status

An overview of the configuration states and the number of hosts associated with it during the last reporting interval. The following table shows the descriptions of the possible configuration states.

Table 10. Host Configuration States
Icon State Description

host state config okay

Hosts that had performed modifications without error

Host that successfully performed modifications during the last reporting interval.

host state config error

Hosts in error state

Hosts on which an error was detected during the last reporting interval.

host state config report

Good host reports in the last 35 minutes

Hosts without error that did not perform any modifications in the last 35 minutes.

host state config pending

Hosts that had pending changes

Hosts on which some resources would be applied but Puppet was configured to run in the noop mode.

host state config outofsync

Out of sync hosts

Hosts that were not synchronized and the report was not received during the last reporting interval.

host state config noreport

Hosts with no reports

Hosts for which no reports were collected during the last reporting interval.

host state config noalert

Hosts with alerts disabled

Hosts which are not being monitored.

Click the particular configuration status to view hosts associated with it.

Host Configuration Chart

A pie chart shows the proportion of the configuration status and the percentage of all hosts associated with it.

Latest Events

A list of messages produced by hosts including administration information, product and subscription changes, and any errors.

Monitor this section for global notifications sent to all users and to detect any unusual activity or errors.

Run Distribution (last 30 minutes)

A graph shows the distribution of the running Puppet agents during the last puppet interval which is 30 minutes by default. In this case, each column represents a number of reports received from clients during 3 minutes.

New Hosts

A list of the recently created hosts. Click the host for more details.

Task Status

A summary of all current tasks, grouped by their state and result. Click the number to see the list of corresponding tasks.

Latest Warning/Error Tasks

A list of the latest tasks that have been stopped due to a warning or error. Click a task to see more details.

Discovered Hosts

A list of all bare-metal hosts detected on the provisioning network by the Discovery plug-in.

Latest Errata

A list of all errata available for hosts registered to Foreman.

Content Views

A list of all Content Views in Foreman and their publish status.

Sync Overview

An overview of all products or repositories enabled in Foreman and their synchronization status. All products that are in the queue for synchronization, are unsynchronized or have been previously synchronized are listed in this section.

Host Subscription Status

An overview of the subscriptions currently consumed by the hosts registered to Foreman. A subscription is a purchased certificate that unlocks access to software, upgrades, and security fixes for hosts. The following table shows the possible states of subscriptions.

Table 11. Host Subscription States
Icon State Description

host state sub invalid

Invalid

Hosts that have products installed, but are not correctly subscribed. These hosts need attention immediately.

host state sub partial

Partial

Hosts that have a subscription and a valid entitlement, but are not using their full entitlements. These hosts should be monitored to ensure they are configured as expected.

host state sub valid

Valid

Hosts that have a valid entitlement and are using their full entitlements.

Click the subscription type to view hosts associated with subscriptions of the selected type.

Subscription Status

An overview of the current subscription totals that shows the number of active subscriptions, the number of subscriptions that expire in the next 120 days, and the number of subscriptions that have recently expired.

Host Collections

A list of all host collections in Foreman and their status, including the number of content hosts in each host collection.

Virt-who Configuration Status

An overview of the status of reports received from the virt-who daemon running on hosts in the environment. The following table shows the possible states.

Table 12. Virt-who Configuration States
State Description

No Reports

No report has been received because either an error occurred during the virt-who configuration deployment, or the configuration has not been deployed yet, or virt-who cannot connect to Foreman during the scheduled interval.

No Change

No report has been received because hypervisor did not detect any changes on the virtual machines, or virt-who failed to upload the reports during the scheduled interval. If you added a virtual machine but the configuration is in the No Change state, check that virt-who is running.

OK

The report has been received without any errors during the scheduled interval.

Total Configurations

A total number of virt-who configurations.

Click the configuration status to see all configurations in this state.

The widget also lists the three latest configurations in the No Change state under Latest Configurations Without Change.

Latest Compliance Reports

A list of the latest compliance reports. Each compliance report shows a number of rules passed (P), failed (F), or othered (O). Click the host for the detailed compliance report. Click the policy for more details on that policy.

Compliance Reports Breakdown

A pie chart shows the distribution of compliance reports according to their status.

Red Hat Insights Actions

Red Hat Insights is a tool embedded in Foreman that checks the environment and suggests actions you can take. The actions are divided into 4 categories: Availability, Stability, Performance, and Security.

Red Hat Insights Risk Summary

A table shows the distribution of the actions according to the risk levels. Risk level represents how critical the action is and how likely it is to cause an actual issue. The possible risk levels are: Low, Medium, High, and Critical.

Note

It is not possible to change the date format displayed in the Foreman web UI.

8.1.1. Managing Tasks

Foreman keeps a complete log of all planned or performed tasks, such as repositories synchronised, errata applied, and Content Views published. To review the log, navigate to Monitor > Tasks.

In the Task window, you can search for specific tasks, view their status, details, and elapsed time since they started. You can also cancel and resume one or more tasks.

The tasks are managed using the Dynflow engine. Remote tasks have a timeout which can be adjusted as needed.

To Adjust Timeout Settings:
  1. In the Foreman web UI, navigate to Administer > Settings.

  2. Enter %_timeout in the search box and click Search. The search should return four settings, including a description.

  3. In the Value column, click the icon next to a number to edit it.

  4. Enter the desired value in seconds, and click Save.

Note

Adjusting the %_finish_timeout values might help in case of low bandwidth. Adjusting the %_accept_timeout values might help in case of high latency.

When a task is initialized, any back-end service that will be used in the task, such as Candlepin or Pulp, will be checked for correct functioning. If the check fails, you will receive an error similar to the following one:

There was an issue with the backend service candlepin: Connection refused – connect(2).

If the back-end service checking feature turns out to be causing any trouble, it can be disabled as follows.

To Disable Checking for Services:
  1. In the Foreman web UI, navigate to Administer > Settings.

  2. Enter check_services_before_actions in the search box and click Search.

  3. In the Value column, click the icon to edit the value.

  4. From the drop-down menu, select false.

  5. Click Save.

8.2. Configuring RSS Notifications

To view Foreman event notification alerts, click the Notifications icon in the upper right of the screen.

By default, the Notifications area displays RSS feed events published in the Foreman Blog.

The feed is refreshed every 12 hours and the Notifications area is updated whenever new events become available.

You can configure the RSS feed notifications by changing the URL feed. The supported feed format is RSS 2.0 and Atom. For an example of the RSS 2.0 feed structure, see the Foreman Blog feed. For an example of the Atom feed structure, see the Foreman blog feed.

To Configure RSS Feed Notifications:
  1. In the Foreman web UI, navigate to Administer > Settings and select the Notifications tab.

  2. In the RSS URL row, click the edit icon in the Value column and type the required URL.

  3. In the RSS enable row, click the edit icon in the Value column to enable or disable this feature.

8.3. Monitoring Foreman server

From the About page in Foreman web UI, you can find an overview of the following:

  • System Status, including Smart Proxies, Available Providers, Compute Resources, and Plug-ins

  • Support Information

  • System Information

  • Backend System Status

  • Installed Packages

To navigate to the About page:

  • In the upper right corner of Foreman web UI, click Administer > About.

Note

After Pulp failure, the status of Pulp might show OK instead of Error for up to 10 minutes due to synchronization delay.

8.4. Monitoring Smart Proxy server

The following section shows how to use the Foreman web UI to find Smart Proxy information valuable for maintenance and troubleshooting.

8.4.1. Viewing General Smart Proxy Information

In the Foreman web UI, navigate to Infrastructure > Smart Proxies to view a table of Smart Proxy servers registered to Foreman server. The information contained in the table answers the following questions:

Is Smart Proxy server running?

This is indicated by a green icon in the Status column. A red icon indicates an inactive Smart Proxy, use the service foreman-proxy restart command on Smart Proxy server to activate it.

What services are enabled on Smart Proxy server?

In the Features column you can verify if Smart Proxy for example provides a DHCP service or acts as a Pulp mirror. Smart Proxy features can be enabled during installation or configured in addition. For more information, see Installing Smart Proxy server.

What organizations and locations is Smart Proxy server assigned to?

A Smart Proxy server can be assigned to multiple organizations and locations, but only Smart Proxies belonging to the currently selected organization are displayed. To list all Smart Proxies, select Any Organization from the context menu in the top left corner.

After changing the Smart Proxy configuration, select Refresh from the drop-down menu in the Actions column to ensure the Smart Proxy table is up to date.

Click the Smart Proxy name to view further details. At the Overview tab, you can find the same information as in the Smart Proxy table. In addition, you can answer to the following questions:

Which hosts are managed by Smart Proxy server?

The number of associated hosts is displayed next to the Hosts managed label. Click the number to view the details of associated hosts.

How much storage space is available on Smart Proxy server?

The amount of storage space occupied by the Pulp content in /var/lib/pulp is displayed. Also the remaining storage space available on the Smart Proxy can be ascertained.

8.4.2. Monitoring Services

In the Foreman web UI, navigate to Infrastructure > Smart Proxies and click the name of the selected Smart Proxy. At the Services tab, you can find basic information on Smart Proxy services, such as the list of DNS domains, or the number of Pulp workers. The appearance of the page depends on what services are enabled on Smart Proxy server. Services providing more detailed status information can have dedicated tabs at the Smart Proxy page. For more information, see Monitoring Puppet.

8.4.3. Monitoring Puppet

In the Foreman web UI, navigate to Infrastructure > Smart Proxies and click the name of the selected Smart Proxy. At the Puppet tab you can find the following:

  • A summary of Puppet events, an overview of latest Puppet runs, and the synchronization status of associated hosts at the General sub-tab.

  • A list of Puppet environments at the Environments sub-tab.

At the Puppet CA tab you can find the following:

  • A certificate status overview and the number of autosign entries at the General sub-tab.

  • A table of CA certificates associated with the Smart Proxy at the Certificates sub-tab. Here you can inspect the certificate expiry data, or cancel the certificate by clicking Revoke.

  • A list of autosign entries at the Autosign entries sub-tab. Here you can create an entry by clicking New or delete one by clicking Delete.

9. Using Webhooks

A webhook is a way for a web page or web application to provide other applications with information in real time. Webhooks are only triggered after an event occurs. The request usually contains details of the event. An event triggers callbacks, such as sending an e-mail confirming a host has been provisioned. Webhooks enable you to define a call to an external API based on Foreman internal event using a fire-and-forget message exchange pattern. The application sending the request does not wait for the response, or ignores it.

Payload of a webhook is created from webhook templates. Webhook templates use the same ERB syntax as Provisioning templates. Available variables:

  • @event_name: Name of an event.

  • @webhook_id: Unique event ID.

  • @payload: Payload data, different for each event type. To access individual fields, use @payload[:key_name] Ruby hash syntax.

  • @payload[:object]: Database object for events triggered by database actions (create, update, delete). Not available for custom events.

  • @payload[:context]: Additional information as hash like request and session UUID, remote IP address, user, organization and location.

Because webhooks use HTTP, no new infrastructure needs be added to existing web services.

The typical use case for webhooks in Foreman is making a call to a monitoring system when a host is created or deleted.

Webhooks are useful where the action you want to perform in the external system can be achieved through its API. Where it is necessary to run additional commands or edit files, the shellhooks plugin for Smart Proxies is available. The shellhooks plugin enables you to define a shell script on the Smart Proxy that can be executed through the API.

You can use webhooks successfully without installing the shellhooks plugin.

For a list of available events, see Available webhook events.

9.1. Migrating to Webhooks

The legacy foreman_hooks plugin provided full access to model objects that the webhooks plugin does not intentionally provide.

The scope of what is available is limited by the safemode and all objects and macros are both subject to an API stability promise and are fully documented.

The number of events triggered by webhooks is substantially fewer than with foreman_hooks.

Webhooks are processed asynchronously so there is minimal risk of tampering with internals of the system. It is not possible to migrate from foreman_hooks without creating payloads for each individual webhook script. However, the webhooks plugin comes with several example payload templates. You can also use the example payloads with shellhooks to simplify migration.

Both script and payload templates must be customized to achieve similar results.

9.2. Installing Webhooks

Use the following procedure to install webhooks. After installing webhooks, you can configure Foreman server to send webhook requests.

Procedure
  • Install webhooks using the following command:

    # foreman-installer --enable-foreman-plugin-webhooks
  • Optional: you can install the CLI plugin using the following command:

    # foreman-installer --enable-foreman-cli-webhooks

9.3. Creating a Webhook Template

Webhook templates are used to generate the body of HTTP request to a configured target when a webhook is triggered. Use the following procedure to create a webhook template in the Foreman web UI.

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

  2. Click Clone an existing template or Create Template.

  3. Enter a name for the template.

  4. Use the editor to make changes to the template payload.

    A webhook HTTP payload must be created using Foreman template syntax. The webhook template can use a special variable called @object that can represent the main object of the event. @object can be missing in case of certain events. You can determine what data are actually available with the @payload variable.

    For more information, see Template Writing Reference in Managing Hosts and for available template macros and methods, visit /templates_doc on Foreman server.

  5. Optional: Enter the description and audit comment.

  6. Assign organizations and locations.

  7. Click Submit.

9.4. Creating a Webhook

You can customize events, payloads, HTTP authentication, content type, and headers through the Foreman web UI.

Use the following procedure to create a webhook in the Foreman web UI.

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

  2. Click Create new.

  3. From the Subscribe to list, select an event.

  4. Enter a Name for your webhook.

  5. Enter a Target URL. Webhooks make HTTP requests to pre-configured URLs. The target URL can be a dynamic URL.

  6. Click Template to select a template. Webhook templates are used to generate the body of the HTTP request to Foreman server when a webhook is triggered.

  7. Enter an HTTP method.

  8. Optional: If you do not want activate the webhook when you create it, uncheck the Enabled flag.

  9. Click the Credentials tab.

  10. Optional: If HTTP authentication is required, enter User and Password.

  11. Optional: Uncheck Verify SSL if you do not want to verify the server certificate against the system certificate store or Foreman CA.

  12. On the Additional tab, enter the HTTP Content Type. For example, application/json, application/xml or text/plain on the payload you define. The application does not attempt to convert the content to match the specified content type.

  13. Optional: Provide HTTP headers as JSON. ERB is also allowed.

9.5. Available Webhook Events

The following table contains a list of webhook events that are available from the Foreman web UI. Action events trigger webhooks only on success, so if an action fails, a webhook is not triggered.

For more information about payload, go to Administer > About > Support > Templates DSL. A list of available types is provided in the following table. Some events are marked as custom, in that case, the payload is an object object but a Ruby hash (key-value data structure) so syntax is different.

Event name Description Payload

Actions Katello Content View Promote Succeeded

A content view was successfully promoted.

Actions::Katello::ContentView::Promote

Actions Katello Content View Publish Succeeded

A repository was successfully synchronized.

Actions::Katello::ContentView::Publish

Actions Remote Execution Run Host Job Succeeded

A generic remote execution job succeeded for a host. This event is emitted for all Remote Execution jobs, when complete.

Actions::RemoteExecution::RunHostJob

Actions Remote Execution Run Host Job Katello Errata Install Succeeded

Install errata using the Katello interface.

Actions::RemoteExecution::RunHostJob

Actions Remote Execution Run Host Job Katello Group Install Succeeded

Install package group using the Katello interface.

Actions::RemoteExecution::RunHostJob

Actions Remote Execution Run Host Job Katello Package Install Succeeded

Install package using the Katello interface.

Actions::RemoteExecution::RunHostJob

Actions Remote Execution Run Host Job Katello Group Remove

Remove package group using the Katello interface.

Actions::RemoteExecution::RunHostJob

Actions Remote Execution Run Host Job Katello Package Remove Succeeded

Remove package using the Katello interface.

Actions::RemoteExecution::RunHostJob

Actions Remote Execution Run Host Job Katello Service Restart Succeeded

Restart Services using the Katello interface.

Actions::RemoteExecution::RunHostJob

Actions Remote Execution Run Host Job Katello Group Update Succeeded

Update package group using the Katello interface.

Actions::RemoteExecution::RunHostJob

Actions Remote Execution Run Host Job Katello Package Update Succeeded

Update package using the Katello interface.

Actions::RemoteExecution::RunHostJob

Actions Remote Execution Run Host Job Foreman OpenSCAP Run Scans Succeeded

Run OpenSCAP scan.

Actions::RemoteExecution::RunHostJob

Actions Remote Execution Run Host Job Ansible Run Host Succeeded

Runs an Ansible playbook containing all the roles defined for a host.

Actions::RemoteExecution::RunHostJob

Actions Remote Execution Run Host Job Ansible Run Capsule Upgrade Succeeded

Upgrade Capsules on given Capsule server hosts.

Actions::RemoteExecution::RunHostJob

Actions Remote Execution Run Host Job Ansible Configure Cloud Connector Succeeded

Configure Cloud Connector on given hosts.

Actions::RemoteExecution::RunHostJob

Actions Remote Execution Run Host Job Ansible Run Playbook Succeeded

Run an Ansible playbook against given hosts.

Actions::RemoteExecution::RunHostJob

Actions Remote Execution Run Host Job Ansible Enable Web Console Succeeded

Run an Ansible playbook to enable the web console on given hosts.

Actions::RemoteExecution::RunHostJob

Actions Remote Execution Run Host Job Puppet Run Host Succeeded

Perform a single Puppet run.

Actions::RemoteExecution::RunHostJob

Actions Remote Execution Run Host Job Katello Module Stream Action Succeeded

Perform a module stream action using the Katello interface.

Actions::RemoteExecution::RunHostJob

Actions Remote Execution Run Host Job Leapp Pre-upgrade Succeeded

Upgradeability check for RHEL 7 host.

Actions::RemoteExecution::RunHostJob

Actions Remote Execution Run Host Job Leapp Remediation Plan Succeeded

Run Remediation plan with Leapp.

Actions::RemoteExecution::RunHostJob

Actions Remote Execution Run Host Job Leapp Upgrade Succeeded

Run Leapp upgrade job for RHEL 7 host.

Actions::RemoteExecution::RunHostJob

Build Entered

A host entered the build mode.

Custom event: @payload[:id] (host id), @payload[:hostname] (host name).

Build Exited

A host build mode was canceled, either it was successfully provisioned or the user canceled the build manually.

Custom event: @payload[:id] (host id), @payload[:hostname] (host name).

Content View Created/Updated/Destroyed

Common database operations on a content view.

Katello::ContentView

Domain Created/Updated/Destroyed

Common database operations on a domain.

Domain

Host Created/Updated/Destroyed

Common database operations on a host.

Host

Hostgroup Created/Updated/Destroyed

Common database operations on a hostgroup.

Hostgroup

Model Created/Updated/Destroyed

Common database operations on a model.

Model

Status Changed

Global host status of a host changed.

Custom event: @payload[:id] (host id), @payload[:hostname], @payload[:global_status] (hash)

Subnet Created/Updated/Destroyed

Common database operations on a subnet.

Subnet

Template Render Performed

A report template was rendered.

Template

User Created/Updated/Destroyed

Common database operations on a user.

User

9.6. Shellhooks

With webhooks, you can only map one Foreman event to one API call. For advanced integrations, where a single shell script can contain multiple commands, you can install a Smart Proxy shellhooks plugin that exposes executables using a REST HTTP API.

You can then configure a webhook to reach out to a Smart Proxy API to run a predefined shellhook. A shellhook is an executable script that can be written in any language as long as it can be executed. The shellhook can for example contain commands or edit files.

You must place your executable scripts in /var/lib/foreman-proxy/shellhooks with only alphanumeric characters and underscores in their name.

You can pass input to shellhook script through the webhook payload. This input is redirected to standard input of the shellhook script. You can pass arguments to shellhook script using HTTP headers in format X-Shellhook-Arg-1 to X-Shellhook-Arg-99. For more information on passing arguments to shellhook script, see:

The HTTP method must be POST. An example URL would be: https://smartproxy.example.com:8443/shellhook/My_Script.

Note

Unlike the shellhooks directory, the URL must contain /shellhook/ in singular to be valid.

You must enable Smart Proxy Authorization for each webhook connected to a shellhook to enable it to authorize a call.

Standard output and standard error output are redirected to the Smart Proxy logs as messages with debug or warning levels respectively.

The shellhook HTTPS calls do not return a value.

For an example on creating a shellhook script, see Creating a Shellhook to Print Arguments.

9.7. Installing the Shellhooks Plugin

Optionally, you can install and enable the shellhooks plugin on each Smart Proxy used for shellhooks, using the following command:

# foreman-installer --enable-foreman-proxy-plugin-shellhooks

9.8. Passing Arguments to Shellhook Script Using Webhooks

Use this procedure to pass arguments to a shellhook script using webhooks.

Procedure
  • When creating a webhook, on the Additional tab, create HTTP headers in the following format:

    {
      "X-Shellhook-Arg-1": "VALUE",
      "X-Shellhook-Arg-2": "VALUE"
    }

    Ensure that the headers have a valid JSON or ERB format. Only pass safe fields like database ID, name, or labels that do not include new lines or quote characters.

    For more information, see Creating a Webhook.

Example
{
  "X-Shellhook-Arg-1": "<%= @object.content_view_version_id %>",
  "X-Shellhook-Arg-2": "<%= @object.content_view_name %>"
}

9.9. Passing Arguments to Shellhook Script Using Curl

Use this procedure to pass arguments to a shellhook script using curl.

Procedure
  • When executing a shellhook script using curl, create HTTP headers in the following format:

    "X-Shellhook-Arg-1: VALUE"
    "X-Shellhook-Arg-2: VALUE"
Example
# curl -sX POST -H 'Content-Type: text/plain' \
-H "X-Shellhook-Arg-1: Version 1.0" \
-H "X-Shellhook-Arg-2: My Content View" \
--data "" https://smartproxy.example.com:8443/shellhook/My_Script

9.10. Creating a Shellhook to Print Arguments

Create a simple shellhook script that prints "Hello World!" when you run a remote execution job.

Prerequisite
Procedure
  1. Modify the /var/lib/foreman-proxy/shellhooks/print_args script to print arguments to standard error output so you can see them in the Smart Proxy logs:

    #!/bin/sh
    #
    # Prints all arguments to stderr
    #
    echo "$@" >&2
  2. In the Foreman web UI, navigate to Administer > Webhooks.

  3. Click Create new.

  4. From the Subscribe to list, select Actions Remote Execution Run Host Job Succeeded.

  5. Enter a Name for your webhook.

  6. In the Target URL field, enter the URL of your Smart Proxy server followed by :8443/shellhook/print_args:

    https://smartproxy.example.com:8443/shellhook/print_args

    Note that shellhook in the URL is singular, unlike the shellhooks directory.

  7. From the Template list, select Empty Payload.

  8. On the Credentials tab, check Smart Proxy Authorization.

  9. On the Additional tab, enter the following text in the Optional HTTP headers field:

    {
        "X-Shellhook-Arg-1": "Hello",
        "X-Shellhook-Arg-2": "World!"
    }
  10. Click Submit. You now have successfully created a shellhook that prints "Hello World!" to Smart Proxy logs every time you a remote execution job succeeds.

Verification
  1. Run a remote execution job on any host. You can use time as a command. For more information, see Executing a Remote Job in Managing Hosts.

  2. Verify that the shellhook script was triggered and printed "Hello World!" to Smart Proxy server logs:

    # tail /var/log/foreman-proxy/proxy.log

    You should find the following lines at the end of the log:

    [I] Started POST /shellhook/print_args
    [I] Finished POST /shellhook/print_args with 200 (0.33 ms)
    [I] [3520] Started task /var/lib/foreman-proxy/shellhooks/print_args\ Hello\ World\!
    [W] [3520] Hello World!

10. Searching and Bookmarking

Foreman features powerful search functionality on most pages of the Foreman web UI. It enables you to search all kinds of resources that Foreman manages. Searches accept both free text and syntax-based queries, which can be built using extensive input prediction. Search queries can be saved as bookmarks for future reuse.

10.1. Building Search Queries

As you start typing a search query, a list of valid options to complete the current part of the query appears. You can either select an option from the list and keep building the query using the prediction, or continue typing. To learn how free text is interpreted by the search engine, see Using Free Text Search.

10.1.1. Query Syntax

parameter operator value

Available fields, resources to search, and the way the query is interpreted all depend on context, that is, the page where you perform the search. For example, the field "hostgroup" on the Hosts page is equivalent to the field "name" on the Host Groups page. The field type also determines available operators and accepted values.

For a list of all operators, see Operators. For descriptions of value formats, see Values.

10.1.2. Query Operators

All operators that can be used between parameter and value are listed in the following table. Other symbols and special characters that might appear in a prediction-built query, such as colons, do not have special meaning and are treated as free text.

Table 13. Comparison Operators Accepted by Search
Operator Short Name Description Example

=

EQUALS

Accepts numerical, temporal, or text values. For text, exact case sensitive matches are returned.

hostgroup = RHEL7

!=

NOT EQUALS

~

LIKE

Accepts text or temporal values. Returns case insensitive matches. Accepts the following wildcards: _ for a single character, % or * for any number of characters including zero. If no wildcard is specified, the string is treated as if surrounded by wildcards: %rhel7%

hostgroup ~ rhel%

!~

NOT LIKE

>

GREATER THAN

Accepts numerical or temporal values. For temporal values, the operator > is interpreted as "later than", and < as "earlier than". Both operators can be combined with EQUALS: >= <=

registered_at > 10-January-2017
The search will return hosts that have been registered after the given date, that is, between 10th January 2017 and now.

registered_at <= Yesterday
The search will return hosts that have been registered yesterday or earlier.

<

LESS THAN

^

IN

Compares an expression against a list of values, as in SQL. Returns matches that contain or not contain the values, respectively.

release_version !^ 7

!^

NOT IN

HAS or set?

 

Returns values that are present or not present, respectively.

has hostgroup or set? hostgroup
On the Puppet Classes page, the search will return classes that are assigned to at least one host group.

not has hostgroup or null? hostgroup
On the Dashboard with an overview of hosts, the search will return all hosts that have no assigned host group.

NOT HAS or null?

 

Simple queries that follow the described syntax can be combined into more complex ones using logical operators AND, OR, and NOT. Alternative notations of the operators are also accepted:

Table 14. Logical Operators Accepted by Search
Operator Alternative Notations Example

and

&

&&

<whitespace>

class = motd AND environment ~ production

or

|

||

 

errata_status = errata_needed || errata_status = security_needed

not

!

 

hostgroup ~ rhel7 not status.failed

10.1.3. Query Values

Text Values

Text containing whitespaces must be enclosed in quotes. A whitespace is otherwise interpreted as the AND operator.

Examples:

hostgroup = "Web servers"

The search will return hosts with assigned host group named "Web servers".

hostgroup = Web servers

The search will return hosts in the host group Web with any field matching %servers%.

Temporal Values

Many date and time formats are accepted, including the following:

  • "10 January 2017"

  • "10 Jan 2017"

  • 10-January-2017

  • 10/January/2017

  • "January 10, 2017"

  • Today, Yesterday, and the like.

Warning

Avoid ambiguous date formats, such as 02/10/2017 or 10-02-2017.

10.2. Using Free Text Search

When you enter free text, it will be searched for across multiple fields. For example, if you type "64", the search will return all hosts that have that number in their name, IP address, MAC address, and architecture.

Note

Multi-word queries must be enclosed in quotes, otherwise the whitespace is interpreted as the AND operator.

Because of searching across all fields, free text search results are not very accurate and searching can be slow, especially on a large number of hosts. For this reason, we recommend that you avoid free text and use more specific, syntax-based queries whenever possible.

10.3. Managing Bookmarks

You can save search queries as bookmarks for reuse. You can also delete or modify a bookmark.

Bookmarks appear only on the page on which they were created. On some pages, there are default bookmarks available for the common searches, for example, all active or disabled hosts.

10.3.1. Creating Bookmarks

This section details how to save a search query as a bookmark. You must save the search query on the relevant page to create a bookmark for that page, for example, saving a host related search query on the Hosts page.

Procedure
  1. In the Foreman web UI, navigate to the page where you want to create a bookmark.

  2. In the Search field, enter the search query you want to save.

  3. Select the arrow to the right of the Search button and then select Bookmark this search.

  4. In the Name field, enter a name for the new bookmark.

  5. In the Search query field, ensure your search query is correct.

  6. Ensure the Public checkbox is set correctly:

    • Select the Public checkbox to set the bookmark as public and visible to all users.

    • Clear the Public checkbox to set the bookmark as private and only visible to the user who created it.

  7. Click Submit.

To confirm the creation, either select the arrow to the right of the Search button to display the list of bookmarks, or navigate to Administer > Bookmarks and then check the Bookmarks list for the name of the bookmark.

10.3.2. Deleting Bookmarks

You can delete bookmarks on the Bookmarks page.

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

  2. On the Bookmarks page, click Delete for the Bookmark you want to delete.

  3. When the confirmation window opens, click OK to confirm the deletion.

To confirm the deletion, check the Bookmarks list for the name of the bookmark.

Appendix A: Administration Settings

This section contains information about settings that you can edit in the Foreman web UI by navigating to Administer > Settings.

A.1. General Settings

Setting Default Value Description

Administrator email address

The default administrator email address

Foreman URL

URL where your Foreman instance is reachable. See also Provisioning > Unattended URL.

Entries per page

20

Number of records shown per page in Foreman

Fix DB cache

No

Foreman maintains a cache of permissions and roles. When set to Yes, Foreman recreates this cache on the next restart.

DB pending seed

No

Should the foreman-rake db:seed be executed on the next run of the installer modules?

Smart Proxy request timeout

60

Open and read timeout for HTTP requests from Foreman to Smart Proxy (in seconds).

Login page footer text

Text to be shown in the login-page footer.

Show host power status

Yes

Show power status on the host index page. This feature calls to compute resource providers which may lead to decreased performance on the host listing page.

HTTP(S) proxy

Set a proxy for outgoing HTTP(S) connections from the Foreman product. System-wide proxies must be configured at the operating system level.

HTTP(S) proxy except hosts

[]

Set hostnames to which requests are not to be proxied. Requests to the local host are excluded by default.

Show Experimental Labs

No

Whether or not to show a menu to access experimental lab features (requires reload of page).

Append domain names to the host

Yes

If set to Yes, Foreman appends domain names when new hosts are provisioned.

Out of sync interval

30

Managed hosts report periodically, and if the time between reports exceeds this duration in minutes, hosts are considered out of sync. You can override this on your hosts by adding the outofsync_interval parameter, per host, at Hosts > All hosts > $host > Edit > Parameters > Add Parameter.

Foreman UUID

Foreman instance ID. Uniquely identifies a Foreman instance.

Default language

The UI for new users uses this language.

Default timezone

The timezone to use for new users.

Instance title

The instance title is shown on the top navigation bar (requires a page reload).

Saved audits interval

Duration in days to preserve audit data. Leave empty to disable the audits cleanup.

New host details UI

Yes

Foreman loads the new UI for host details.

A.2. Tasks settings

Setting Default Value Description

Sync task timeout

120

Number of seconds to wait for a synchronous task to finish before an exception is raised.

Enable dynflow console

Yes

Enable the dynflow console (/foreman_tasks/dynflow) for debugging.

Require auth for dynflow console

Yes

The user must be authenticated as having administrative rights before accessing the dynflow console.

Proxy action retry count

4

Number of attempts permitted to start a task on the Smart Proxy before failing.

Proxy action retry interval

15

Time in seconds between retries.

Allow proxy batch tasks

Yes

Allow triggering tasks on the Smart Proxy in batches.

Proxy tasks batch size

100

Number of tasks included in one request to the Smart Proxy if foreman_tasks_proxy_batch_trigger is enabled.

Tasks troubleshooting URL

URL pointing to the task troubleshooting documentation. It should contain a %{label} placeholder that is replaced with a normalized task label (restricted to only alphanumeric characters)). A %{version} placeholder is also available.

Polling intervals multiplier

1

Polling multiplier used to multiply the default polling intervals. You can use this to prevent polling too frequently for long running tasks.

A.3. Template Sync Settings

Setting Default Value Description

Associate

New

Associate templates with OS, organization and location.

Branch

Default branch in Git repo.

Commit message

Templates export made by a Foreman user

Custom commit message for exported templates.

Dirname

/

The directory within the Git repo containing the templates.

Filter

Import or export of names matching this regex. Case-insensitive. Snippets are not filtered.

Force import

No

If set to Yes, locked templates are overwritten during an import.

Lock templates

Keep, do not lock new

How to handle lock for imported templates.

Metadata export mode

Refresh

Default metadata export mode.

Possible options:

refresh re-renders metadata.

keep keeps existing metadata.

remove exports the template without metadata.

Negate

No

Negate the filter for import or export.

Prefix

A string added as a prefix to imported templates.

Repo

Target path from where to import or export templates. Different protocols can be used, for example:

/tmp/dir

git://example.com

https://example.com

ssh://example.com

When exporting to /tmp, note that production deployments may be configured to use private tmp.

Verbosity

No

Choose verbosity for Rake task importing templates.

A.4. Discovered Settings

Setting Default Value Description

Discovery location

Indicates the default location to place discovered hosts in.

Discovery organization

Indicates the default organization to which discovered hosts are added.

Interface fact

discovery_bootif

Fact name to use for primary interface detection.

Create bond interfaces

No

Automatically create a bond interface if another interface is detected on the same VLAN using LLDP.

Clean all facts

No

Clean all reported facts (except discovery facts) during provisioning.

Hostname facts

discovery_bootif

List of facts to use for the hostname (comma separated, first wins).

Auto provisioning

No

Use the provisioning rules to automatically provision newly discovered hosts.

Reboot

Yes

Automatically reboot or kexec discovered hosts during provisioning.

Hostname prefix

mac

The default prefix to use for the hostname. Must start with a letter.

Fact columns

Extra facter columns to show in host lists (comma separated).

Highlighted facts

Regex to organize facts for highlights section – e.g. ^(abc|cde)$.

Storage facts

Regex to organize facts for the storage section.

Software facts

Regex to organize facts for the software section.

Hardware facts

Regex to organize facts for the hardware section.

Network facts

Regex to organize facts for the network section.

IPMI facts

Regex to organize facts for the Intelligent Platform Management Interface (IPMI) section.

Lock PXE

No

Automatically generate a Preboot Execution Environment (PXE) configuration to pin a newly discovered host to discovery.

Locked PXELinux template name

pxelinux_discovery

PXELinux template to be used when pinning a host to discovery.

Locked PXEGrub template name

pxegrub_discovery

PXEGrub template to be used when pinning a host to discovery.

Locked PXEGrub2 template name

pxegrub2_discovery

PXEGrub2 template to be used when pinning a host to discovery.

Force DNS

Yes

Force the creation of DNS entries when provisioning a discovered host.

Error on existing NIC

No

Do not permit to discover an existing managed host matching the MAC of a provisioning Network Interface Card (NIC) (errors out early).

Type of name generator

Fact + prefix

Discovery hostname naming pattern.

Prefer IPv6

No

Prefer IPv6 to IPv4 when calling discovered nodes.

A.5. Boot Disk Settings

Setting Default Value Description

iPXE directory

/usr/share/ipxe

Path to directory containing iPXE images.

ISOLINUX directory

/usr/share/syslinux

Path to directory containing ISOLINUX images.

SYSLINUX directory

/usr/share/syslinux

Path to directory containing SYSLINUX images.

Grub2 directory

/var/lib/tftpboot/grub2

Path to directory containing grubx64.efi and shimx64.efi.

Host image template

Boot disk iPXE - host

iPXE template to use for host-specific boot disks.

Generic image template

Boot disk iPXE - generic host

iPXE template to use for generic host boot disks.

Generic Grub2 EFI image template

Boot disk Grub2 EFI - generic host

Grub2 template to use for generic Extensible Firmware Interface (EFI) host boot disks.

ISO generation command

genisoimage

Command to generate ISO image, use genisoimage or mkisofs.

Installation media caching

Yes

Installation media files are cached for full host images.

Allowed bootdisk types

[generic, host, full_host, subnet]

List of permitted bootdisk types. Leave blank to disable it.

A.6. Content Settings

Setting Default Value Description

Default HTTP Proxy

Default HTTP Proxy for syncing content.

CDN SSL version

SSL version used to communicate with the CDN.

Default synced OS provisioning template

Kickstart default

Default provisioning template for operating systems created from synced content.

Default synced OS finish template

Kickstart default finish

Default finish template for new operating systems created from synced content.

Default synced OS user-data

Kickstart default user data

Default user data for new operating systems created from synced content.

Default synced OS PXELinux template

Kickstart default PXELinux

Default PXELinux template for new operating systems created from synced content.

Default synced OS PXEGrub template

Kickstart default PXEGrub

Default PXEGrub template for new operating systems created from synced content.

Default synced OS PXEGrub2 template

Kickstart default PXEGrub2

Default PXEGrub2 template for new operating systems created from synced content.

Default synced OS iPXE template

Kickstart default iPXE

Default iPXE template for new operating systems created from synced content.

Default synced OS partition table

Kickstart default

Default partitioning table for new operating systems created from synced content.

Default synced OS kexec template

Discovery Foreman community kexec

Default kexec template for new operating systems created from synced content.

Default synced OS Atomic template

Atomic Kickstart default

Default provisioning template for new atomic operating systems created from synced content.

Manifest refresh timeout

1200

Timeout when refreshing a manifest (in seconds).

Accept action timeout

20

Time in seconds to wait for a host to pick up a remote action.

Finish action timeout

3600

Time in seconds to wait for a host to finish a remote action.

Subscription connection enabled

Yes

Can communicate with the Foreman community Portal for subscriptions.

Installable errata from Content View

No

Calculate errata host status based only on errata in a host’s Content View and Lifecycle Environment.

Restrict Composite Content View promotion

No

If this is enabled, a composite content view cannot be published or promoted, unless the component content view versions that it includes exist in the target environment.

Check services before actions

Yes

Check the status of backend services such as pulp and candlepin before performing actions?

Batch size to sync repositories in

100

How many repositories should be synced concurrently on a Smart Proxy. A smaller number may lead to longer sync times. A larger number will increase dynflow load.

Sync Smart Proxies after Content View promotion

Yes

Whether or not to auto sync Smart Proxies after a Content View promotion.

Default Custom Repository download policy

immediate

Default download policy for custom repositories. Either immediate or on_demand.

Default Foreman community Repository download policy

on_demand

Default download policy for enabled Foreman community repositories. Either immediate or on_demand.

Default Smart Proxy download policy

on_demand

Default download policy for Smart Proxy syncs. Either inherit, immediate, or on_demand.

Pulp export destination filepath

/var/lib/pulp/katello-export

On-disk location for exported repositories.

Pulp 3 export destination filepath

/var/lib/pulp/exports

On-disk location for Pulp 3 exported repositories.

Pulp client key

/etc/pki/katello/private/pulp-client.key

Path for SSL key used for Pulp server authentication.

Pulp client cert

/etc/pki/katello/certs/pulp-client.crt

Path for SSL certificate used for Pulp server authentication.

Sync Connection Timeout

300

Total timeout in seconds for connections when syncing.

Use remote execution by default

No

If enabled, remote execution is used instead of katello-agent for remote actions.

Delete Host upon unregister

No

When unregistering a host using subscription-manager, also delete the host record. Managed resources linked to the host such as virtual machines and DNS records might also be deleted.

Subscription manager name registration fact

When registering a host using subscription-manager, force use the specified fact for the host name (in the form of fact.fact).

Subscription manager name registration fact strict matching

No

If this is enabled, and register_hostname_fact is set and provided, registration looks for a new host by name only using that fact, and skips all hostname matching.

Default Location subscribed hosts

Default Location

Default location where new subscribed hosts are stored after registration.

Expire soon days

120

The number of days remaining in a subscription before you are reminded about renewing it.

Content View Dependency Solving Default

No

The default dependency solving value for new content views.

Host Duplicate DMI UUIDs

[]

If hosts fail to register because of duplicate Desktop Management Interface (DMI) UUIDs, add their comma-separated values here. Subsequent registrations generate a unique DMI UUID for the affected hosts.

Host Profile Assume

Yes

Enable new host registrations to assume registered profiles with matching hostname as long as the registering DMI UUID is not used by another host.

Host Profile Can Change In Build

No

Enable host registrations to bypass Host Profile Assume as long as the host is in build mode.

Host Can Re-Register Only In Build

No

Enable hosts to re-register only when they are in build mode.

Host Tasks Workers Pool Size

5

Number of workers in the pool to handle the execution of host-related tasks. When set to 0, the default queue is used. Restart of the dynflowd/foreman-tasks service is required.

Applicability Batch Size

50

Number of host applicability calculations to process per task.

Autosearch

Yes

For pages that support it, automatically perform the search while typing in search input.

Autosearch delay

500

If Autosearch is enabled, delay in milliseconds before executing searches while typing.

Pulp bulk load size

2000

The number of items fetched from a single paged Pulp API call.

Upload profiles without Dynflow

Yes

Enable Katello to update host installed packages, enabled repositories, and module inventory directly instead of wrapped in Dynflow tasks (try turning off if Puma processes are using too much memory).

Orphaned Content Protection Time

1440

Time in minutes to consider orphan content as orphaned.

Prefer registered through proxy for remote execution

No

Prefer using a proxy to which a host is registered when using remote execution.

Allow deleting repositories in published content views

Yes

Enable removal of repositories that the user has previously published in one or more Content View versions.

A.7. Authentication Settings

Setting Default Value Description

OAuth active

Yes

Foreman will use OAuth for API authorization.

OAuth consumer key

*****

OAuth consumer key.

OAuth consumer secret

*****

OAuth consumer secret.

OAuth map users

No

Foreman maps users by username in the request-header. If this is disabled, OAuth requests have administrator rights.

Failed login attempts limit

30

Foreman blocks user logins from an incoming IP address for 5 minutes after the specified number of failed login attempts. Set to 0 to disable brute force protection.

Restrict registered Smart Proxies

Yes

Only known Smart Proxies can access features that use Smart Proxy authentication.

Trusted hosts

[]

List of hostnames, IPv4, IPv6 addresses or subnets to be trusted in addition to Smart Proxies for access to fact/report importers and ENC output.

SSL certificate

/etc/foreman/client_cert.pem

SSL Certificate path that Foreman uses to communicate with its proxies.

SSL CA file

/etc/foreman/proxy_ca.pem

SSL CA file path that Foreman uses to communicate with its proxies.

SSL private key

/etc/foreman/client_key.pem

SSL Private Key path that Foreman uses to communicate with its proxies.

SSL client DN env

HTTP_SSL_CLIENT_S_DN

Environment variable containing the subject DN from a client SSL certificate.

SSL client verify env

HTTP_SSL_CLIENT_VERIFY

Environment variable containing the verification status of a client SSL certificate.

SSL client cert env

HTTP_SSL_CLIENT_CERT

Environment variable containing a client’s SSL certificate.

Server CA file

SSL CA file path used in templates to verify the connection to Foreman.

Websockets SSL key

etc/pki/katello/private/katello-apache.key

Private key file path that Foreman uses to encrypt websockets.

Websockets SSL certificate

/etc/pki/katello/certs/katello-apache.crt

Certificate path that Foreman uses to encrypt websockets.

Websockets encryption

Yes

VNC/SPICE websocket proxy console access encryption (websockets_ssl_key/cert setting required).

Login delegation logout URL

Redirect your users to this URL on logout. Enable Authorize login delegation also.

Authorize login delegation auth source user autocreate

External

Name of the external authentication source where unknown externally authenticated users (see Authorize login delegation) are created. Empty means no autocreation.

Authorize login delegation

No

Authorize login delegation with REMOTE_USER HTTP header.

Authorize login delegation API

No

Authorize login delegation with REMOTE_USER HTTP header for API calls too.

Idle timeout

60

Log out idle users after the specified number of minutes.

BCrypt password cost

9

Cost value of bcrypt password hash function for internal auth-sources (4 – 30). A higher value is safer but verification is slower, particularly for stateless API calls and UI logins. A password change is needed to affect existing passwords.

BMC credentials access

Yes

Permits access to BMC interface passwords through ENC YAML output and in templates.

OIDC JWKs URL

OpenID Connect JSON Web Key Set (JWKS) URL. Typically https://keycloak.example.com/auth/realms/<realm name>/protocol/openid-connect/certs when using Keycloak as an OpenID provider.

OIDC Audience

[]

Name of the OpenID Connect Audience that is being used for authentication. In the case of Keycloak this is the Client ID.

OIDC Issuer

The issuer claim identifies the principal that issued the JSON Web tokens (JWT), which exists at a /.well-known/openid-configuration in case of most of the OpenID providers.

OIDC Algorithm

The algorithm used to encode the JWT in the OpenID provider.

A.8. Email Settings

Setting Default Value Description

Email reply address

Email reply address for emails that Foreman is sending.

Email subject prefix

Prefix to add to all outgoing email.

Send welcome email

No

Send a welcome email including username and URL to new users.

Delivery method

Sendmail

Method used to deliver email.

SMTP enable StartTLS auto

Yes

SMTP automatically enables StartTLS.

SMTP OpenSSL verify mode

Default verification mode

When using TLS, you can set how OpenSSL checks the certificate.

SMTP address

SMTP address to connect to.

SMTP port

25

SMTP port to connect to.

SMTP HELO/EHLO domain

HELO/EHLO domain.

SMTP username

Username to use to authenticate, if required.

SMTP password

*****

Password to use to authenticate, if required.

SMTP authentication

none

Specify authentication type, if required.

Sendmail arguments

-i

Specify additional options to sendmail. Only used when the delivery method is set to sendmail.

Sendmail location

/usr/sbin/sendmail

The location of the sendmail executable. Only used when the delivery method is set to sendmail.

A.9. Notifications Settings

Setting Default Value Description

RSS enable

Yes

Pull RSS notifications.

RSS URL

https://theforeman.org/feed.xml

URL from which to fetch RSS notifications.

A.10. Provisioning Settings

Setting Default Value Description

Host owner

Default owner on provisioned hosts, if empty Foreman uses the current user.

Root password

*****

Default encrypted root password on provisioned hosts.

Unattended URL

URL that hosts retrieve templates from during the build. When it starts with https, unattended, or userdata, controllers cannot be accessed using HTTP.

Safemode rendering

Yes

Enables safe mode rendering of provisioning templates. The default and recommended option Yes denies access to variables and any object that is not listed in Foreman.

When set to No, any object may be accessed by a user with permission to use templating features, either by editing templates, parameters or smart variables. This permits users full remote code execution on Foreman server, effectively disabling all authorization. This is not a safe option, especially in larger companies.

Access unattended without build

No

Enable access to unattended URLs without build mode being used.

Query local nameservers

No

Foreman queries the locally configured resolver instead of the SOA/NS authorities.

Installation token lifetime

360

Time in minutes that installation tokens should be valid for. Set to 0 to disable the token.

SSH timeout

120

Time in seconds before SSH provisioning times out.

Libvirt default console address

0.0.0.0

The IP address that should be used for the console listen address when provisioning new virtual machines using libvirt.

Update IP from built request

No

Foreman updates the host IP with the IP that made the build request.

Use short name for VMs

No

Foreman uses the short hostname instead of the FQDN for creating new virtual machines.

DNS timeout

[5, 10, 15, 20]

List of timeouts (in seconds) for DNS lookup attempts such as the dns_lookup macro and DNS record conflict validation.

Clean up failed deployment

Yes

Foreman deletes the virtual machine if the provisioning script ends with a non-zero exit code.

Type of name generator

Random-based

Specifies the method used to generate a hostname when creating a new host.

The default Random-based option generates a unique random hostname which you can but do not have to use. This is useful for users who create many hosts and do not know how to name them.

The MAC-based option is for bare-metal hosts only. If you delete a host and create it later on, it receives the same hostname based on the MAC address. This can be useful for users who recycle servers and want them to always get the same hostname.

The Off option disables the name generator function and leaves the hostname field blank.

Default PXE global template entry

Default PXE menu item in a global template – local, discovery or custom, use blank for template default.

Default PXE local template entry

Default PXE menu item in local template – local, local_chain_hd0, or custom, use blank for template default.

iPXE intermediate script

iPXE intermediate script

Intermediate iPXE script for unattended installations.

Destroy associated VM on host delete

No

Destroy associated VM on host delete. When enabled, VMs linked to hosts are deleted on Compute Resource. When disabled, VMs are unlinked when the host is deleted, meaning they remain on Compute Resource and can be re-associated or imported back to Foreman again. This does not automatically power off the VM

Maximum structured facts

100

Maximum number of keys in structured subtree, statistics stored in foreman::dropped_subtree_facts.

Default Global registration template

Global Registration

Global Registration template.

Default 'Host initial configuration' template

Linux host_init_config default

Default 'Host initial configuration' template, automatically assigned when a new operating system is created.

CoreOS Transpiler Command

[false, --pretty, --files-dir, /usr/share/foreman/config/ct]

Full path to CoreOS transpiler (ct) with arguments as an comma-separated array

Fedora CoreOS Transpiler Command

[false, --pretty, --files-dir, /usr/share/foreman/config/ct]

Full path to Fedora CoreOS transpiler (fcct) with arguments as an comma-separated array

Global default PXEGrub2 template

PXEGrub2 global default

Global default PXEGrub2 template. This template is deployed to all configured TFTP servers. It is not affected by upgrades.

Global default PXELinux template

PXELinux global default

Global default PXELinux template. This template is deployed to all configured TFTP servers. It is not affected by upgrades.

Global default PXEGrub template

PXEGrub global default

Global default PXEGrub template. This template is deployed to all configured TFTP servers. It is not affected by upgrades.

Global default iPXE template

iPXE global default

Global default iPXE template. This template is deployed to all configured TFTP servers. It is not affected by upgrades.

Local boot PXEGrub2 template

PXEGrub2 default local boot

Template that is selected as PXEGrub2 default for local boot.

Local boot PXELinux template

PXELinux default local boot

Template that is selected as PXELinux default for local boot.

Local boot PXEGrub template

PXEGrub default local boot

Template that is selected as PXEGrub default for local boot.

Local boot iPXE template

iPXE default local boot

Template that is selected as iPXE default for local boot.

Manage PuppetCA

Yes

Foreman automates certificate signing upon provision of a new host.

Use UUID for certificates

No

Foreman uses random UUIDs for certificate signing instead of hostnames.

A.11. Facts Settings

Setting Default Value Description

Create new host when facts are uploaded

Yes

Foreman creates the host when new facts are received.

Location fact

foreman_location

Hosts created after a Puppet run are placed in the location specified by this fact.

Organization fact

foreman_organization

Hosts created after a Puppet run are placed in the organization specified by this fact. The content of this fact should be the full label of the organization.

Default location

Default Location

Hosts created after a Puppet run that did not send a location fact are placed in this location.

Default organization

Default Organization

Hosts created after a Puppet run that did not send an organization fact are placed in this organization.

Update hostgroup from facts

Yes

Foreman updates a host’s hostgroup from its facts.

Ignore facts for operating system

No

Stop updating operating system from facts.

Ignore facts for domain

No

Stop updating domain values from facts.

Update subnets from facts

None

Foreman updates a host’s subnet from its facts.

Ignore interfaces facts for provisioning

No

Stop updating IP and MAC address values from facts (affects all interfaces).

Ignore interfaces with matching identifier

[lo, en*v*, usb*, vnet*, macvtap*, ;vdsmdummy;, veth*, tap*, qbr*, qvb*, qvo*, qr-*, qg-*, vlinuxbr*, vovsbr*, br-int]

Skip creating or updating host network interfaces objects with identifiers matching these values from incoming facts. You can use a * wildcard to match identifiers with indexes, e.g. macvtap*. The ignored interface raw facts are still stored in the database, see the Exclude pattern setting for more details.

Exclude pattern for facts stored in satellite

[lo, en*v*, usb*, vnet*, macvtap*, ;vdsmdummy;, veth*, tap*, qbr*, qvb*, qvo*, qr-*, qg-*, vlinuxbr*, vovsbr*, br-int, load_averages::*, memory::swap::available*, memory::swap::capacity, memory::swap::used*, memory::system::available*, memory::system::capacity, memory::system::used*, memoryfree, memoryfree_mb, swapfree, swapfree_mb, uptime_hours, uptime_days]

Exclude pattern for all types of imported facts (Puppet, Ansible, rhsm). Those facts are not stored in the foreman database. You can use a * wildcard to match names with indexes, e.g. ignore* filters out ignore, ignore123 as well as a::ignore or even a::ignore123::b.

Default Puppet environment

production

Foreman defaults to this puppet environment if it cannot auto detect one.

ENC environment

Yes

Foreman explicitly sets the puppet environment in the ENC yaml output. This avoids conflicts between the environment in puppet.conf and the environment set in Foreman.

Update environment from facts

No

Foreman updates a host’s environment from its facts.

A.12. Configuration Management Settings

Setting Default Value Description

Create new host when report is uploaded

Yes

Foreman creates the host when a report is received.

Matchers inheritance

Yes

Foreman matchers are inherited by children when evaluating smart class parameters for hostgroups, organizations, and locations.

Default parameters lookup path

[fqdn, hostgroup, os, domain]

Foreman evaluates host smart class parameters in this order by default.

Interpolate ERB in parameters

Yes

Foreman parses ERB in parameters value in the ENC output.

Always show configuration status

No

All hosts show a configuration status even when a Puppet Smart Proxy is not assigned.

Puppet interval

35

Duration in minutes after servers reporting using Puppet are classed as out of sync.

Puppet out of sync disabled

No

Disable host configuration status turning to out of sync for Puppet after report does not arrive within configured interval.

A.13. Remote Execution Settings

Setting Default Value Description

Fallback to Any Proxy

No

Search the host for any proxy with Remote Execution. This is useful when the host has no subnet or the subnet does not have an execution proxy.

Enable Global Proxy

Yes

Search for Remote Execution proxy outside of the proxies assigned to the host. The search is limited to the host’s organization and location.

SSH User

root

Default user to use for SSH. You can override per host by setting the remote_execution_ssh_user parameter.

Effective User

root

Default user to use for executing the script. If the user differs from the SSH user, su or sudo is used to switch the user.

Effective User Method

sudo

The command used to switch to the effective user. One of [sudo, dzdo, su]

Effective user password

*****

Effective user password. See Effective User.

Sync Job Templates

Yes

Whether to sync templates from disk when running db:seed.

SSH Port

22

Port to use for SSH communication. Default port 22. You can override per host by setting the remote_execution_ssh_port parameter.

Connect by IP

No

Whether the IP addresses on host interfaces are preferred over the FQDN. It is useful when the DNS is not resolving the FQDNs properly. You can override this per host by setting the remote_execution_connect_by_ip parameter. For dual-stacked hosts, consider the remote_execution_connect_by_ip_prefer_ipv6 setting.

Prefer IPv6 over IPv4

No

When connecting using an IP address, are IPv6 addresses preferred? If no IPv6 address is set, it falls back to IPv4 automatically. You can override this per host by setting the remote_execution_connect_by_ip_prefer_ipv6 parameter. By default and for compatibility, IPv4 is preferred over IPv6.

Default SSH password

*****

Default password to use for SSH. You can override per host by setting the remote_execution_ssh_password parameter.

Default SSH key passphrase

*****

Default key passphrase to use for SSH. You can override per host by setting the remote_execution_ssh_key_passphrase parameter.

Workers pool size

5

Number of workers in the pool to handle the execution of the remote execution jobs. Restart of the dynflowd/foreman-tasks service is required.

Cleanup working directories

Yes

Whether working directories are removed after task completion. You can override this per host by setting the remote_execution_cleanup_working_dirs parameter.

Cockpit URL

Where to find the Cockpit instance for the Web Console button. By default, no button is shown.

Form Job Template

Run Command - SSH Default

Choose a job template that is pre-selected in job invocation form.

Job Invocation Report Template

Jobs - Invocation report template

Select a report template used for generating a report for a particular remote execution job.

A.14. Ansible Settings

Setting Default Value Description

Private Key Path

Use this to supply a path to an SSH Private Key that Ansible uses instead of a password. Override with the ansible_ssh_private_key_file host parameter.

Connection type

ssh

Use this connection type by default when running Ansible playbooks. You can override this on hosts by adding the ansible_connection parameter.

WinRM cert Validation

validate

Enable or disable WinRM server certificate validation when running Ansible playbooks. You can override this on hosts by adding the ansible_winrm_server_cert_validation parameter.

Default verbosity level

Disabled

Foreman adds this level of verbosity for additional debugging output when running Ansible playbooks.

Post-provision timeout

360

Timeout (in seconds) to set when Foreman triggers an Ansible roles task playbook after a host is fully provisioned. Set this to the maximum time you expect a host to take until it is ready after a reboot.

Ansible report timeout

30

Timeout (in minutes) when hosts should have reported.

Ansible out of sync disabled

No

Disable host configuration status turning to out of sync for Ansible after a report does not arrive within the configured interval.

Default Ansible inventory report template

Ansible - Ansible Inventory

Foreman uses this template to schedule the report with Ansible inventory.

Ansible roles to ignore

[]

The roles to exclude when importing roles from Smart Proxy. The expected input is comma separated values and you can use * wildcard metacharacters. For example: foo*, *b*, *bar.

Proxy tasks batch size for Ansible

Number of tasks which should be sent to the Smart Proxy in one request if foreman_tasks_proxy_batch_trigger is enabled. If set, it overrides the foreman_tasks_proxy_batch_size setting for Ansible jobs.