1. Foreman 1.16 Manual

Foreman Architecture

A Foreman installation will always contain a central foreman instance
that is responsible for providing the Web based GUI, node
configurations, initial host configuration files, etc. However, if the
foreman installation supports unattended installations then other
operations need to be performed to fully automate this process. The
smart proxy manages remote services and is generally installed with all
Foreman installations to manage TFTP, DHCP, DNS, Puppet, Puppet CA,
Ansible, Salt, and Chef.

Smart-Proxy

A Smart-Proxy is located on or near a machine that performs a specific function and helps foreman orchestrate the process of commissioning a new host. Placing the proxy on or near to the actual service will also help reduce latencies in large distributed organizations.

Release notes for 1.16

Headline features

Netgroup LDAP authentication

Netgroup grouping is an alternative to POSIX usergroups. Foreman can now be configured to pull users from external groups using either posix or Netgroup naming standards. Although this is an older standard, it can be useful and is supported for integration with FreeIPA and OpenLDAP. (#16112)

Puppet 5 support

ActiveJob + Dynflow backend for background jobs

This feature is for plugin developers. ActiveJob is a very simple and well understood means of scheduling background jobs. 1.16 adds an integration of Dynflow engine into the ActiveJob framework. The goal is to encourage more background jobs to encourage more dynamic user workflows. (#18618)

VMWare SCSI controllers with per-disk configuration

When provisioning a host, it is often necessary to support multiple disks with different SCSI configurations. This is now supported on VMWare with each disk supporting custom conifgurations such as mode, size, and controller id. (#4509)

Thin Host API

To improve integration with other inventory systems, a thin host API was added which supports performant queries of the inventory in Foreman. (#20072)

Plugin Role Locking

Plugin developers who add new roles to Foreman will now have these roles locked by default. This will allow for better maintenance and upgrades of these built in roles. (#19039)

Release notes for 1.16.0

API

Show host interface FQDN in GET API call /api/hosts/:id/interfaces (#20711)

Add subnet6 fields info into GET api of api/v2/hostgroups/:id (#20701)

Administer -> About page should have a bullet link to the local API docs (#20035)

Smart proxy features list should be returned from #refresh API call (#19476)

Foreman’s API /users/:id doesn’t support usernames with dots in them (#19399)

Provide description for Hammer command to disable/enable notifications for a host. (#19383)

/api/compute_resources/:id/available_flavors not working for OpenStack (#19377)

rake tasks

Deprecations

The following deprecations were introduced during this release and will remain deprecated until version 1.18 when they will be retired.

Host API has a ‘scsi_controller_type’ attribute for VMWare hosts which is now deprecated. Instead, you should specify the SCSI controller type on a per-interface basis instead of declaring a global one. For example:

(Only for plugin developers) Plugins with assets must register their assets into Foreman through precompile_assets(asset_files), not SETTINGS[:plugin_name] = asset_files

Last release for Debian 8.X (Jessie)

Due to Jessie bringing Ruby 2.1, which is not compatible with Ruby On Rails 5.x, Foreman 1.16 will be the last major release for Debian/jesse. Minor releases of the 1.16 series will continue to be built for Jessie, but users are strongly encouraged to upgrade.

Contributors

We’d like to thank the following people who contributed to the Foreman 1.16 release:

As well as all users who helped test releases, report bugs and provide feedback on the project.

2. Quickstart

The Foreman installer is a collection of Puppet modules that installs everything required for a full working Foreman setup. It uses native OS packaging (e.g. RPM and .deb packages) and adds necessary configuration for the complete installation.

Components include the Foreman web UI, Smart Proxy, Passenger, a Puppet master (either Puppet Server or under Passenger), and optionally TFTP, DNS and DHCP servers. It is configurable and the Puppet modules can be read or run in “no-op” mode to see what changes it will make.

Supported platforms

CentOS, Scientific Linux or Oracle Linux 7, x86_64

Debian 8 (Jessie), i386/amd64/armhf/aarch64

Debian 9 (Stretch), i386/amd64/armhf/aarch64

Red Hat Enterprise Linux 7, x86_64

Ubuntu 16.04 (Xenial), i386/amd64/armhf/aarch64

Other operating systems will need to use alternative installation methods (see the manual).

2.1 Installation

The Foreman installer uses Puppet (> 3.x required) to install Foreman. This guide assumes that you have a newly installed operating system, on which the installer will setup Foreman, a Puppet master, and the Smart Proxy by default. It’s not advisable to follow the steps below on an existing system, since the installer will affect the configuration of several components.

Using Puppet 5.x is recommended, which is available from the Puppet Labs repository.
You may use Puppet 4.x but check Troubleshooting area about an issue with reporting.
To use Puppet 5.x with Puppet Agent and Puppet Server:

Downloading the installer

Running the installer

Ensure that ping $(hostname -f) shows the real IP address, not 127.0.1.1. Change or remove this entry from /etc/hosts if present.

The installation run is non-interactive, but the configuration can be customized by supplying any of the options listed in foreman-installer --help, or by running foreman-installer -i for interactive mode. More examples are given in the Installation Options section. Adding -v will disable the progress bar and display all changes. To run the installer, execute:

foreman-installer

After it completes, the installer will print some details about where to find Foreman and the Smart Proxy and Puppet master if they were installed along Foreman. Output should be similar to this:

* Foreman is running at https://theforeman.example.com
Initial credentials are admin / 3ekw5xtyXCoXxS29
* Foreman Proxy is running at https://theforeman.example.com:8443
* Puppetmaster is running at port 8140
The full log is at /var/log/foreman-installer/foreman-installer.log

If you use Puppet 4.x and notice that no reports are received, check the
troubleshooting area.

2.2 Puppet Management

After installation, the Foreman installer will have set up a puppet master on the host, fully integrated with Foreman. First run the Puppet agent on the Foreman host which will send the first Puppet report to Foreman, automatically creating the host in Foreman’s database.

puppet agent --test

Puppet will show a warning the first time that the node can't be found, this can be ignored.

In Foreman, click on the Hosts tab and your Foreman host should be visible in the list with an “O” status. This indicates its status is OK, with no changes made on the last Puppet run.

Downloading a Puppet module

Next, we’ll install a Puppet module for managing the NTP service from Puppet Forge to our “production” environment (the default):

puppet module install puppetlabs/ntp

In Foreman, go to Configure > Classes and click Import from hostname (top right) to read the available Puppet classes from the puppet master and populate Foreman’s database. The “ntp” class will appear in the Puppet class list if installed correctly.

Using the Puppet module

Click on the “ntp” class in the list, change to the Smart Class Parameters tab and select the servers parameter on the left hand side. Tick the Override checkbox so Foreman manages the “servers” parameter of the class and change the default value if desired, before submitting the page.

Change back to the Hosts tab and click Edit on the Foreman host. On the Puppet Classes tab, expand the ntp module and click the + icon to add the ntp class to the host, then save the host.

Managed parameters can be overridden when editing an individual host from its Parameters tab.

Clicking the YAML button when back on the host page will show the ntp class and the servers parameter, as passed to Puppet via the ENC (external node classifier) interface. Re-run puppet agent --test on the Foreman host to see the NTP service automatically reconfigured by Puppet and the NTP module.

Adding more Puppet-managed hosts

Other hosts with Puppet agents installed can use this puppet master by setting server = foreman.example.com in puppet.conf. Sign their certificates in Foreman by going to Infrastructure > Smart Proxies > Certificates or using puppet cert list and puppet cert sign on the puppet master.

Puppet classes can be added to host groups in Foreman instead of individual hosts, enabling a standard configuration of many hosts simultaneously. Host groups are typically used to represent server roles.

3. Installing Foreman

There are several different methods of installing Foreman. The recommended way
is with the puppet based Foreman Installer but you may also use your distribution’s package manager or install directly from source.

3.1 System Requirements

This sections outlines the system requirements for an installation of Foreman. This will cover the hardware requirements, OS requirements and firewall requirements. This includes variations for all supported database types.

3.1.1 Supported Platforms

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

All platforms will require Puppet 4 or higher, which may be installed from OS or the Puppet Labs repositories.

Other operating systems will need to use alternative installation methods, such as from source.

The following operating systems are known to install successfully from Foreman:

RHEL and derivatives (CentOS, Scientific Linux, Oracle Linux) 3+

Fedora

Ubuntu

Debian

OpenSUSE

SLES

CoreOS

Solaris

FreeBSD

Juniper Junos

Cisco NX-OS

3.1.2 Hardware Requirements

The hardware requirements for Foreman depend primarily on the number of requests that it will receive, which depends on the number of configuration management clients, web UI activity and other systems using the API.

The default installation when including Puppet Server will require:

4GB memory

2GB disk space

For a bare minimum installation with few clients and no Puppet master, the requirements are:

2GB memory

1GB disk space

Scaling notes

The default installation when using Passenger will increase the number of running processes based on the number of simultaneous requests, up to a default maximum of six instances. Each instance will typically require 0.5-1GB of memory, depending on the number of configured plugins.

Disk usage will increase as more data is stored in the database (PostgreSQL by default), mostly for facts and reports. See the reports cronjob configuration to change how they are expired.

3.1.3 Puppet Compatibility

Foreman integrates with Puppet and Facter in a few places, but generally using a recent, stable version will be fine. The exact versions of Puppet, Puppet Server and Facter that Foreman is compatible with are listed below.

Lines indicated with * require Parametrized_Classes_in_ENC in Foreman to be disabled.

Puppet Server compatibility

Puppet Server is the application for serving Puppet agents used by default in Puppet 4/5 AIO installations.

Puppet Server version

Foreman installer

Notes

1.x

Limited support

2.0 - 2.1

Limited support

Requires server_use_legacy_use_conf, server_puppetserver_version to be set

2.2 - 2.7

Supported

5.x

Supported

AIO installer compatibility

The Foreman installer supports both AIO and non-AIO configurations when using Puppet 4/5, switching behavior automatically based on the version of Puppet installed (usually during the first run when answers are stored).

When using an AIO installation of Puppet to run the installer, it will default to configuring the Puppet Server application, and when using a non-AIO version of Puppet, it defaults to a traditional Rack/Passenger configuration.

Facter compatibility

Foreman is known to be compatible with all Facter 1.x to 3.x releases.

Puppet Enterprise compatibility

The Foreman installer and packages are generally incompatible with Puppet Enterprise, however with some manual reconfiguration, individual Foreman components such as the smart proxy should work if needed (some further unsupported documentation can be found on the wiki). The installer in particular will conflict with a Puppet Enterprise installation. It is recommended that Foreman is installed using Puppet “open source”.

3.1.4 Browser Compatibility

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

Ports indicated with * are running by default on a Foreman all-in-one installation and should be open.

3.2 Foreman Installer

The Foreman installer is a collection of Puppet modules that installs everything required for a full working Foreman setup. It uses native OS packaging (e.g. RPM and .deb packages) and adds necessary configuration for the complete installation.

Components include the Foreman web UI, Smart Proxy, Passenger (for the puppet master and Foreman itself), and optionally TFTP, DNS and DHCP servers. It is configurable and the Puppet modules can be read or run in “no-op” mode to see what changes it will make.

It’s strongly recommended to use the installer instead of only installing packages, as the installer uses OS packages and it saves a lot of time otherwise spent replicating configuration by hand.

By default it will configure:

Apache HTTP with SSL (using a Puppet-signed certificate)

Foreman running under mod_passenger

Smart Proxy configured for Puppet, TFTP and SSL

Puppet master running under mod_passenger

Puppet agent configured

TFTP server (under xinetd on Red Hat platforms)

Other modules can be enabled, which will also configure:

ISC DHCP server

BIND DNS server

It’s recommended to run the installer on a fresh and clean single-purpose system, since the configurations of the aforementioned components is (at least partially) overwritten by the installer.

3.2.1 Installation

Downloading the installer

Running the installer

The installation run is non-interactive, but the configuration can be customized by supplying any of the options listed in foreman-installer --help, or by running foreman-installer -i for interactive mode. More examples are given in the Installation Options section. Adding -v will disable the progress bar and display all changes, while --noop will run without making any changes. To run the installer, execute:

foreman-installer

After it completes, the installer will print some details about where to find Foreman and the Smart Proxy and Puppet master if they were installed along Foreman. Output should be similar to this:

* Foreman is running at https://theforeman.example.com
Initial credentials are admin / 3ekw5xtyXCoXxS29
* Foreman Proxy is running at https://theforeman.example.com:8443
* Puppetmaster is running at port 8140
* The full log is at /var/log/foreman-installer/foreman-installer.log

3.2.2 Installer Options

The installer is a collection of Puppet modules, which have a large number of parameters available to customize the configuration. Parameters can be set by running foreman-installer with arguments, e.g. --foreman-db-type, changing settings in interactive mode or by setting up an answers file.

The precedence for settings is for those set by arguments to foreman-installer or interactive mode, then the answers file, then the Puppet manifest defaults.

foreman-installer arguments

Every parameter available in the installer can be set using command line arguments to foreman-installer. Run foreman-installer --help for most options, or foreman-installer --full-help for a list of every available option.

When running the installer, all arguments passed on the command line will be persisted by default to /etc/foreman-installer/scenarios.d/foreman-answers.yaml and used automatically on subsequent runs, without needing to specify those arguments again. This persistence can be disabled with the -b option.

Interactive mode

The installer also provides a text driven interface to customize configuration parameters, and can be run by executing:

foreman-installer -i

Plugins and compute resources

The installer contains a number of high level modules (e.g. “foreman”, “puppet”) and additionally a number of smaller modules for additional functionality, such as plugins and compute resource support. These can be added with the “–enable” switches, or the default options can be disabled with “–no-enable” switches.

Allow any authentication for the CRL. This is needed on the puppet CA to accept clients from a the puppet CA proxy.

--puppet-auth-allowed

An array of authenticated nodes allowed to access all catalog and node endpoints. default to ['$1']

--puppet-auth-template

Use a custom template for the auth configuration.

--puppet-autosign

If set to a boolean, autosign is enabled or disabled for all incoming requests. Otherwise this has to be set to the full file path of an autosign.conf file or an autosign script. If this is set to a script, make sure that script considers the content of autosign.conf as otherwise Foreman functionality might be broken.

--puppet-autosign-entries

A list of certnames or domain name globs whose certificate requests will automatically be signed. Defaults to an empty Array.

--puppet-autosign-mode

Mode of the autosign file/script

--puppet-autosign-content

Content of the autosign file/script

--puppet-autosign-source

Path to the source of the autosign file/script. Can be used instead of autosign-content

--puppet-ca-port

Puppet CA port

--puppet-ca-server

Use a different ca server. Should be either a string with the location of the ca_server or 'false'.

--puppet-classfile

The file in which puppet agent stores a list of the classes associated with the retrieved configuration.

--puppet-client-certname

The node's certificate name, and the unique identifier it uses when requesting catalogs.

--puppet-client-package

Install a custom package to provide the puppet client

--puppet-codedir

Override the puppet code directory.

--puppet-configtimeout

How long the client should wait for the configuration to be retrieved before considering it a failure.

--puppet-cron-cmd

Specify command to launch when runmode is set 'cron'.

--puppet-dir

Override the puppet directory.

--puppet-dir-group

Group of the base puppet directory, used when puppet::server is false.

--puppet-dir-owner

Owner of the base puppet directory, used when puppet::server is false.

--puppet-dns-alt-names

Use additional DNS names when generating a certificate. Defaults to an empty Array.

--puppet-environment

Default environment of the Puppet agent

--puppet-group

Override the name of the puppet group.

--puppet-hiera-config

The hiera configuration file.

--puppet-listen

Should the puppet agent listen for connections.

--puppet-listen-to

An array of servers allowed to initiate a puppet run. If $listen = true one of three things will happen: 1) if $listen_to is not empty then this array will be used. 2) if $listen_to is empty and $puppetmaster is defined then only $puppetmaster will be allowed. 3) if $puppetmaster is not defined or empty, $fqdn will be used.

--puppet-logdir

Override the log directory.

--puppet-manage-user

Whether to manage the puppet user

--puppet-main-template

Use a custom template for the main puppet configuration.

--puppet-manage-packages

Should this module install packages or not. Can also install only server packages with value of 'server' or only agent packages with 'agent'.

--puppet-module-repository

Use a different puppet module repository

--puppet-package-provider

The provider used to install the agent. Defaults to chocolatey on Windows Defaults to undef elsewhere

--puppet-package-source

The location of the file to be used by the agent's package resource. Defaults to undef. If 'windows' or 'msi' are used as the provider then this setting is required.

Use $environment in the modulepath Deprecated when $server_directory_environments is true, set $server_environments to [] instead.

--puppet-server-enc-api

What version of enc script to deploy. Valid values are 'v2' for latest, and 'v1' for Foreman =< 1.2

--puppet-server-environment-class-cache-enabled

Enable environment class cache in conjunction with the use of the environment_classes API. Defaults to false

--puppet-server-environment-timeout

Timeout for cached compiled catalogs (10s, 5m, ...)

--puppet-server-environments

Environments to setup (creates directories). Applies only when $server_dynamic_environments is false

--puppet-server-environments-group

The group owning the environments directory

--puppet-server-environments-mode

Environments directory mode.

--puppet-server-environments-owner

The owner of the environments directory

--puppet-server-envs-dir

Directory that holds puppet environments

--puppet-server-envs-target

Indicates that $envs_dir should be a symbolic link to this target

--puppet-server-external-nodes

External nodes classifier executable

--puppet-server-foreman

Should foreman integration be installed

--puppet-server-foreman-facts

Should foreman receive facts from puppet

--puppet-server-foreman-ssl-ca

SSL CA of the Foreman server

--puppet-server-foreman-ssl-cert

Client certificate for authenticating against Foreman server

--puppet-server-foreman-ssl-key

Key for authenticating against Foreman server

--puppet-server-foreman-url

Foreman URL

--puppet-server-git-branch-map

Git branch to puppet env mapping for the default post receive hook

--puppet-server-git-repo

Use git repository as a source of modules

--puppet-server-git-repo-group

Git repository group

--puppet-server-git-repo-mode

Git repository mode

--puppet-server-git-repo-path

Git repository path

--puppet-server-git-repo-user

Git repository user

--puppet-server-group

Name of the puppetmaster group.

--puppet-server-http

Should the puppet master listen on HTTP as well as HTTPS. Useful for load balancer or reverse proxy scenarios. Note that the HTTP puppet master denies access from all clients by default, allowed clients must be specified with $server_http_allow.

Additional java options to pass through. This can be used for Java versions prior to Java 8 to specify the max perm space to use: For example: '-XX:MaxPermSpace=128m'.

--puppet-server-jvm-java-bin

Set the default java to use.

--puppet-server-jvm-max-heap-size

Specify the maximum jvm heap space.

--puppet-server-jvm-min-heap-size

Specify the minimum jvm heap space.

--puppet-server-main-template

Which template should be used for master related configuration in the [main] section

--puppet-server-max-active-instances

Max number of active jruby instances. Defaults to processor count

--puppet-server-max-requests-per-instance

Max number of requests a jruby instances will handle. Defaults to 0 (disabled)

--puppet-server-package

Custom package name for puppet master

--puppet-server-parser

Sets the parser to use. Valid options are 'current' or 'future'. Defaults to 'current'.

--puppet-server-passenger

If set to true, we will configure apache with passenger. If set to false, we will enable the default puppetmaster service unless service_fallback is set to false. See 'Advanced server parameters' for more information. Only applicable when server_implementation is "master".

--puppet-server-passenger-min-instances

The PassengerMinInstances parameter. Sets the minimum number of application processes to run. Defaults to the number of processors on your system.

--puppet-server-passenger-pre-start

Pre-start the first passenger worker instance process during httpd start.

--puppet-server-passenger-ruby

The PassengerRuby parameter. Sets the Ruby interpreter for serving the puppetmaster rack application.

--puppet-server-port

Puppet master port

--puppet-server-post-hook-content

Which template to use for git post hook

--puppet-server-post-hook-name

Name of a git hook

--puppet-server-puppet-basedir

Where is the puppet code base located

--puppet-server-puppetdb-host

PuppetDB host

--puppet-server-puppetdb-port

PuppetDB port

--puppet-server-puppetdb-swf

PuppetDB soft_write_failure

--puppet-server-puppetserver-dir

The path of the puppetserver config dir

--puppet-server-puppetserver-experimental

Whether the /puppet/experimental route should be enabled

--puppet-server-puppetserver-jruby9k

Whether to use JRuby 9k

--puppet-server-puppetserver-logdir

The path of the puppetserver log dir

--puppet-server-puppetserver-rundir

The path of the puppetserver run dir

--puppet-server-puppetserver-trusted-agents

Normally agents can only fetch their own catalogs. If you want some nodes to be able to fetch any catalog, list them here

--puppet-server-puppetserver-vardir

The path of the puppetserver var dir

--puppet-server-puppetserver-version

The version of puppetserver 2 installed (or being installed) Unfortunately, different versions of puppetserver need configuring differently, and there's no easy way of determining which version is being installed. Defaults to '2.3.1' but can be overriden if you're installing an older version.

--puppet-server-rack-arguments

Arguments passed to rack app ARGV in addition to --confdir and --vardir. The default is an empty array.

--puppet-server-report-api

What version of report processor to deploy. Valid values are 'v2' for latest, and 'v1' for Foreman =< 1.2

If passenger is not used, do we want to fallback to using the puppetmaster service? Set to false if you disabled passenger and you do NOT want to use the puppetmaster service. Defaults to true.

--puppet-server-ssl-dir

SSL directory

--puppet-server-ssl-dir-manage

Toggle if ssl_dir should be added to the [master] configuration section. This is necessary to disable in case CA is delegated to a separate instance

--puppet-server-ssl-protocols

Array of SSL protocols to use. Defaults to [ 'TLSv1.2' ]

--puppet-server-ssl-chain-filepath

Optional filepath to SSL chain

--puppet-server-storeconfigs-backend

Do you use storeconfigs? (note: not required) false if you don't, "active_record" for 2.X style db, "puppetdb" for puppetdb

--puppet-server-strict-variables

if set to true, it will throw parse errors when accessing undeclared variables.

--puppet-server-template

Which template should be used for master configuration

--puppet-server-use-legacy-auth-conf

Should the puppetserver use the legacy puppet auth.conf? Defaults to false (the puppetserver will use its own conf.d/auth.conf)

--puppet-server-user

Name of the puppetmaster user.

--puppet-server-version

Custom package version for puppet master

--puppet-service-name

The name of the puppet agent service.

--puppet-sharedir

Override the system data directory.

--puppet-show-diff

Show and report changed files with diff output

--puppet-splay

Switch to enable a random amount of time to sleep before each run.

--puppet-splaylimit

The maximum time to delay before runs. Defaults to being the same as the run interval. This setting can be a time interval in seconds (30 or 30s), minutes (30m), hours (6h), days (2d), or years (5y).

--puppet-srv-domain

Search domain for SRV records

--puppet-ssldir

Override where SSL certificates are kept.

--puppet-syslogfacility

Facility name to use when logging to syslog

--puppet-systemd-cmd

Specify command to launch when runmode is set 'systemd.timer'.

--puppet-systemd-unit-name

The name of the puppet systemd units.

--puppet-unavailable-runmodes

Runmodes that are not available for the current system. This module will not try to disable these modes. Default is [] on Linux, ['cron', 'systemd.timer'] on Windows and ['systemd.timer'] on other systems.

--puppet-use-srv-records

Whether DNS SRV records will be used to resolve the Puppet master

--puppet-usecacheonfailure

Switch to enable use of cached catalog on failure of run.

--puppet-user

Override the name of the puppet user.

--puppet-vardir

Override the puppet var directory.

--puppet-version

Specify a specific version of a package to install. The version should be the exact match for your distro. You can also use certain values like 'latest'.

--foreman-plugin-discovery-image-name

tarball with images

--foreman-plugin-discovery-install-images

should the installer download and setup discovery images for you? the average size is few hundreds of MB

--foreman-plugin-discovery-source-url

source URL to download from

--foreman-plugin-discovery-tftp-root

TFTP root to install image into

--foreman-plugin-memcache-compress

will gzip-compress values larger than 1K

--foreman-plugin-memcache-expires-in

global default for key TTL in seconds

--foreman-plugin-memcache-hosts

an array of hosts running memcache

--foreman-plugin-memcache-namespace

prepends each key with this value to provide simple namespacing

--foreman-plugin-ovirt-provision-package

Package name to install, use ruby193-rubygem-ovirt_provision_plugin on Foreman 1.8/1.9 on EL

Directory where OpenSCAP audits are stored before they are forwarded to Foreman

--foreman-proxy-plugin-openscap-version

plugin package version, it's passed to ensure parameter of package resource can be set to specific version number, 'latest', 'present' etc.

--foreman-proxy-plugin-pulp-enabled

enables/disables the pulp plugin

--foreman-proxy-plugin-pulp-group

group owner of the configuration file

--foreman-proxy-plugin-pulp-listen-on

proxy feature listens on http, https, or both

--foreman-proxy-plugin-pulp-mongodb-dir

directory for Mongo DB

--foreman-proxy-plugin-pulp-pulp-content-dir

directory for pulp content

--foreman-proxy-plugin-pulp-pulp-dir

directory for pulp

--foreman-proxy-plugin-pulp-pulp-url

pulp url to use

--foreman-proxy-plugin-pulp-pulpnode-enabled

enables/disables the pulpnode plugin

--foreman-proxy-plugin-pulp-puppet-content-dir

directory for puppet content

--foreman-proxy-plugin-pulp-version

plugin package version, it's passed to ensure parameter of package resource can be set to specific version number, 'latest', 'present' etc.

--foreman-proxy-plugin-remote-execution-ssh-enabled

Enables/disables the plugin

--foreman-proxy-plugin-remote-execution-ssh-generate-keys

Automatically generate SSH keys

--foreman-proxy-plugin-remote-execution-ssh-listen-on

Proxy feature listens on https, http, or both

--foreman-proxy-plugin-remote-execution-ssh-local-working-dir

Local working directory on the smart proxy

--foreman-proxy-plugin-remote-execution-ssh-remote-working-dir

Remote working directory on clients

--foreman-proxy-plugin-remote-execution-ssh-ssh-identity-dir

Directory where SSH keys are stored

--foreman-proxy-plugin-remote-execution-ssh-ssh-identity-file

Provide an alternative name for the SSH keys

--foreman-proxy-plugin-remote-execution-ssh-ssh-keygen

Location of the ssh-keygen binary

--foreman-proxy-plugin-salt-api

Use Salt API

--foreman-proxy-plugin-salt-api-auth

Salt API auth mechanism

--foreman-proxy-plugin-salt-api-password

Salt API password

--foreman-proxy-plugin-salt-api-url

Salt API URL

--foreman-proxy-plugin-salt-api-username

Salt API username

--foreman-proxy-plugin-salt-autosign-file

File to use for salt autosign

--foreman-proxy-plugin-salt-enabled

Enables/disables the plugin

--foreman-proxy-plugin-salt-group

Owner of plugin configuration

--foreman-proxy-plugin-salt-listen-on

Proxy feature listens on https, http, or both

--foreman-proxy-plugin-salt-user

User to run salt commands under

Answers file

The answers file describes the classes that will be applied to the host to
install Foreman, along with their parameters. The foreman-installer package stores it at /etc/foreman-installer/scenarios.d/foreman-answers.yaml. By default, the all-in-one setup will include Foreman, a puppetmaster, Puppet agent, and the Smart Proxy:

Other examples are given in the next section, or /usr/share/foreman-installer/README.md.

Advanced module configuration

Additional configuration options can be given in /etc/foreman-installer/custom-hiera.yaml for some of the Puppet modules that are used internally by Foreman installer. The contents of this file will be passed to Hiera during the Foreman installer execution so can set class parameters for other modules such as apache, mysql, and postgresql.

For example, the TraceEnable option may be controlled by disabling the apache::trace_enable parameter in this file:

apache::trace_enable:Off

Please note that the parameters used by these modules may change between versions of Foreman, so it’s important to check the versions in use and the appropriate module documentation or source code when editing this configuration file. Modifications cannot be supported or migrated by Foreman.

3.2.3 Installation Scenarios

The Foreman installer can accommodate more complex, multi-host setups when supplied with appropriate parameters.

Using an external database server

Per default foreman-installer will install a PostgreSQL database server onto the Foreman host and create its database. An external MySQL or PostgreSQL database server with an already created database can be used with the following arguments:

Setting up Foreman with external Puppet masters

Using the scenarios outlined below, a simple scale-out setup can be created as follows:

On the Foreman host, run a complete foreman-installer all-in-one installation to provide Foreman, a Puppet master and smart proxy. This will be the Puppet CA.

For each Puppet master:

Generate a new certificate following the steps in the SSL CA section and transfer it to the new Puppet master host

Run the standalone Puppet master installation as detailed below

Each Puppet master will register with Foreman as a smart proxy, while the instance running on the Foreman host itself will act as a central Puppet CA. These can be selected while adding new hosts or host groups.

SSL certificate authority setup

The scenarios below assume a single Puppet CA (certificate authority) for all hosts, which is also used for Foreman and smart proxy communications, though more complex deployments are possible. This might be the central Foreman host, or a particular Puppet master.

Other systems require certificates to be generated on the central Puppet CA host, then distributed to them before running foreman-installer (else it may generate a second CA). To prepare these, on the host acting as Puppet CA, run:

This provides the new host a certificate in the same authority, but doesn’t make it a CA itself. Certificates will continue to be generated on the central Puppet CA host.

Standalone Puppet master

A standalone Puppet master can be configured along with a smart proxy installation, enabling the Puppet infrastructure to be scaled out. A certificate should be generated and copied to the host first to make it part of the same CA, else a new Puppet CA will be generated.

Fill in the OAuth consumer key and secret values from your Foreman instance, retrieve them from Administer > Settings > Authentication, and set the Foreman URLs appropriately. These allow the smart proxy to register automatically with the Foreman instance, or disable with --foreman-proxy-register-in-foreman=false.

PuppetDB integration

An existing PuppetDB server can be integrated into a Puppet master by adding:

Be aware that foreman-installer does not setup the PuppetDB server itself. Starting with 1.13 of foreman-installer, only
setups using Puppet Labs Puppet 4 AIO packages are supported for PuppetDB integration using these parameters.

Foreman server without the Puppet master

The default “all-in-one” Foreman installation includes a Puppet master, but this can be disabled. Foreman by default uses Puppet’s SSL certificates however, so a certificate must be generated and copied to the host first, or all SSL communications need to be disabled.

This will still configure the Puppet agent, but this too can be disabled with --no-enable-puppet to disable the whole Puppet module.

Smart proxy for DNS, DHCP etc.

The smart proxy allows management of various network services, such as DNS, DHCP and TFTP. The installer can set up a basic smart proxy service ready to be configured, or it can install and configure BIND or ISC DHCP ready to go. A certificate should be generated and copied to the host first so Foreman can contact the proxy server.

Fill in the OAuth consumer key and secret values from your Foreman instance, retrieve them from Administer > Settings > Authentication, and set the Foreman URL appropriately. These allow the smart proxy to register automatically with the Foreman instance, or disable with --foreman-proxy-register-in-foreman=false.

Command line arguments for a smart proxy configured with just BIND, setting DNS forwarders and overriding the default forward and reverse DNS zones:

Ensure the dns-interface argument is updated with the correct network
interface name for the DNS server to listen on. After configuration, make sure
to create Subnet in Foreman under Infrastructure > Subnets for the
particular Smart Proxy which registers automatically.

Command line arguments for a smart proxy configured with just ISC DHCP and a single DHCP subnet:

Also ensure here that the dhcp-interface argument is updated for the interface
to run DHCP on. After configuration, make sure to create a new Subnet (or
import from existing) in the Foreman interface.

While it is possible to define the same DHCP range in Foreman, it’s usually
good practice to select a range from outside the pool defined in the
installer, but still in the subnet. For the example above, it is recommended
to define the DHCP range from 10.0.0.1 to 10.0.0.99 in the Foreman UI which
gives the following IP address distribution:

3.3 Install From Packages

Packages are available for Red Hat and Debian-based distributions. This will install a standalone Foreman service running under WEBrick, which has limited scalability.

The Puppet-based Foreman installer is recommended for most environments, instead of installing only the packages as it will perform full configuration too.

3.3.1 RPM Packages

Foreman is packaged for the following RPM based distributions:

RHEL and derivatives, version 6 and 7

Fedora 24

For most users, it’s highly recommended to use the installer as the packages only provide the software and a standalone Foreman service. The installer installs these packages, then additionally configures Foreman to run under Apache and Passenger with PostgreSQL, plus can configure a complete Puppet setup integrated with Foreman.

Pre-requisites: EPEL

All RHEL and derivatives must be subscribed to EPEL to provide additional dependencies. Install epel-release from here to automatically configure it.

Pre-requisites: Software collections

All RHEL and derivatives require software collections from the CentOS SCLorg Special Interest Group (SIG). Foreman uses the rh-ruby22 and sclo-ror42 collections - the former is from RHSCL, and the latter from the SCLorg SIG.

Generally we recommend all users to use the CentOS SCLorg SIG’s builds of both, which can be configured by installing the foreman-release-scl package from our repositories (which in turn installs the centos-release-scl* packages). The Foreman installer will use this package by default.

It is also possible to obtain rh-ruby22 from other sources below, but the sclo-ror42 collection is still required from the CentOS SCLorg SIG. These sources are noted only for completeness:

Pre-requisites: Optional repo (RHEL only)

RHEL 6 and 7 hosts must also be subscribed to the RHEL 6/7 Optional repository or child channel in RHN.

To enable the optional repository on a RHEL 7 system using subscription-manager, run:

yum-config-manager --enable rhel-7-server-optional-rpms

Pre-requisites: Puppet

It’s recommended to configure the Puppet Labs repositories to obtain the latest version of Puppet available, instead of the version on EPEL. Either the 3.x open source repository or the Puppet Collection (PC1) repository may be configured:

Upgrade

3.3.2 Software Collections

The RPMs use a packaging technique called Software Collections, or SCL. This provides Ruby and all dependencies required to run Foreman separately from the version of Ruby provided by the distribution.

A “tfm” (The Foreman) collection is provided by the Foreman project which ships all dependencies for the main Foreman application, and depends on the “sclo-ror42” and “rh-ruby22” collections which provide newer versions of Ruby and Ruby on Rails. Packages that are part of these collections will have “tfm-“, “sclo-ror42-“ and “rh-ruby22-“ prefixes, allowing them to be easily identified, and will install entirely underneath /opt/theforeman and /opt/rh.

The system Ruby version is left alone and will still be used for packages provided both by the distribution, and other third parties who target the system Ruby (e.g. Puppet packages).

Foreman currently uses SCL only on RHEL and EL clones where a newer version of Ruby is desired. Fedora only uses the distro version of Ruby.

In order to run rake commands for Foreman, or scripts that run in the same environment, tfm-rake and tfm-ruby wrappers are provided as alternatives for the usual rake or ruby. In order to run a series of commands or a script directly within the software collection, scl enable tfm 'other command' can be used. It is also possible to run scl enable tfm bash to get a shell within the context of the SCL. Foreman rake tasks should be run with foreman-rake, which automates using Foreman’s rake environment, changes user etc.

More general information about software collections is available from these links:

Passenger under the SCL

When running Foreman under Passenger (the default installer setup), a specific configuration is needed for SCL (on EL), since Foreman operates under the SCL Ruby and other apps such as the puppetmaster will use the system Ruby. Passenger 4 is shipped in the Foreman repos as it can be configured with separate Ruby binaries per VirtualHost. The full configuration is described below.

The following packages must be installed:

mod_passenger

tfm-rubygem-passenger

tfm-rubygem-passenger-native

tfm-rubygem-passenger-native-libs

rubygem-passenger

rubygem-passenger-native

rubygem-passenger-native-libs

Ensure all version numbers match and are at least 4.0. mod_passenger provides the Apache module, while there are two copies of the Ruby components, one for the SCL Ruby (tfm-rubygem-*) and one for the system Ruby (rubygem-*).

The /etc/httpd/conf.d/passenger.conf file is supplied by mod_passenger and should contain:

Check for .rpmsave or .rpmnew config backup files if this isn’t correct. Note that this refers to the system Ruby paths by default, allowing everything except Foreman (i.e. the puppetmaster) to run under the system Ruby.

Next, the Foreman config file at /etc/httpd/conf.d/foreman.conf must contain this entry in both HTTP and HTTPS VirtualHost sections:

PassengerRuby /usr/bin/tfm-ruby

Ensure both RailsAutoDetect and RakeAutoDetect config entries are removed from foreman.conf and puppet.conf when using Passenger 4, since they have been deprecated.

When successfully configured, two Passenger RackApp processes will be visible and by inspecting the open files, the Ruby version being loaded can be confirmed:

Upgrade

3.4 Install From Source

Installing the latest development code:
Foreman uses Bundler to install dependencies and get up and running. This is the preferred way to get Foreman if you want to benefit from the latest improvements. By using the git repository you can also upgrade more easily. You will need to have Bundler installed manually for now (check your distribution repositories, or install it via rubygems).

Foreman will run with the following requirements (aside from rubygem dependencies):

Ruby 2.0, 2.1, 2.2, 2.3 or 2.4

NodeJS 4.0 or newer

NPM 3.0 or newer

You will want to make sure that you have one of the mysql-devel,
postgresql-devel, and sqlite-devel libraries installed so the database
gems can install properly. Also, you would also need gcc, ruby-devel,
libxml-devel, libxslt-devel, libvirt-devel, nodejs, and npm packages.

For RHEL6 or clones, you can issue the following commands to install all
required packages:

Additionally, it is important that config/database.yml is set to use
the correct database in the “production” block. Rails (and subsequently
Foreman) will use these connection settings under “production” to manage
the database it uses and setup the necessary schema.

You can install other hammer plugins via any of the methods mentioned above.

3.5 Configuration

The following sections detail the configuration steps required to get Foreman working in your environment.
Lets get started!

3.5.1 Initial Setup

Configuration

Foreman configuration is managed from two places; a configuration file
config/settings.yaml and from the SETTINGS/Foreman Settings page. A full
description of the configuration options is given at
foreman_configuration

Database

Foreman requires a database of its own to operate - database sharing is
unsupported. By default, the installer uses PostgreSQL, while a package or
source installation will use SQLite.
If you want to use other database (e.g.
MySQL) please modify the configuration file under config/database.yml.

Import Data from Puppet

At this point, you might want to go through the [[FAQ]] to see how can you import your data into Foreman.

Start The Web Server

if you installed via rpm, just start the foreman service, or start the builtin web server by typing:

RAILS_ENV=production rails server

and point your browser to http://foreman:3000

If you would like to keep the server running, its recommend to setup
passenger or use the RPM. Example usage with passenger can be found on
GitHub.

Getting your Puppet Reports into Foreman

Read Puppet_Reports to learn how to get your nodes to report to Foreman.

3.5.2 Configuration Options

Configuration is broken into two parts. The /etc/foreman/settings.yaml file and the Administer > Settings page. The configuration file contains a few low-level options that need to be set before Foreman starts but the majority of Foreman customization is managed from within the web interface on the Settings page.

The configuration file can also override those settings specified in the web interface. Any settings added in the config file that are available in the web interface will be made read-only.

The config/settings.yaml file

YAML start

The first non-comment line of this file must be three dashes.

---

login

This boolean option configures whether Foreman requires users to to login. If it is set then each user will be expected to authenticate themselves and all operations will occur, and be audited, under their identity. When this option is false then all activity will be executed under the admin account.

:login: true

require_ssl

This boolean option configures whether Foreman insists on using only https/ssl encrypted communication channels in the web interface. This does not configure the channels used to contact the smart-proxies. Note that certain operations will still accept a http connection even if this is set, for example, the downloading of a finish script.

:require_ssl: true

unattended

This boolean option configures whether Foreman will act as a simple node classifier for puppet, or support the full spectrum of operations required for managing a host’s lifecycle. When set to true then foreman will provide full host building facilities for various operating systems.

:unattended: true

support_jsonp

This boolean options configures whether Foreman will provide support for the JavaScript object notation with padding. When set to true then Foreman will allow to pass a callback parameter to the API calls.

:support_jsonp: false

logging

This options contains a hash of parameters that override the current logging configuration. It supports any of the options that are in logging.yaml (see below), but most usually it’s used to change the log level for debugging.

:logging:
:level: debug

loggers

This options contains a hash of config options for specific loggers, which cover parts of Foreman functionality. It’s usually used to enable additional types of logging.

Some plugins may add their own loggers. See the configuration files in /etc/foreman/plugins/ which should list possibilities and enable them there.

The ‘email.yaml’ file

This settings file can be found at /etc/foreman/email.yaml, or config/email.yaml on a source installation.

This file is deprecated for configuring email, SMTP and sendmail options. Please remove it and configure via the web UI under Administer > Settings > Email instead. On Foreman 1.16, this file will be completely useless.

An example settings file can be found at config/email.yaml.example, copy this file to config/email.yaml if there isn’t already a config file.

Configuration Directives

authentication

The type of authentication method expected by your service provider.

Valid settings:

:login
:none

(note: if you set this to :none, you must not include the user_name and password settings)

Using sendmail command

Example for a unix system that uses the /usr/sbin/sendmail command.

production:
delivery_method: :sendmail

The ‘logging.yaml’ file

This settings file can be found at /etc/foreman/logging.yaml, or config/logging.yaml on a source installation. It controls the default logging locations, formatting and log levels per Rails environment.

In a normal installation, only the “production” environment is relevant - development and test are only used in source installations. The file has comments for the most common configuration options, which can be changed here or overridden from the logging directive in the main settings.yaml config file (see above).

The ‘Administer/Settings’ page

access_unattended_without_build

When enabled, unattended URLs used to fetch templates for individual hosts will be accessible irrespective of the host build state. When disabled, the unattended URLs will only function in build mode to prevent accidental rebuilding etc.
Default: false

administrator

When Foreman needs to mail the administrator then this is the email address that it will contact. The domain is determined from Facter, else it will default to the “:domain” setting in /etc/foreman/settings.yaml.
Default: root@<your domain>.

always_show_configuration_status

When reporting the configuration status of hosts, usually only hosts with outdated reports, or a Puppet proxy/master set and no reports will be considered out of sync. When true, all hosts will be considered out of sync until a report is received. This setting should be enabled in environments where Foreman is used for reporting without smart proxies.
Default: false

authorize_login_delegation

mod_proxy and other load balancers will set a REMOTE_USER environment variable. If this is true , your users will be able to login through an external service and Foreman requests will be authenticated using this REMOTE_USER variable.
Default: false

authorize_login_delegation_api

Same as above, but this setting allows REMOTE_USER authentication for API calls as well.
Default: false

authorize_login_delegation_auth_source_autocreate

If you have authorize_login_delegation set, new users can be autocreated through your external authentication mechanism by changing this to the name of the Auth Source you want to use to auto create users.
Default: ‘’

bmc_credentials_accessible

By default passwords stored on BMC network interfaces will be visible to other users who can view the host via the ENC YAML preview and accessible through templates, for the purposes of configuring BMC interfaces automatically.

When set to false, all BMC passwords will be redacted in template and ENC output, preventing both users from viewing the passwords directly and also from configuration (or access) in Puppet and other config management tools using the ENC interface. Foreman will continue to use the stored password for BMC power operations.

Note that setting this to false also this requires that safemode_render be enabled, else it could be bypassed.

Default: true

clean_up_failed_deployment

During host provisioning onto a compute resource using images or templates and a finish script, this setting controls the behavior of Foreman when the script fails. When true, the new host and virtual machine (on the compute resource) will be deleted if the script fails. When false, the host and virtual machine are left running so the script can be debugged.
Default: true

create_new_host_when_facts_are_uploaded

When facts are received from Puppet or other configuration management systems, a corresponding host will be created in Foreman if the certname or hostname is unknown. When false, this behavior is disabled and facts will be discarded from unknown hosts.
Default: true
See also: create_new_host_when_report_is_uploaded

create_new_host_when_report_is_uploaded

If a report is received from Puppet or other configuration management systems, a corresponding host will be created in Foreman if the hostname is unknown. When false, this behavior is disabled and reports will be discarded from unknown hosts.
Default: true
See also: create_new_host_when_facts_are_uploaded

db_pending_migration

When you upgrade Foreman using foreman-installer, the database may migrate its data model to the new version. If this is true, the next run of the installer will run these migrations. If it is false, the database will remain untouched.

Default: true

db_pending_seed

When you upgrade Foreman using foreman-installer, the new version may contain some seed data such as operating systems, provisioning templates, roles and more. It will also update any previous seeded data. If this is true, the next run of the installer will seed this data. If it is false, the database will not get this seeded data.

Default: true

default_location

The name of an location that hosts uploading facts into Foreman will be assigned to if they are new or missing an location. This can be used when hosts are created through fact uploads to ensure they’re assigned to the correct location to prevent resource mismatches. For inherited location, the fact should use slash-delimited names, e.g. “USA/New York”.
Default: ‘’

default_organization

The name of an organization that hosts uploading facts into Foreman will be assigned to if they are new or missing an organization. This can be used when hosts are created through fact uploads to ensure they’re assigned to the correct organization to prevent resource mismatches. For inherited organization, the fact should use slash-delimited names, e.g. “ACME Inc/Engineering”.
Default: ‘’

default_puppet_environment

When Foreman receives a fact upload from a machine that it has not previously come across it will create a host in its database. If the facts from that host did not contain information about the puppet environment then it will assign the default_puppet_environment environment to this host.
Default: production

Default_variables_Lookup_Path

A Smart-variable’s match criteria are evaluated in a specific order and if this search order is not provided then Default_variables_Lookup_Path is used.
Default: [“fqdn”, “hostgroup”, “os”, “domain”]

delivery_method

The method for sending emails from the Foreman instance, either sendmail (running the command set by sendmail_location) to send mail via the configured local MTA, or smtp for direct connection to an outbound SMTP server (given by settings with the smtp prefix).
Default: sendmail

dns_conflict_timeout

When updating a host and DNS conflict detection is performed, each lookup for A and PTR records will be limited to this time in seconds.
Default: 3 (seconds)
See also: query_local_nameservers

email_reply_address

email_subject_prefix

The subject line prefix for any emails sent by Foreman.
Default: [foreman]

enc_environment

When this is true, Foreman will send the puppet environment in the ENC yaml output. This is meant to fix conflicts between a node’s puppet.conf environment and the environment set in Foreman. On Puppet 3+, agents will take the environment sent by the ENC. When false, the ENC yaml will not contain the environment, the node will not update its environment and use the one at puppet.conf.
Default: true

Enable_Smart_Variables_in_ENC

Whether Smart-variables should be included in the yaml node information provided to puppet.
Default: true

entries_per_page

The number of entries that will be shown in the web interface for list operations.
Default: 20

fix_db_cache

Foreman maintains a cache of permissions and roles. If this is set to true, Foreman will recreate this cache on the next run.
Default: false

foreman_url

Emails may contain embedded references to Foreman’s web interface. This option allows the URL prefix to be configured. The FQDN is determined from Facter, else it will default to the “:fqdn” setting in /etc/foreman/settings.yaml.
Default: https://FQDN/ or http://FQDN/ (depending on require_ssl)
See also: unattended_url

global_(PXELinux/PXEGrub/PXEGrub2)

Default PXELinux/PXEGrub/PXEGrub2 template. This template gets deployed to all configured TFTP servers. For example, this template can be used to make new hosts in a network boot into Foreman Discovery.

Default: none

host_group_matchers_inheritance

Matchers used in smart variables or class parameters to match host groups can be inherited by children of those matching host groups too (e.g. a matcher for hostgroup=Base will also apply to Base/Web). Set this to false to make matchers only match a particular hostgroup and not its children.
Default: true

host_power_status

Controls whether the power status of hosts is shown on the hosts list, which may lead to decreased performance, or if the column is removed.
Default: true

host_owner

Defines which is the default owner of newly provisioned hosts. It can be either a user or a user group. If unset, the default owner of the host will be the user who created the host.
Default: none

idle_timeout

Users that stay idle (no requests sent to Foreman) for more than this number of minutes will be logged out.
Default: 60

interpolate_erb_in_parameters

If true, Foreman variables will be exposed to the ENC. Check Template Writing for a more comprehensive guide on how to create and use these variables in your ERB templates.
Default: true

ignore_facts_for_operatingsystem

When Foreman receives facts for a host (from any source, Puppet, Ansible…) it will try to update the operating system to whatever the incoming facts say. This setting allows you to import all facts but ignore those related with operating system. If this is set to true, Foreman will update the operating system of hosts using these facts.
Default: false
See also: ignored_facts_for_domain

ignore_facts_for_domain

See ignored_facts_for_operatingsystem - this setting is the equivalent for domains.
Default: false

ignore_puppet_facts_for_provisioning

If this option is set to true then Foreman will not update the IP and MAC addresses stored on a host’s network interfaces with the values that it receives from facts. It will also include Foreman’s values for IP and MAC to Puppet in its node/ENC information.
Default: false
See also: ignored_interface_identifiers

ignored_interface_identifiers

When importing facts and updating stored information on network interfaces, any network interface with an identifier (e.g. eth0) that matches any of the items in this list will be ignored and not updated. This can be used to avoid updating special types of interfaces when Foreman has limited or no understanding of them. The contents are an array of strings which may contain * wildcards to match zero or more characters.
Default: ['lo', 'usb*', 'vnet*', 'macvtap*', '_vdsmdummy_', 'veth*']
See also: ignore_puppet_facts_for_provisioning

legacy_puppet_hostname

This setting truncates the hostname of your smart proxy to ‘puppet’ if it starts with ‘puppet’.
Default: false

libvirt_default_console_access

The IP address that should be used for the console listen address when provisioning new virtual machines via Libvirt.
Default: 0.0.0.0

location_fact

The name of a fact from hosts reporting into Foreman which gives the full location name of the host. This can be used when hosts are created through fact uploads to ensure they’re assigned to the correct location to prevent resource mismatches. The location of a host will be updated to the value of the fact on every fact upload. For inherited locations, the fact should use slash-delimited names, e.g. “USA/New York”.
Default: foreman_location

local_boot_(PXELinux/PXEGrub/PXEGrub2)

When creating hosts that use a PXE loader, this will be the default template for local boot.

Default: none

login_delegation_logout_url

If your external authentication system has a logout URL, redirect your users to it here. This setting can be useful if your users sign in Foreman through SSO, and you want them to sign out from all services when they log out Foreman.
Default: ‘’

login_text

Specifies text to be displayed on the Foreman login page underneath the version number.
Default: ‘’

manage_puppetca

If this option is set to true then Foreman will manage a host’s Puppet certificate signing. If it is set to false then some external mechanism is required to ensure that the host’s certificate request is signed.
Default: true

max_trend

Days that trend graphs will capture.
Default: 30

modulepath

This it the modulepath that foreman uses when processing puppet modules. It is usually able to determine this itself at runtime but if it is not able to find a value then modulepath is used.
Default: /etc/puppet/modules

name_generator_type

Specifies the method used to generate random hostnames when creating a new host, either Random-based, MAC-based for bare metal hosts only, or Off to disable the function and leave the field blank.
Default: Random-based

oauth_active

Enables OAuth authentication for API requests.
Default: false

oauth_consumer_key

OAuth consumer key
Default: none

oauth_consumer_secret

OAuth consumer secret
Default: none

oauth_map_users

This allows OAuth users to specify which user their requests map to. When this is false, OAuth requests will map to admin.
Default: true

organization_fact

The name of a fact from hosts reporting into Foreman which gives the full organization name of the host. This can be used when hosts are created through fact uploads to ensure they’re assigned to the correct organization to prevent resource mismatches. The organization of a host will be updated to the value of the fact on every fact upload. For inherited organization, the fact should use slash-delimited names, e.g. “ACME Inc/Engineering”.
Default: foreman_organization

outofsync_interval

Duration in minutes after the Puppet interval for servers to be classed as out of sync. This is added to the puppet_interval setting and used in pages such as the host list and dashboard.
Default: 5

Parametrized_Classes_in_ENC

In Puppet 2.6.5+, the ENC may send a hash of the class’s attributes and values. Before then, the ENC used to send just an array of class names. Set this to true if you are using any version of Puppet equal to or higher than 2.6.5.
Default: true

password_hash

Changes the algorithm and format used to hash root passwords entered when creating new hosts or host groups. This needs to be set to the lowest common denominator of operating systems that are provisioned from Foreman, but try to set it to the highest level (i.e. SHA-512) that all OSes support. After changing the value, root passwords will need to be re-entered on existing hosts or host groups in order to re-hash them under the new algorithm.
Default: MD5

proxy_request_timeout

Timeout in seconds used when making REST requests to a Smart Proxy, e.g. when importing Puppet classes or creating DHCP records. May be set to a larger value when certain operations take a long time.
Default: 60

puppet_interval

This is the number of minutes between each run of puppet.
Default: 30

puppet_server

The default puppet server hostname. For larger organizations this is often a non fqdn so that a name like puppet can be a different host within each DNS domain.
Default: puppet

puppetrun

If this option is set to true then Foreman will be able to trigger a puppet run on any host that it manages.
Default: false

query_local_nameservers

If true, Foreman will query the local DNS. When false Foreman will query the SOA/NS authority. Warning! Querying a resolver can cause Foreman to get false positives when checking presence of DNS records due to caching.
Default: false
See also: dns_conflict_timeout

remote_addr

When Foreman receives client web requests via a smart proxy, proxy or load balancer, the original client source IP address is lost, replaced by the smart proxy, proxy, or load balancers IP instead. For template requests without a token, this causes a failure, because Foreman can’t match the request against a valid host.

Smart proxies, and other devices if configured, can preserve the original client IP within an HTTP X-Forwarded-For header, which Foreman can evaluate and use to match the request against a valid host.

In order to prevent spoofing and provide some level of security, Foreman will only evaluate X-Forwarded-For headers from devices which match the list of IPs configured here.

This is a regular expression, so it can support several load balancers, i.e: (10.0.0.1|127.0.0.1)
Default: 127.0.0.1

require_ssl_smart_proxies

When set to true, Foreman requires a client SSL certificate on requests from smart proxies or services on them (e.g. Puppet masters), and will verify the CN of the certificate against the known smart proxies. If false, it uses the reverse DNS of the IP address making the request. require_ssl in config/settings.yaml should be enabled too. For more information about securing the connection between Puppet masters or smart proxies and Foreman, see Section 5.4.1
Default: true

restrict_registered_smart_proxies

When set to true, services such as Puppet masters (or Salt, Chef) need to have a smart proxy registered with the appropriate feature (e.g. Puppet) to access fact/report importers and ENC output.
Default: true

root_pass

If a root password is not provided whilst configuring a host or its host group then this encrypted password is used when building the host.
Default: ‘’
(To generate a new one you should use: openssl passwd -1 “your_password” )

safemode_render

In the default configuration with safemode_render set to true, access to variables, Foreman internals and any object that is not whitelisted within Foreman will be denied for system security.

When set to false, any object may be accessed by a user with permission to use templating features, either via editing of templates, parameters or smart variables. This permits users full remote code execution on the Foreman server, effectively disabling all authorization if set to false. It is strongly recommended for this setting to be true in most environments.

Default: true

send_welcome_email

New account holders will receive a welcome email when the account is created if this is enabled, including their username and a link to Foreman.
Default: false

sendmail_arguments

Arguments given to the sendmail command when sending emails from Foreman.
Default: -i

sendmail_location

Path to the sendmail binary, or other sendmail-compatible MTA for outbound email.
Default: /usr/sbin/sendmail

smtp_address

Outbound SMTP connections will connect to the SMTP server at this address, either a hostname or IP address.
Default: empty value (implying localhost)

smtp_domain

Outbound SMTP connections will use this domain to identify during the HELO/EHLO command.
Default: empty value

smtp_enable_starttls_auto

Outbound SMTP connections will automatically switch to TLS mode (via STARTTLS) when the capability is advertised by the SMTP server. This implies verification of TLS/SSL certificates by default (see also: smtp_openssl_verify_mode).
Default: true

smtp_openssl_verify_mode

Outbound SMTP connections to a TLS-enabled SMTP server will verify the remote server certificate according to this setting. Either the default (usually peer), none for no verification of the server certificate, or peer for explicitly verifying the server certificate. client_once and fail_if_no_peer_cert have no effect in outbound SMTP connections.
Default: Default verification mode (usually peer)

smtp_username

ssl_client_cert_env

Environment variable containing the entire PEM-encoded certificate from the client. This environment variable is required when authenticating using Subject Alternative Names and will be preferred over ssl_client_dn_env if available. Under Apache HTTP and mod_ssl, SSLOptions +ExportCertData sets this environment variable.
Default: SSL_CLIENT_CERT
See also: ssl_client_dn_env

trusted_puppetmaster_hosts

unattended_url

This controls the URL prefix used in provisioning templates such as TFTP/PXELinux files that refer to the Foreman server. It is usually HTTP rather than HTTPS due to lack of installer support for HTTPS. The FQDN is determined from Facter, else it will default to the “:fqdn” setting in /etc/foreman/settings.yaml.
Default: http://FQDN/
See also: foreman_url

update_environment_from_facts

If Foreman receives an environment fact from one of its hosts and if this option is true, it will update the host’s environment with the new value. By default this is not the case as Foreman should manage the host’s environment.
Default: false

update_ip_from_built_request

If true, Foreman will update the host IP with the IP that made the ‘build’ request. This request is made at the end of a provisioning cycle to indicate a host has completed the build.
Default: false

update_subnets_from_facts

If true, fact imports from Puppet and other config management tools will update the subnet on host network interfaces to match the IP address given in facts, preventing a mismatch.
Default: false

use_shortname_for_vms

When false, any hosts created on a compute resource will use the FQDN of the host for the name of the virtual machine. When set to the true, the short name (i.e. without domain) will be used instead.
Default: false

use_gravatar

Display user avatars by matching their emails with emails at Gravatar.com
Default: false

use_uuid_for_certificates

When enabled, Foreman will generate UUIDs for each host instead of using the hostname as the Puppet certname, which is more reliable with changing hostnames. Note that when disabling this setting, existing stored certnames won’t be changed or discarded until new certificates are requested from a host (i.e. on a rebuild), in order that the existing certificate remains known to Foreman and can be revoked.

websockets_encrypt

When enabled, virtual machine consoles using NoVNC will always be sent over an encrypted WebSocket connection. Requires both websockets_ssl_cert and websockets_ssl_key to be configured too.
Default: true if require_ssl is enabled
See also: websockets_ssl_cert, websockets_ssl_key

websockets_ssl_cert

Path to the SSL certificate that will be used for the WebSockets server when serving virtual machine consoles. Should be the same as the SSL certificate used for the Foreman web server (e.g. Apache).

websockets_ssl_key

Path to the SSL private key that will be used for the WebSockets server when serving virtual machine consoles. Should be the same as the SSL key used for the Foreman web server (e.g. Apache).

3.5.3 Database Setup

Foreman is a rails application. Therefore, anything that is supported under RAILS (sqlite, mysql, postgresql, …) can be used. See 3.3 Install From Packages for a list of packages for connecting foreman to the databse of your choice. At this time, Oracle DB is known to not work. Patches are welcome!

(On RPM distros, remove “bundle exec” from the start of these commands.)

Once you’ve migrated to your new database using prod2dev, you should update your database.yml file to point your ‘production’ environment at the new database.
You should also update the ‘development’ environment to point to an alternative location (for example, at SQLite) to ensure you don’t accidentally overwrite your production database.

Special notes for migrating to Postgres

Firstly, the default installer setup doesn’t give superuser privileges to the ‘foreman’ user, which then prevents the prod2dev script from temporarily disabling foreign keys. You’ll need to do

sudo-u postgres psql -c'ALTER USER foreman WITH SUPERUSER'

before the prod2dev call, and

sudo-u postgres psql -c'ALTER USER foreman WITH NOSUPERUSER'

after it.

Secondly, the psql sequence numbers will be wrong after the prod2dev execution. You can fix them like this:

3.5.4 Puppet Reports

Foreman uses a custom puppet reports address (similar to tagmail or store) which Puppet will use to upload its report into Foreman. This enables you to see the reports through the web interface as soon as the client finishes its run.

Configuration

Client

Ensure that the puppet clients has the following option in their puppet.conf:

Edit the URL field to point to your Foreman instance, and the SSL fields for the hostname of the Puppet master (which may be the same host). Paths to Puppet’s SSL certificates will be under /etc/puppetlabs/ssl/ when using Puppet 4 with AIO.

Debugging reports

If reports aren’t showing up in Foreman when an agent is run, there can be a number of reasons. First check through the above configuration steps, and then look at these places to narrow down the cause:

Puppet master logs may show an issue either loading or executing the report processor. Check syslog (/var/log/messages or syslog) for puppet-master messages, or /var/log/puppetlabs/puppetserver/.

/var/log/foreman/production.log should show a POST "/api/reports" request each time a report is received, and will end in Completed 201 Created when successful. Check for errors within the block of log messages.

When viewing reports in Foreman’s UI, be aware that the default search is for “eventful” reports. Clear the search (‘x’) to see reports with no changes.

Expire reports automatically

You will probably want to delete your reports after some time to limit database growth. To do so, you can set a cronjob:

Available conditions:

days => number of days to keep reports (defaults to 7)

status => status of the report (defaults to 0 –> “reports with no errors”)

Example:

Expires all reports regardless of their status

foreman-rake reports:expire days=7

Expires all non interesting reports after one day

foreman-rake reports:expire days=1 status=0

3.5.5 Facts and the ENC

Foreman can act as a classifier to Puppet through the External Nodes interface. This is a mechanism provided by Puppet to ask for configuration data from an external service, via a script on the puppetmaster.

The external nodes script we supply also deals with uploading facts from hosts to Foreman, so we will discuss the two things together.

Configuration

Puppet master

Download the ENC script to /etc/puppetlabs/puppet/node.rb (Puppet 4 AIO) or /etc/puppet/node.rb (non-AIO). The name is arbitrary, but must match configuration below, and ensure it’s executable by “puppet” with chmod +x /etc/puppet/node.rb.

Unless it already exists from setting up reporting, create a new configuration file at /etc/puppetlabs/puppet/foreman.yaml (Puppet 4 AIO) or /etc/puppet/foreman.yaml (non-AIO) containing

Edit the URL field to point to your Foreman instance, and the SSL fields for the hostname of the Puppet master (which may be the same host). Paths to Puppet’s SSL certificates will be under /etc/puppetlabs/ssl/ when using Puppet 4 with AIO. More information on SSL certificates is at Securing communications with SSL.

Add the following lines to the [master] section of puppet.conf:

[master]
external_nodes = /etc/puppet/node.rb
node_terminus = exec

Restart the Puppet master. When the next agent checks in, the script will upload
fact data for this host to Foreman, and download the ENC data.

The --no-environment option can be optionally specified to stop the ENC from
being authoritative about the agent’s Puppet environment. This can be useful
in development setups where the agent may be run against different
environments.

Client

No agent configuration is necessary to use this functionality.

Testing the config

Make sure that the puppet user can execute the ENC script and it works:

Debugging the ENC

If Puppet agents receive empty catalogs, check the puppet.conf master configuration has the ENC script configured. Also check the output of the ENC for the hostname logged by Puppet (which may be different) to see if Foreman is reporting the correct configuration.

If the hostname.yaml facts file is missing, this is typically a Puppet misconfiguration. Check /etc/puppet/rack/config.ru has been updated if Puppet has been upgraded.

Failures to upload facts or download the ENC data may be a network issue (check the URL and SSL settings) or an error on the Foreman server. Check /var/log/foreman/production.log for two requests, POST "/api/hosts/facts" and GET "/node/client.example.com?format=yml" and for any errors within the block of log messages.

Assigning data to hosts through the ENC

Foreman passes all assoicated parameters, classes,and class parameters, to the Host,
including those inherited from host groups, domains, or global settings. See section
Managing Puppet for
more information on assigning configuration to hosts.

Creating hosts in Foreman with facts

By default, Foreman adds hosts to its database that it learns about through facts,
provided the “create_new_host_when_facts_are_uploaded” setting is enabled.

If locations or organizations are enabled, these can be inferred from the
“foreman_location” or “foreman_organization” facts as supplied by the host. The
names of these facts can be changed with the “location_fact” and
“organization_fact” settings respectively. Foreman will update hosts on each
fact upload based on the value of these facts.

If these facts aren’t supplied, then the “default_location” and
“default_organization” settings can be used to set values globally when a
host doesn’t have a location or an organization set.

The ‘certname’ is optional but will be used to location the Host in Foreman if
supplied. The ‘facts’ hash must be a flat hash, not nested with other arrays or hashes.
See link-to-API-when-its-updated-here for more details.

This body can be POSTed to ‘/api/hosts/facts’ using Foreman API v2. See the
node.rb template for an example of constructing and sending data in Ruby.

3.5.6 CLI

The Command Line Interface is based on the hammer framework. The foreman-related commands are defined in plugin hammer_cli_foreman

Format and locations

Configuration is loaded from a set of directories in this order:

./config/hammer/ (config dir in CWD)

/etc/hammer/.

~/.hammer/

custom location specified on command line - -c CONF_FILE_PATH

In each of these directories hammer tries to load cli_config.yml and anything in the cli.modules.d subdirectory which is the recommended location for configuration of hammer modules.

Later directories and files have precedence if they redefine the same option. Files from cli.modules.d are loaded in alphabetical order.

Hammer uses yaml formatting for its configuration. The config file template is contained in the hammer_cli gem.

gem contents hammer_cli|grep cli_config.template.yml

and can be copied to one of the locations above and changed as needed. The packaged version of hammer copies the template to /etc for you.

Plugins

Plugins are disabled by default. You have to edit the config file and enable them manually under modules option, as can be seen in the sample config below.

Plugin specific configuration should be nested under plugin’s name.

Options

:log_dir: <path> - directory where the logs are stored. The default is /var/log/hammer/ and the log file is named hammer.log

Sample config

3.6 Upgrade

Upgrading to Foreman 1.16

Preparation

Before updating to 1.16, make sure you have successfully upgraded to 1.15 first.

Upgrading across more than one version is not supported, so it’s required to upgrade to each
intermediate version and follow all upgrade instructions for the previous versions.

Check the list of Supported Platforms
when planning to upgrade, as these change between releases. If your OS is no
longer supported by Foreman, migrate or upgrade the OS (if supported) using a
release of Foreman supported by both OS versions before upgrading Foreman.

Step 1 - Backup

It is recommended that you backup your database and modifications to Foreman
files(config/settings.yaml, unattended installations etc). Most upgrades are
safe but it never hurts to have a backup just in case.

For more information about how to backup your instance head over to
Backup

Step 2 - Perform the upgrade

Before proceeding, it is necessary to shutdown the Foreman instance (e.g.
service httpd stop or service apache2 stop usually).

Now it’s time to perform the actual upgrade. This process if different
depending on how you downloaded Foreman. You only need to perform one of
the following options.

Step 2 (A) - Fedora or RHEL package (RPM) and installer setups

To upgrade an existing Foreman installation, first update with the
appropriate foreman-release package for your operating system:

Optional Step 3 (C) - Run foreman-installer

If you used foreman-installer to set up your existing Foreman instance we
recommend running it again after upgrading. Note that the installer can
modify config files so this may overwrite your custom changes. You can run
the installer in noop mode so you can see what would be changed.

To see what would happen

foreman-installer --noop --dont-save-answers --verbose

You may see ERRORS such as /Stage[main]/Foreman_proxy::Register/Foreman_smartproxy[foreman-hostname.domain]:Could not evaluate: Connection refused - connect(2) due to httpd / apache2 service being stopped. These can be safely ignored.

To apply these changes, run the installer again without options

foreman-installer

Step 4 - Restart

Restart the application server (e.g. mongrel, thin, passenger).

On RPM installations, run:

service httpd restart

And on Debian/Ubuntu installations with Passenger, run:

service apache2 restart

Optional Step 5 - Cleanup of RPMs and repositories

On EL6/7, consider removing the unmaintained softwarecollections.org
repositories, which are replaced by the CentOS SCLorg repos:

yum erase rhscl-\*

And consider removing unused SCL packages:

yum erase ruby193\* rh-ror41\*

Common issues

4. General Foreman

This section covers general information on using Foreman to manage your infrastructure. It covers the features of the web interface, managing puppet, provisioning systems and the installation and configuration of Foreman Smart Proxies.

4.1 Web Interface

4.1.1 LDAP Authentication

Setting up

Go to Administer > LDAP Authentication, click on New LDAP Source and enter the following details about the LDAP server:

Name: an arbitrary name for the directory

Server: the LDAP hostname, e.g. ldap.example.com

LDAPS: check this if you want or need to use LDAPS to access the directory

Port: the LDAP port (default is 389, or 636 for LDAPS)

Server type: select the implementation if listed, else choose POSIX

Under the account tab, the details of an account used to read LDAP entries is required if anonymous binds and reads are disabled. This should be a dedicated service account with bind, read and search permissions on the user and group entries in the directory server.

This may use the variable $login which will be replaced by the login of the authenticating user, however this is deprecated and will result in reduced functionality (as it only works at authentication time).

Account: leave this field empty if your LDAP server can be read anonymously, otherwise enter a user name that has read access

Account password: password for the account, if defined above and when not using $login

Trusting SSL certificates

When configuring an LDAPS connection, the certificate authority needs to be trusted.
When using Active Directory Certificate Services, ensure to export the Enterprise PKI CA Certificate using the Base-64 encoded X.509 format.

If your LDAP server uses a certificate chain with intermediate CAs, all of the root and intermediate certificates in the chain must be trusted.

On the fly user creation

By checking Automatically create accounts in Foreman, any LDAP user will have their Foreman account automatically created the first time they log into Foreman.

If organizations/locations are enabled, you can assign multiple organizations/locations to your LDAP authentication sources. This will assign users that are automatically created to the set of organizations/locations associated with the LDAP authentication source. Please notice this assignment happens only when users are created automatically via LDAP, and not upon every login.

Changing the organization/location of a LDAP authentication source will not automatically change these attributes on the users in that authentication source.

To use this feature, the relevant LDAP attributes must be specified on the next tab (e.g. firstname, lastname, email), as these will be used to populate the Foreman account.

Attribute mappings

Foreman needs to know how to map internal user account attributes to their LDAP counterparts, such as login, name, and e-mail. Examples for common directory servers are provided below.

Note that LDAP attribute names are case sensitive.

Foreman also has the ability to use a user’s photo stored in LDAP as their Foreman avatar, by setting the jpegPhoto attribute mapping.

Examples

All of the examples below use a dedicated service account called ‘foreman’. This should be set up with bind, read and search permissions on the user and group entries and with a strong, random password.

Active Directory

Typically either LDAPS on port 636 or LDAP on port 389.

Setting

Value

Account

DOMAIN\foreman

Base DN

CN=Users,DC=example,DC=COM

Groups base DN

CN=Users,DC=example,DC=com

Login name attribute

userPrincipalName

First name attribute

givenName

Surname attribute

sn

Email address attribute

mail

Note that previously we recommended using sAMAccountName as the login name attribute. It turned out that userPrincipalName is a better choice since it does not contain white spaces that can cause issues on user creation.

FreeIPA

Typically either LDAPS on port 636 or LDAP on port 389.

Setting

Value

Account

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

Base DN

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

Groups base DN

cn=groups,cn=accounts,dc=example,dc=com or cn=ng,cn=compat,dc=example,dc=com if you use netgroups

Linking user groups to LDAP

A Foreman user group can be associated to a group stored in an LDAP server, so membership of the LDAP group automatically adds a user to the Foreman user group. User groups can be associated with roles, enabling users to log into Foreman and be automatically granted permissions via their membership of an LDAP group. Read more about permissions in the Roles and Permissions section.

To configure the association, create or edit a user group via Administer > User groups. The group name may be any value (no direct relation to the LDAP group). Under the Roles tab, select roles granting permissions to Foreman, or tick the Admin checkbox to enable administrator level access.

On the External groups tab, click the Add external user group button to open a new form. In the Name field, enter the exact name of the LDAP group (usually the common name/CN) and select the server from the dropdown list of LDAP authentication sources. Click the Submit button to save changes.

When a user logs in for the first time (assuming on the fly account creation), the ldap:refresh_usergroups cronjob runs (every 30 minutes by default) or the Refresh button is pressed next to the external user group entry, Foreman will synchronize the group membership from LDAP.

Security Disclaimer

Please remember your external user groups will only be refreshed automatically through the ldap:refresh_usergroups cronjob. There can be a lapse of time cronjob runs, in which if the user groups in LDAP change, the user will be assigned to the wrong external user groups. This situation can be quickly fixed by manually running foreman-rake ldap:refresh_usergroups or by refreshing the external user groups in the UI. Otherwise, the problem will eventually get fixed when the cronjob runs again.

Active Directory password changes

When using Active Directory, please be aware that users will be able to log in for up to an hour after a password change using the old password. This is a function of the AD domain controller and not Foreman.

To change this password expiry period, see Microsoft KB906305 for the necessary registry change.

Troubleshooting

If you want to use on the fly user creation, make sure that Foreman can fetch from your LDAP all the required information to create a valid user.
For example, on-the-fly user creation won’t work if you don’t have valid email adresses in your directory (you will get an ‘Invalid username/password’ error message when trying to log in).

4.1.2 Roles and Permissions

A user’s access to the features of Foreman are constrained by the permissions that they are granted. These permissions are also used to restrict the set of hosts, host groups and other resources that a user is able to access and modify.

Note: a user with global admin enabled is not restricted by the authorization system. This is the default for installations that do not have :login:true in config/settings.yml.

A logged in user will be granted the Default role role plus one or more additional roles. The permissions and filters associated with these roles are aggregated and determine the final permission set.

Roles may be administered by users with admin privileges or regular users with ‘edit_roles’ permission. In order to add new filters and permissions to a role, regular users must have the ‘create_filters’ permission.

Roles

These may be created, deleted and edited on the Roles page. Each role will contain permission filters, which define the actions allowed in a certain resource. Once your role is created, you can associate it with one or more users and user groups.

There is one built-in system role, ‘Default role’. This is a set of permissions that every user will be granted, in addition to any other roles that they have. Foreman provides you with a set of seeded roles. These roles can be assigned to users but cannot be modified in any way. They serve as a sane set of defaults and a quick starting point. If you wish to base your custom role on one of these, you can clone it and modify the clone.

Roles can be also associated to Locations or Organizations if these are allowed. Unlike other objects this does not mean that Roles would be only available in a particular scope. Roles are always global for the entirety of Foreman. The association means that filters of such role are scoped to a particular Organization or Location. Imagine you want to create a role representing Administrator of Organization A. You can clone an existing Organization admin role and associate it with Organization A. If you later assign this role to some users, they will be granted all admin permissions but only on resources of Organization A. Note that some resources are not scopeable by Organization and Locations. Filters for such resources grant permissions globally.

The seeded Organization admin role is similar to the Manager role. They are both being automatically extended with permissions introduced in new Foreman versions, as well as permissions introduced by plugins. The difference is that Organization admin role does not contain permissions for managing organizations, only for viewing them. Since organization administrator does not usually need to create or modify other organizations, the Organization admin role fits better this scenario.

Filters

Filters are defined within the context of a role, clicking on the ‘filters and permissions’ link. A filter allows an user to choose a resource (Hosts, Host groups, etc…) and the permissions that should be granted for that resource. After a filter has been created, users given a role containing this filter will have the permissions for the resource specified at the filter.

If the filter is marked as ‘Unlimited?’, the permissions created in this filter will apply to all objects in the chosen resource. For instance, if the resource is Host, and the permissions are ‘view’ and ‘index’, and ‘Unlimited?’ is checked, users that have a role with this filter will be able to ‘view’ and ‘index’ all hosts in the system.

When ‘Unlimited?’ is unchecked, a text box allowing to define more granular filtering will be enabled. You can write a search query and permissions in this filter will be applied to the results of that query only. An example of a query for the resource Host could be ‘os = RedHat’. In this case, the permissions in this filter will be applied only to Hosts whose Operating System is set to Red Hat. You can test your search queries at the index page of your resource, in this case that would be ‘/hosts’.

Some example queries for the resource Host:

Ownership and domain membership: ‘owner_id = 95 and domain = localdomain’ - Will apply permisisons to hosts owned by User with id 95 and in the domain ‘localdomain’

Fact filtering: ‘facts.alarmlevel = high’ - Will apply permissions to hosts with a fact ‘alarmlevel’ with value ‘high’. As a fact is only generated during a puppet run, this filter will only refer to machines that have been built and therefore cannot be used to restrict the creation of machines.

These pools of queries can be combined by adding them together or the filters can be used to restrict the selected resource to a smaller and smaller subset of the total. Think of them as set operations.

As already mentioned, a Role can be assigned to Organizations and Locations. In such case, all filters for resources that support such scoping automatically apply the same Organizations and Locations. If you want to combine filters with different Organizations or Locations assignments, you can use ‘Override’ check box. When checked you can override Organizations and Location for a filter. If you uncheck this field, the filter starts inheriting its role Organizations and Locations after submitting again. If you want to reset all role filters to start inheriting, you can use ‘Disable all filters overriding’ button on role’s ‘Filters’ tab.

We recommend managing Organizations and Locations association on Role level to keep the setup simple and clear.

Note: If the “Administrator” check box is checked for a user, filtering will not take effect.

Permissions

These determine the operations that are allowed to be performed upon the resources to which they refer. For a few simple items like bookmarks, this operates as expected - it grants permission for all bookmarks. But for most resources, such as the hosts a user is able to operate on, there is an additional layer of security called filtering.

When editing a filter there is a search field at the bottom that narrows the scope of the permissions granted to a subset of the resource objects. Most permission types support this search field however there are some exceptions. The permission for creating objects can’t be limited by a search query because the object does not exist during creation. Therefore a user is granted the create permission if they are associated with any filter containing this permission (limited by search or not).

The user is allowed to see this type of object when listing them on the index page

create

The user is allowed to create this type of object

edit

The user is allowed to edit this type of object

destroy

The user is allowed to destroy this type of object

Permissions for Domains

view

The user is allowed to see a list of domains when viewing the index page

create

The user is allowed to create a new domain and will also be able to create domain parameters

edit

The user is allowed to edit a domain and will also be able to edit a domain's parameters. If they have domain filtering active in their profile then only these domains will be editable

destroy

The user is allowed to destroy a domain and will also be able to destroy domain parameters. If they have domain filtering active in their profile then only these domains will be deletable

Permissions for Host groups

view

The user is allowed to see a list of host groups when viewing the index page

create

The user is allowed to create a new host group and will also be able to create host group parameters

edit

The user is allowed to edit a host group and will also be able to edit a host group's parameters. If they have host group filtering active in their profile then only these host groups will be editable

destroy

The user is allowed to destroy a host group and will also be able to destroy host group parameters. If they have host group filtering active in their profile then only these host groups will be deletable

Permissions for Hosts

view

The user is allowed to see a list of hosts when viewing the index page. This list may be constrained by the user's host filters

create

The user is allowed to create a new host. This operation may be constrained by the user's host filters

edit

The user is allowed to edit a host. This operation may be constrained by the user's host filters

destroy

The user is allowed to destroy a host. This operation may be constrained by the user's host filters

Permissions for Users

view

The user is allowed to see a list of users when viewing the index page. A user will always be able to see their own account even if they do not have this permission

create

The user is allowed to create a new user

edit

The user is allowed to edit existing users. A user will always be able to edit their own basic account settings and password

destroy

The user is allowed to delete users from the system

4.1.3 Trends

Trends in Foreman allow you to track changes in your infrastructure over time. It allows you to track both Foreman related information and any puppet facts. The Trend pages give a graph of how the number of hosts with that value have changed over time, and the current hosts list.

There are two pieces to the Trends area, the Trends to track and their corresponding counters. To define trend counters, use the “Add Trend Counter” button on the ‘/trends’ page. Optionally set the “Name” field to over-ride odd puppet fact names to be more readable. Once created you can optionally ‘Edit’ the Trend to change the display names of the underlying values.

Next, to start collecting trend data, set a cron job to execute ‘foreman-rake trends:counter’. Each time the rake task executes it will create 1 tick on the graphs, so you can fine tune the granularity with your cron job. We recommend using the same as your puppet run interval (30 minutes). Here’s an example to run once per hour:

0 **** /usr/sbin/foreman-rake trends:counter

Finally note that these trends are the same for all users. So if you delete a Trend category you will loose all history for that trend and the trackers will start all over again. So please be careful when deleting.

4.1.4 Auditing

Foreman supports auditing of almost all changes that happen within Foreman, from both the UI and from the API. Auditing is done at a user level, and is thus ineffective if :login: is set to false, as all audits will be done as the ‘admin’ user.

Basic View

Go to the Audit tab to see a view of what has changed. This view can be
filtered by the type of change or by the object that was altered (e.g. search
for a hostname to see all changes relating to that host). You also get the
parent object - so if a parameter was modified, you can see what host/group that parameter belongs to. The timestamp of the change and the user who performed it will be listed.

Extended Audits for Templates

Template changes also store a diff of the changes, and the ability to roll back to a previous version of the template.

4.1.5 Searching

Each page in Foreman has its own search functionality, which is centred around the resources that it manages, allowing searching based on attributes of the resources in the list or resources that they’re associated to. The search box also features powerful auto-completion to help build up search queries and free text search on many pages. The search functionality can also be used in the API when listing resources, see Customize JSON Responses for details.

General usage

Searching is through “field = value” or free text queries, which can be combined with logical operators (and, or, not) and parentheses to handle more complex logic. To give some examples:

name = client.example.com on the host list would show the host(s) whose hostname is client.example.com

hostgroup = "Web servers" and domain != lon.example.com would show hosts in the Web servers host group, but not in the lon.example.com domain

Web servers would show all hosts with that text anywhere, e.g. as their host group name or in the comment field

The fields available depend on the type of resource that’s being searched, and the names of the attributes vary depending on the context. The “name” field on the host groups list is equivalent to the “hostgroup” field on the hosts list. Requests to add additional searchable fields are welcome, and may be filed in the “Search” category in the bug tracker.

The search engine is provided by the scoped_search library, which maps search queries directly to SQL queries. The Query Language documentation provides A more complete specification of the syntax available.

Bookmarks

Foreman supports the ability to make search bookmarks, allows users to quickly jump to predefined search conditions. Available bookmarks can be selected from the dropdown menu to the right of the search box, or managed from Administer > Bookmarks.

Some of the bookmarks are provided by default, e.g. to search for active or inactive hosts, or to only view reports with events.

To save a query, Use the dropdown menu to the right of the search box and click “Bookmark this search”. When saving, the bookmark can be labeled as public, so all other users are able to see and use it too.

Free text search

If you ignore the auto-completer and just enter text in the search field, Foreman will try searching for that text across multiple fields.

For example, if you just enter 12 in the the hosts search box, the results will include all hosts with 12 in their IP address, MAC address or name. In general the fields used for free text search are kept to a minimumfor performance and accuracy reasons. It’s preferable to search using a specific field, e.g. when searching for an IP address, use ip ~ 12 instead of 12.

Searching for present/empty values

The “has” operator matches values that are present, e.g. to search for hosts that are on a compute resource, use has compute_resource.

Similarly, this can be negated, so to search for hosts without host groups, you can use not has hostgroup.

Case sensitivity

When querying using = and != operators then exact, case sensitive matches will be returned. When running ~ (like) and !~ (unlike) operators, the matching is case insensitive.

Quoting

In search queries, white spaces are used as a delimiter. Here are some examples of the way a query will be interpreted:

description ~ created successfully: list all notifications that contain “created” and at least one of its text fields contains “successfully”

description !~ created successfully: list all notifications that doesn’t contain “created” and at least one of its text fields contains “successfully”

In the second and third example, “successfully” is an additional term that is interpreted as a free text search

Wildcards (‘_’, ‘%’, ‘*’)

The ~ and !~ search operators are translated to the LIKE and NOT LIKE SQL queries respectively, which support two basic wildcards, _ and %.

_ is a wildcard for a single character replacement. For example, the search name ~ fo_ will match both “foo” and “for”.

The % and * wildcard will replace zero or more characters. For example, the search name ~ corp% will match both “corp” and “corporation”. The more common ‘*’ wildcard is not a SQL wildcard but may be used instead.

When the ~ or !~ search is processed, a ‘%’ wildcard is automatically added at the beginning and end of the value if no wildcard is used, so it will by default match at any location inside a string. For example, the search name ~ foo is equivalent to name ~ %foo% and the search name ~ foo% will only match “foo” at the beginning of the value.

Date-time search query syntax

Many date and time formats are accepted in search queries. Here are some examples:

“30 minutes ago”, “1 hour ago”, “2 hours ago”, Today, Yesterday

“3 weeks ago”, “1 month ago”, “6 days ago”, “July 10,2011”

The date can have different separators, “10-July-2011” will be interpreted in the same way as “10/July/2010” or “10 July 2011” Month names may be the full English name or a three letter abbreviation, e.g. “Jan” will be interpreted as “January”. Many other formats are also acceptable, however it is not recommended to use ambiguous formats such as “3/4/2011”

The valid date time operators are ‘=’, ‘<’ and ‘>’ which are interpreted as ‘at’, ‘before’ and ‘after’ respectively. This is how the search term interpeted:

The right hand part of a date-time condition is parsed and translated into a specific date-time, “30 minutes ago” is translated to “now - 30 minutes”.

last_report > "2011-07-01 12:57:18 EDT" should be read as created after this time

In the same way, last_report > "30 minutes ago" should be read as “created after 30 minutes ago” and not “created more then 30 minutes ago”

A search query like installed_at = Yesterday is translated into a period query, it will be translated at runtime to match a range of date-times. For example, if running on Jan 1, it would be translated into “(installed_at >= Jan 1,2012 00:00) and (installed_at < Dec 31,2011 00:00)”.

4.1.6 User Management

Foreman is all about hosts and users interacting with these hosts.

SSH Keys

Each Foreman user can have multiple SSH keys assigned when editing a user. These keys alone do not serve any purpose, but are available for use in provisioning templates and can be accessed via ENC data. They provide an easy way to manage users and login ssh keys on hosts without the need for LDAP.
If you want users to be able to login to a host using the data provided in Foreman, you need to include the create_users snippet in your provisioning template. There is a puppet module available to keep user data in sync with Foreman and your hosts.

4.2 Managing Puppet

In this section we’ll look at the various ways we can control and interact with Puppet.

4.2.1 Environments

Puppet environments are mapped directly into Foreman. They can be used at various levels throughout the Foreman interface. Puppet environments are generally used to separate classes from different types of Host, typically allowing changes to a module to tested in one environment (e.g. development) before being pushed to another (e.g production).

Defining environments

There are several ways to create Puppet environments within Foreman.

Importing from Puppet

Foreman can detect all the environments and classes contained on a Puppet master, and import them automatically. To do this, go to Configure > Environments and click on Import from <proxy-name>. Foreman will scan the Puppet master via the Smart Proxy, and display a confirmation of the detected changes. Select the changes you wish to apply and confirm.

More information about configuring the Smart Proxy to read environments and Puppet classes is in the Smart Proxy Puppet section.

Note that the Smart Proxy will only detect environments that contain one or more Puppet classes, so ensure that at least one Puppet module containing a class has been deployed to the Puppet master.

Manual creation

To create an environment by hand, simply go to Configure > Environments and click New Puppet Environment. Give the new environment a name and save. Note that if the environment doesn’t exist on the Puppet master and you subsequently run an import (above), Foreman will prompt for the environment to be deleted.

Assigning environments to hosts

This is done from the Host Edit page, on the Host tab. Selecting an environment will filter the classes visible on the Puppet Classes tab to just the classes in the selected environment.

You can also also mass-assign an environment to a group of hosts - tick the checkboxes of the required hosts in the Hosts list, and then select Change Environment from the Select Action dropdown menu at the top of the page.

Environments with host groups

You can assign an environment to a hostgroup as well. This functions as a form
of default - a user creating a new host and selecting the hostgroup will
automatically have the environment pre-selected. The user is not prevented from changing the environment of the new host, it simply saves a few clicks if they are happy with it.

4.2.2 Classes

Puppet classes are generally imported from the Puppet Master(s) via the Import
button on the Puppet Classes page. They can also be created by hand, and
manually associated with a set of environments (for filtering purposes).

Importing Classes

Go to Configure > Classes and click the Import button. This will not be visible unless you have at least one Puppet Master with a puppet-enabled Smart Proxy. Only classes from modules will be imported, and the Puppet manifests must be valid in order for the Smart Proxy to parse them. Use puppet parser validate to test the syntax of Puppet manifests.

More information about configuring the Smart Proxy to read environments and Puppet classes is in the Smart Proxy Puppet section.

The “Hosts” Column

Under Configure > Classes you will also see a column called “Hosts”. This column represents the number of hosts the given module/class has been assigned to. Clicking this figure will list the hosts.

However, if we know that the subclasses are not intended for direct consumption, but are only really part of the internal structure of the module, then we would want to exclude those from the import mechanism, so that Foreman only offers to import git. We can achieve this via the file /usr/share/foreman/config/ignored_environments.yml.

This file is read during each import, causing Foreman to ignore changes to the listed environments or Puppet classes that match the expressions in the file. It will not delete any environments or classes already in Foreman.

Entire environments can be ignored with this configuration:

:ignored:-development-testenv

Classes can be ignored using a set of regular expressions - any class which matches one of them will not be imported. So, for the above example, we might configure:

Regular expression features such as negative lookaheads can be used for more advanced filtering, e.g. to ignore all classes except for those starting with “role::”, the following syntax can be used:

:filters:-!ruby/regexp'/^(?!role::)/'

Assigning classes to hosts

To cause Puppet to apply your classes, you will need to assign them to your
hosts. This can be achieved in a number of ways - the best method may vary
depending on how many classes you intend to assign and whether any parameters
need to be overridden.

Individual host assignment

When editing a host, Puppet clases may be assigned directly under the Puppet
Classes tab. All classes that are in the Puppet environment selected on the
first Host tab will be listed.

Via a host group

Host groups tend to correspond to an infrastructure role as each host may be
assigned to a single host group, and typically inherits most of its Puppet
classes in this way.

Puppet classes can be assigned by editing the host group and selecting them
on the Puppet Classes tab.

Most host group attributes are copied to a host when it is created, however
Puppet class associations remain inherited from the host group throughout its
lifetime. Any change to a host group’s assigned Puppet classes or parameters
will affect any host with that host group set.

The Puppet environment attribute may be different on the host to the host
group, which means that Puppet classes assigned to the host group may not
exist in the host’s own Puppet environment. Any Puppet classes that are
inherited from the host group, but do not exist in the host’s environment will
be left out when Foreman renders the ENC (YAML) output. Check under
Configure > Puppet classes that the classes are available in both the host
group and host environments if they differ.

You can also also mass-assign a host group to a number of hosts - tick the
checkboxes of the required hosts in the Hosts list, and then select Change
Group from the Select Action dropdown menu at the top of the page.

Using config groups

A config group provides a one-step method of associating many Puppet classes
to either a host or host group. Typically this would be used to add a
particular application profile or stack in one step.

To create a config group, click on Configure > Config groups, click New
Config Group, enter a name and select the desired Puppet classes. When
editing either a host or host group, the new config group can be added at the
top of the Puppet Classes tab.

Config groups are not specific to an environment and so only those Puppet
classes that are in the host’s environment when rendering the ENC (YAML) will
be listed. Any classes that are not listed in the environment (as per
Configure > Classes) will be left out.

Note that it isn’t possible to use a smart class parameter override with a
config group, as a host may have many config groups with no way to define an
order of precedence. Overrides should be made on a host group, host or other
attribute.

Checking the results

To see how Foreman is passing the classes to Puppet, go to a Host and click the YAML button. You will be shown the exact YAML data sent to the Puppet master - the classes will be in the “classes” hash.

4.2.3 Parameters

Foreman can pass two types of parameters to Puppet via the ENC (External Node Classifier) interface - global parameters (accessible from any manifest), and class parameters (scoped to a single Puppet class). These can be added in a number of ways through Foreman.

Generally speaking, it’s best to use class parameters where possible, as this makes designing, using and sharing Puppet modules and classes easier. The class may clearly specify which parameters it expects, provide sensible defaults and allow users to override them. Foreman is also able to import information about class parameters automatically, making it easier to consume new classes without needing to know and enter the precise names of global parameters.

Types of parameters in Puppet

In Puppet’s DSL, accessing a global parameter or variable is done using $::example (preferred) or $example for a parameter named “example” in Foreman. More information about accessing variables is available in the Puppet Language: Variables documentation. When looking at the ENC (YAML) output from Foreman, a global parameter will look like this:

parameters:example:"foobar"

When using class parameters, a class will first be defined with a parameter and may be accessed either using the local name or fully-qualified, e.g.

The final (most specific) level of global parameters applies only to a single host. Edit a Host and switch to the Parameters tab, and you will see all of its inherited parameters from the previous levels. You can override any of these previously-defined parameters or define new ones here.

Checking the results

To see how Foreman is passing the parameters to Puppet, go to a Host and click the YAML button. You will be shown the exact YAML data sent to the Puppet master - the parameters will be in the “parameters” hash.

4.2.4 Smart Variables

Smart variables are a tool to provide global parameters (key/value data), normally to your Puppet ENC, depending on a set of rules. They are intended to be a stepping stone to full parameterized classes, when the class hasn’t been parameterized or in special cases when a global parameter is desired. The same matching/rules technology underpins both smart variables and smart class parameters. If in doubt, use smart class parameters.

Smart variables are associated with a Puppet class, but they result in a global parameter. They may have multiple possible values, all depending on hierarchical context or various conditions a user can wish to apply. For example:

Creating a smart variable

Start by going to Configure > Classes and then click one of your classes to edit it.

Click on the Smart Variables tab. If you have any existing smart variables, they will be listed at the left side of the tab.

Click New Variable, and you will be presented with a set of input fields:

Parameter

What the parameter will be called in the ENC data

Parameter type

This dropdown allows validating that all values are of the correct type

Description

A free form text box for your own information

Default Value

Value supplied to the ENC if no other criteria is matched

Hidden value

Should the values of the smart variable be hidden in the UI

Once you’ve created the defaults for your smart variable, you can then add at least one criterion to match against - click the “Add Matcher” button at the bottom of the form and a new row will be added to the matchers table:

Attribute type

Should state a name = value relationship that Foreman use to match against the entries in searchlist

Value

What the parameter should be in the ENC, if this rule is matched

Advanced usage

Smart variables are based on the smart matchers technology, and have a number of advanced features such as validation and multiple data types. More about these can be found in the Smart Matchers section.

API usage

It’s also possible to retrieve these values if you’re not using a ENC, via a custom Puppet function or a http request.. You’ll need to retrieve the value from

4.2.5 Parameterized Classes

Parameterized class support permits detecting, importing, and supplying parameters direct to classes which support it, via the ENC. This requires Puppet 2.6.5 or higher.

Setup

By default, parameterized class support is enabled in Foreman. This can be checked from Administer > Settings > Puppet and ensure Parametrized_Classes_in_ENC is set to true.

Now you’ll need to import some parameterized classes from your Puppet master.
If you don’t have any parameterized classes in your modules dir, the
foreman-installer has several, you can download a few modules from the Puppet
Forge. Once you have some parameterized modules, import your classes (see
4.2.2 Classes)

Configure a class

This example will work with the foreman class from the installer. Click on the class, and you should get a page with 3 tabs, like so:

The middle tab, “Smart Class Parameter”, is the important one. Click onto that, and you should see something like this:

On the left, we have a list of possible parameters that the class supports. On the right, we have the configuration options for the parameter selected.

Lets configure the foreman class to change the user the foreman processes run as. Select the user parameter, at the end of the list. Now lets go through the options:

Puppet Environments / Parameter

These can’t be edited, they’re just for information.

Description

Purely information textbox for making notes in. Not passed to Puppet, or reused anywhere else

Override (important)

If this is unchecked, Foreman will not attempt to control this variable, and it will not be passed to Puppet via the ENC.

Key type

The type of data we want to pass. Most commonly a string, but many other data types are supported. There’s no easy way to tell what type of data Puppet is expecting, so you will need to read through the code/documentation that comes with a particular module to find out. Changing the type field requires an appropriately set “Default Value” field.

Default Value

This will be imported from Puppet initially, but if Puppet is using any class inheritance, you’ll get something unhelpful like “${$foreman::params::user}”. This is because Foreman won’t follow the inheritance, so you’ll need to set a sensible default value

Hidden value

Should the values of the smart class parameter be hidden in the UI.

Ok, so let’s configure our user parameter. We want to tick Override, set type to “String” and set the default value to “foreman”, like so:

Tip: you can set Override on all parameters on a class from the Puppet classes list, clicking the dropdown menu on the right and clicking "Override all parameters".

Default value

Most importantly, the Override option has to be enabled for Foreman to control this variable, otherwise it will never be managed and will not appear in the ENC output.

The Default value will be supplied in the ENC output and should be a supported value, such as a string, YAML or JSON structure or use template features (see following sections). When the Omit checkbox is enabled, no default value will be present in the ENC output unless an override matches. Puppet will instead use the class default or data binding (Hiera) as usual.

The default will be imported from the Puppet manifest initially, but if the class uses an inherited params pattern, it may contain an unhelpful string such as ${$foreman::params::user}. Foreman is unable to parse the actual value in this case as it might change when evaluated. Change the suggested default to the actual value, or tick the Omit checkbox.

Setting up matchers

We’ve configured the default, but that’s not very useful. We need to be able to override the default for hosts or groups of hosts. To do that we need the “Override Value For Specific Hosts” section at the bottom of the page.

Let’s say that any machine in the “development” Puppet environment should use a value of “foremandev” instead of “foreman” for the “user” parameter. Add “environment” to the end of the matchers list, then click the “New Matcher-Value” button, and fill it out like this:

This is a basic configuration - for more complex examples of using matchers,
see the Smart Matchers section.

Overriding a parameter for a host

If Foreman manages the value of a class parameter (“override = true”), it’s also possible to update a host-specific override from the host itself. That way you don’t have to grant access to the Puppet Classes page to everyone. From a Host, click Edit, go to the Parameters tab, and you’ll see the variable, the class-scope, and the current value. You can then override the value for that host:

If the value is hidden you can click the unhide button to temporarily see the value while you edit. Clicking the button won’t change the hidden property for the parameter, only show it for editing purpose.

If you go back and look at the Puppet class, you’ll see Foreman has added a matcher for that host:

The same override button is available on a host group’s Parameters tab. For more complex logic, like matching on facts, use the Puppet Class page.

Advanced usage

Smart class parameters are based on the smart matchers technology, and have a number of advanced features such as validation and multiple data types. More about these can be found in the Smart Matchers section.

4.2.6 Smart Matchers

The same smart matching technology underpins both smart variables and smart class parameters, so is described below. It provides the following features for each parameter:

A default value that can be sent if no specific match is found.

An order of precendence for overrides, based on host attributes or facts.

A list of overrides (matchers).

Specifying a data type, allowing strings, integers and data structures to be passed natively to Puppet.

Optional validation of values.

Template processing of values for dynamic content.

Ordering

Overrides are processed in the order of precedence set in the Order field, from most to least specific (first match wins, unless merging is enabled). This is a list of host attributes and fact names that overrides will be checked against. If no override from this list matches, the default value is used.

Example attributes that may be listed are:

fqdn - host’s FQDN (“host.example.com”)

hostgroup - full name of the host group, including parents (“Europe/Web servers”). Matchers on host groups can be inherited by their children, see documentation for host_group_matchers_inheritance in configuration options.

os - name and version of operating system (“RedHat 6.4”)

domain - host’s domain name (“example.com”)

location or organization - full name of the location/organization, including parents (“Company/Subsidiary”)

The default order is set under Administer > Settings > Puppet > Default_variables_Lookup_Path and is “fqdn”, “hostgroup”, “os”, “domain”.

Note that there’s a name conflict between the “operatingsystem” fact and Foreman’s attribute “operatingsystem” (same as “os” above), and Foreman’s attribute will be the one that is used, so will include the version number.

Overrides / matchers

Once defaults have been filled in for your parameter, you can then add criteria to match against - click the Add Matcher button under your parameter, and more input fields will appear:

Attribute type

Should state a name = value relationship that Foreman use to match against the entries in the order list

Value

What the parameter should be in the ENC, if this rule is matched

Omit

Instead of providing a value, this parameter will not be supplied in the ENC output (use to prevent a default value being returned) - only for smart class parameters

As an example, let’s say that any machine in the “development” puppet environment should use a value of “foremandev” instead of “foreman” for the “user” parameter. Add “environment” to the end of the matchers list, then click the Add Matcher-Value button, and fill it out like this:

The match field currently supports string equality only, the values must match exactly.

Merging overrides

When the data type is a hash or array, ticking Merge overrides will cause values from every override that matches (e.g. an FQDN and domain) to be merged together.

Merging is “deep”, so nested hashes and arrays will gain values rather than being overwritten entirely.

The Merge default option adds the default value as one of the values to merge, it will get the least important priority so one of the other values may overwrite it.

When the data type is an array, the Avoid duplicates option will de-duplicate the resulting array.

Data types

The type of data we want to pass to Puppet can be set in the Parameter type field. Most commonly a string, but many other data types are supported:

String - Everything is taken as a string.

Boolean - Common representation of boolean values are accepted, including true, false, yes, no etc.

Integer - Integer numbers only, can be negative.

Real - Accept any numerical input.

Array - A valid JSON or YAML input, that must evaluate to an array.

Hash - A valid JSON or YAML input, that must evaluate to an object/map/dict/hash.

YAML - Any valid YAML input.

JSON - Any valid JSON input.

There’s no easy way to tell what type of data the Puppet manifest is expecting, so you will need to read through the code/documentation that comes with a particular module to find out. Changing the type field requires an appropriately set “Default Value” field.

Complex data

Here’s an example of adding an array parameter. Note the use of YAML in the edit box:

This will be converted to the JSON ["a","b"] syntax when you save. You can also use hashes in YAML or JSON as data types too.

Note that the JSON hash syntax is not the same as Puppet’s hash syntax: {"example":"value"}

Input validation

The Optional input validator section can be used to restrict the allowed values for the parameter. It is important to note that the validation applies to changes made from the Host edit page as well as the Puppet Classes edit page.

The input validation section is hidden by default but can be opened by clicking on its title. When changing the parameter type this section will be automatically expanded to change the validations according to the new type.

Validator type

A combobox of data types. The type applies to the next field, the validator.

Validator rule

Used to enforce certain values for the parameter values. See below for examples.

For example, to restrict the “user” field to either “foreman” or “foremandev”, tick the Required checkbox, and then set:

Type: List

Rule: foreman,foremandev

String validators

At present, the string type cannot be validated - leave the validator field blank, and all strings in the variable will be considered acceptable

Regexp / List validators

By entering a list (comma-separated, no spaces) or a regex (no delimiter required), the value to be assigned to the parameter will be checked against this list. If the value does not match the validator, and error will be raised.

Template variables

Because Foreman offers templating capabilities, you can utilise pre-existing variables, macros and or functions within your parameterized classes. This is especially useful if you need to send a string to Puppet/Chef, but have a need to embed host specific information within the string, such as the host’s FQDN.

Let’s look a quick example situation: we need to configure RabbitMQ and have it use our existing Puppet SSL certs. Using what we’ve learnt above, we jump into the RabbitMQ class and configure the “ssl cert” parameter as such:

As you can see we’re utilising a template variable within the parameter’s string just like we would in a normal template file. The important part of this string, as we’re sure you’ve gathered, is the “@host.name” element. This pulls the FQDN from Foreman’s facts and inserts it into the string.

Examples

Example 1 - Simple change to a single host

All our hosts use server.foo for something, except bob.domain.com which uses server2.bar:

Parameter

target

Description

The target server to talk to

Default Value

server.foo

Type Validator

string

Validator Constraint

Order

fqdn hostgroup os domain

Attribute type

fqdn = bob.domain.com

Value

server2.bar

Example 2 - Change for a group of hosts (via custom fact) with validation and ordering

Most hosts need to use a port of 80 but all machines with a fact region and value europe need to use 8080. To do this, you have to add the factname (in this example region) to the searchlist:

Parameter

port

Description

The port to use

Default Value

80

Type Validator

list

Validator Constraint

80,443,8080

Order

fqdn region hostgroup os domain

Attribute type

region = europe

Value

8080

Attribute type

fqdn = foo.domain

Value

67

Note that all machines will get either 80 or 8080 as required, except foo.domain which will generate an error, since 67 is not in the list validator. Note also that foo.domain will match before region, since it is higher in the searchlist. The rule ordering does not matter.

It is also possible to mix conditions, e.g.

Parameter

port

Description

The port to use

Default Value

80

Type Validator

list

Validator Constraint

80,443,8080

Order

fqdn region, hostgroup, environment hostgroup environment domain

Attribute type

fqdn = foo.domain

Value

67

Attribute type

region, hostgroup, environment = europe, "web servers", production

Value

8080

4.3 Smart Proxies

The Smart Proxy is a project which provides a restful API to various sub-systems.

Its goal is to provide an API for a higher level orchestration tools (such as Foreman).
The Smart proxy provides an easy way to add or extended existing subsystems and APIs using plugins.

If you require another sub system type or implementation, please add a new feature request or consider writing a plugin.

Once your smart proxy is running, each of the relevant sub systems needs to be configured via the settings.d/* files in the config directory.

4.3.1 Smart Proxy Installation

A smart proxy is an autonomous web-based foreman component that is placed on a host performing a specific function in the host commissioning phase.
It receives requests from Foreman to perform operations that are required
during the commissioning process and executes them on its behalf. More details
can be found on the Foreman Architecture page.

To fully manage the commissioning process then a smart proxy will have to manipulate these services, DHCP, DNS, Puppet CA, Puppet and TFTP. These services may exist on separate machines or several of them may be hosted on the same machine. As each smart proxy instance is capable of managing all the of these services, there is only need for one proxy per host.
In the special case of a smart proxy managing a Windows DHCP server, the host machine must be running Windows, it does not need to be the Microsoft DHCP server itself.

Packages

RPM and Debian packages are available, see the Install from Packages section for configuration and install the foreman-proxy package.

General configuration

On the command line, type the following command. Take care not to use an alias nor upper case characters.

puppet cert generate new-smart-proxy-FQDN

Copy the private key, the public certificate and the ca.pem from /var/lib/puppet/ssl on your puppetmaster over to a location accessible by your new smart proxy, e.g. <smart-proxy location>\ssl\ (create the directory if necessary - this location will be referred to by the settings.yml in the next step)

Copy settings.yml.example inside config to settings.yml

At very least, modify the settings for :bind_host: and :log_file: and SSL, for example:

Once everything runs well install a Windows service using ruby extra\register-service.rb to register the service Foreman Smart Proxy. Alternatively, use a third party tool like NSSM to create the service.

Windows Service Note (domain user):

The register-service.rb queries the user you are currently logged in with, and the syntax asking what user to run the service as can be confusing. If you would like to create the service as a domain user, simply type in the domain\username, when it asks “Run this service as this user?” You can also create the service as a local user, and change it to a different/domain user once the service has been created.

In order to use the service as a domain account, the domain user needs to be added to the local admin group, as well as allow that user rights to “Log on as Service”. You may run into “Error 1053: “The service did not respond in a timely fashion”, if these are not set correctly.
_
Caveats: There is an issue with DevKit not finding any ruby version installed. Check that the DevKit and Ruby Installer are both x32 or x64, otherwise add the missing versions manually by editing config.yml.

Puppet hint: If you have Puppet installed on the same host running smart-proxy, you can use Puppet’s Ruby. You only need DevKit. In this case, just add directory containing ruby.exe to your path variable and add it to DevKit settings if necessary by editing DevKit’s config.yml. Also, you might want to use Puppet’s host certificates right away for smart proxy SSL connections. Usually, they can be found in C:\ProgramData\PuppetLabs\puppet\etc\ssl. For example:

Configuration file

Usually can be found at /etc/foreman-proxy/settings.yml or in the config/settings.yml subdirectory.
You can use the settings.yml.example file inside the config directory as a template for your own settings.yml.

Configuration of each subsystem is usually in /etc/foreman-proxy/settings.d/ or in the config/settings.d/ subdirectory. If you don’t plan to use one of the subsystems, please disable them in these configuration files. For more information see Smartproxy Configuration.

Start the daemon

bundle exec bin/smart-proxy

Or if you installed it via a package simply start the foreman-proxy service.

service foreman-proxy start

Add the Smart Proxy to Foreman

Go to Foreman, under Infrastructure > Smart proxies, click New Proxy

Type in the Name for your Proxy and the URL of your Proxy, with the port used

For example:

Name: Puppet-Proxy

URL: http://puppet.your-domain.com:8443

4.3.2 Smart Proxy Settings

The main configuration for the core Smart Proxy is held in the /etc/foreman-proxy/settings.yml or config/settings.yml file. This includes configuration of ports to listen on, SSL and security settings and logging options.

Each of the modules used in the Smart Proxy have their configuration in the /etc/foreman-proxy/settings.d/ or config/settings.d directory. Modules are enabled or disabled inside their respective configuration files with the :enabled directive, which determines whether the module is available on HTTP, HTTPS, both or is disabled (see below for more details).

YAML start

The first non-comment line of all configuration files must be three dashes.

---

Daemon configuration (settings.yml)

If daemon is present and true then the Smart Proxy will attempt to disconnect itself from the controlling terminal and daemonize itself on startup, writing its pid (process ID) into the specified file.

:daemon: true
:daemon_pid: /var/run/foreman-proxy/foreman-proxy.pid

Logging (settings.yml)

The proxy’s output is captured to the the log_file and may be filtered via the usual Unix syslog levels:

The log_file setting may be set to “STDOUT” which causes log messages to be logged to standard output, for capture by the running process (e.g. systemd with journal). When log_file is set to “SYSLOG”, all messages will be sent to syslog.

A limited number of recent log messages are kept in memory using a ring buffer, which can be exposed in the API and to Foreman by enabling the Logs feature.

The number of all log messages is controlled by the log_buffer setting, and a second buffer of error messages is controlled by the log_buffer_errors setting. The total of the two will directly affect the maximum amount of memory used, which is approximately 500kB in the default configuration of 3,000 recent messages.

:log_buffer: 2000
:log_buffer_errors: 1000

Listening configuration (settings.yaml)

By default the Smart Proxy listens on all interfaces, which can be changed to limit access to a network:

The Smart Proxy has a number of different modules which can be enabled either for HTTP, for HTTPS or for access on both services. It is highly recommended to enable most only on HTTPS and only enable modules on HTTP when required (e.g. templates) or if no SSL is desired.

The two port options control which TCP port(s) the Smart Proxy will listen on. At least one must be enabled for the proxy to start. It is recommended to only set https_port unless an HTTP-only module is active, which also requires the three ssl_* settings to be set.

:http_port: 8000
:https_port: 8443

Be careful when enabling http_port, ensure settings.d/ files are enabled only on HTTPS or trusted_hosts is set appropriately so modules are not exposed without security on HTTP.

Modules are enabled in their per-module configuration file in /etc/foreman-proxy/settings.d/ with the :enabled directive, which can be set to:

:enabled: false to disable the module entirely

:enabled: http to listen on HTTP only

:enabled: https to listen on HTTPS only (recommended)

:enabled: true to listen on both HTTP and HTTPS if enabled (not recommended)

Security configuration (settings.yml)

The existence of all the three ssl key entries below requires the use of an SSL connection.

NOTE that both client certificates need to be signed by the same CA, which must be in the ssl_ca_file, in order for this to work
see SSL for more information

Specific SSL cipher suites can be disabled by using the :ssl_disabled_ciphers: option. For more information on which cipher suites are enabled by default and how to correctly disable specific ones, please see SSL cipher suites.

This is the list of hosts from which the smart proxy will accept connections. For HTTPS connections, the name must match the common name (CN) within the subject DN and for HTTP connections, it must match the hostname from reverse DNS.

:trusted_hosts:
- foreman.prod.domain
- foreman.dev.domain

For HTTPS connections, the name must match the common name (CN) within the subject DN and for HTTP connections, it must match the hostname from reverse DNS. When :forward_verify is enabled (default: true) then the reverse lookup is verified against the forward lookup of the hostname (aka forward-confirmed reverse DNS/FCrDNS).

Some modules may allow connections from all hosts rather than only the trusted_hosts list, particularly if they intend to deal with requests directly from managed hosts rather than only from Foreman.

An empty trusted_hosts list will permit no hosts access:

:trusted_hosts: []

While if the setting is not specified, any host may make requests to the smart proxy, which permits management of any enabled modules and features.

Foreman communication (settings.yml)

Some modules make requests back to Foreman, e.g. when relaying requests from client hosts. The following setting changes the destination URL:

:foreman_url: https://foreman.example.com

And the following settings change the SSL certificates used to authenticate to Foreman and to verify its certificate. In a typical installation, Foreman and the Smart Proxy may both use certificates signed the same certificate authority, so these default to the values of the ssl_* settings defined above.

# SSL settings for client authentication against Foreman. If undefined, the values
# from general SSL options are used instead. Mainly useful when Foreman uses
# different certificates for its web UI and for smart-proxy requests.
:foreman_ssl_ca: /etc/foreman-proxy/ssl/certs/ca.pem
:foreman_ssl_cert: /etc/foreman-proxy/ssl/certs/fqdn.pem
:foreman_ssl_key: /etc/foreman-proxy/ssl/private_keys/fqdn.pem

4.3.3 BMC

Activate the BMC management module within the Smart Proxy instance. This allows users to trigger power management commands through the proxy to controlled hosts using IPMI or similar.

4.3.4 DHCP

4.3.4.1 dhcp.yml

Activate the DHCP management module within the Smart Proxy instance. This is used to query for available IP addresses (looking at existing leases and reservations), add new and delete existing reservations. It cannot manage subnet declarations, which should be managed by another means (e.g. puppet-dhcp).

To enable the DHCP module and enable a provider, dhcp.yml must contain:

:enabled: https
:use_provider: dhcp_isc

For providers from plugins, check the plugin documentation to determine the exact provider name.

The module manages a DHCP server on the local host by default, but for providers that can be run remotely, the server address can be changed:

:server: 127.0.0.1

Note that if the DHCP server is running remotely, some providers (notably ISC) require that the configuration files must be accessible to the Smart Proxy still. This can be achieved with a network file system, e.g. NFS.

All available subnets will be loaded and can be managed by default, but this can have a performance penalty. If only some subnets are used, specify them as follows in network_address/network_mask notation:

Each provider has its own configuration file in the same directory with its own settings, e.g. dhcp_isc.yml. This usually needs additional configuration after changing the use_provider setting.

dhcp_isc

The dhcp_isc provider uses a combination of the ISC DHCP server OMAPI management interface and parsing of configuration and lease files. This requires it to be run either on the same host as the DHCP server or to have network filesystem access to these files.

This provider requires the config and leases settings in the dhcp_isc.yml configuration file, which should be set to the location of the DHCP server config and lease files. On a Red Hat or Fedora server use:

dhcp_native_ms

When disable_ddns is true (default), dynamic DNS updates will be disabled for all hosts that the smart proxy creates. This will slightly slow the host creation process but will ensure that the DHCP server will not create or delete DNS entries on behalf of these clients. It’s preferable to disable this feature at the scope level.

dhcp_libvirt

Provider that manages reservations and leases via dnsmasq through libvirt API.
It uses ruby-libvirt gem to connect to the local or remote instance of libvirt
daemon.

4.3.4.3 MS DHCP

It is required that this procedure is executed as an administrator.

It is not required that the smart proxy be on the same host as the MS DHCP server. The smart proxy just needs to be on a Windows host with connectivity to the DHCP server. If this is the case, make sure the smart proxy service runs as a user with sufficient privileges.

4.3.5 DNS

4.3.5.1 dns.yml

Activate the DNS management module within the Smart Proxy instance. This is used to update and remove DNS records from existing DNS zones.

The DNS module can manipulate any DNS server that complies with the ISC Dynamic DNS Update standard and can therefore be used to manage both Microsoft Active Directory and BIND servers. Updates can also be made using GSS-TSIG, see the second section below. Additional providers are available for managing libvirt’s embedded DNS server (dnsmasq) and Microsoft Active Directory using dnscmd, for static DNS records, avoiding scavenging.

Builtin providers are:

dns_nsupdate - dynamic DNS update using nsupdate

dns_nsupdate_gss - dynamic DNS update with GSS-TSIG

dns_libvirt - dnsmasq DNS via libvirt API

dns_dnscmd - static DNS records in Microsoft Active Directory

Extra providers are available as plugins and can be installed through packages. See the following pages for more information:

For providers from plugins, check the plugin documentation to determine the exact provider name.

The default TTL of DNS records added by the Smart Proxy is 86400 seconds (one day). This can be changed with the dns_ttl setting:

:dns_ttl: 86400

Each provider has its own configuration file in the same directory with its own settings, e.g. dns_nsupdate.yml. This usually needs additional configuration after changing the use_provider setting.

dns_nsupdate

The dns_nsupdate provider uses the nsupdate command to make dynamic updates to the DNS server records. This works on a wide variety of RFC2136-compliant servers.

DNS servers that support Kerberos authentication, e.g. FreeIPA or Microsoft Active Directory, should use the dns_nsupdate_gss provider instead.

This provider has the following settings in the dns_nsupdate.yml configuration file:

#:dns_key: /etc/rndc.key
:dns_server: localhost

The dns_key specifies a file containing a shared secret used to generate a signature for the update request (TSIG record), thus authenticating the smart proxy to the DNS server.

If you use a key file or keytab, make sure that only the foreman-proxy account can read that file.

If neither the dns_key or GSS-TSIG is used then the update request is sent without any signature. Unsigned update requests are considered insecure. Some DNS servers can be configured to accept only signed signatures.

The dns_server option is used if the Smart Proxy is not located on the same physical host as the DNS server. If it is not specified then localhost is presumed.

dns_nsupdate_gss

For servers that support Kerberos/GSS-TSIG to authenticate DNS updates, the dns_nsupdate_gss provider should be used. This typically applies to FreeIPA and Microsoft Active Directory servers. This is equivalent to the nsupdate -g command.

This provider has the following settings in the dns_nsupdate_gss.yml configuration file:

See the section on GSS-TSIG DNS below for steps on setting up the requisite accounts and keytabs with both AD and FreeIPA.

The dns_server option is used if the Smart Proxy is not located on the same physical host as the DNS server. If it is not specified then localhost is presumed.

:dns_server: dnsserver.site.example.com

dns_dnscmd

While the dns_nsupdate provider creates dynamic records in Active Directory, the dns_dnscmd provider uses the dnscmd tool to create static DNS records in AD, which are not affected by scavenging. This requires that the Smart Proxy is installed on a Windows server with dnscmd available.

The dns_server option is used if the Smart Proxy is not located on the same physical host as the DNS server. If it is not specified then localhost is presumed.

:dns_server: dnsserver.site.example.com

dns_libvirt

Provider that manages reservations and leases via dnsmasq through libvirt API.
It uses ruby-libvirt gem to connect to the local or remote instance of libvirt
daemon.

example using ddns-confgen

# To activate this key, place the following in named.conf, and
# in a separate keyfile on the system or systems from which nsupdate
# will be run:
key "foreman" {
algorithm hmac-md5;
secret "GGd1oNCxaKsh8HA84sP1Ug==";
};
# Then, in the "zone" statement for each zone you wish to dynamically
# update, place an "update-policy" statement granting update permission
# to this key. For example, the following statement grants this key
# permission to update any name within the zone:
update-policy {
grant foreman zonesub ANY;
};
# After the keyfile has been placed, the following command will
# execute nsupdate using this key:
nsupdate -k /path/to/keyfile

You should create a new file (such as /etc/rndc.key or other) and store the key “foreman {…} in it.
in the proxy Settings file you should point to this file location - make sure that the proxy have read permissions to this file.

In your named file, you could add the update-policy statement or something like this named example file if you need more fine grained permissions.

4.3.5.3 GSS-TSIG DNS

Both BIND as configured in FreeIPA and Microsoft AD DNS servers can accept DNS updates using GSS-TSIG authentication. This uses Kerberos principals to authenticate to the DNS server. Under Microsoft AD, this is known as “Secure Dynamic Update”.

Pre-requisites

Kerberos principal in the realm/domain that Smart Proxy can use

Kerberos keytab for the above principal

Access to add/delete/modify the required zones in Microsoft DNS. Both forward and reverse lookup.

Microsoft AD configuration

A user has to be created in Active Directory that will be used by the Smart Proxy, e.g. foremanproxy. This will automatically create a service principal, e.g. foremanproxy@EXAMPLE.COM.

Test the Kerberos login with that user on the Smart Proxy using kinit:

kinit foremanproxy@EXAMPLE.COM

This requires that your SRV records in DNS or /etc/krb5.conf file is setup correctly. By default many systems use DNS to locate the Kerberos DC. A KDC can also be statically set in this file. There are dozens of documents on how to do this on the net.

If login works, the keytab file can be created using ktutil. First clear the Kerberos ticket cache:

Store the keytab at /etc/foreman-proxy/dns.keytab, ensure permissions are 0600 and the owner is foreman-proxy.

The ACL on updates to the DNS zone then needs to permit the service principal. In the FreeIPA web UI, under the DNS zone, go to the Settings tab, verify that “Dynamic update” for that zone is set to “True”, and add to the BIND update policy a new grant:

grant foremanproxy\047proxy.example.com@EXAMPLE.COM wildcard * ANY;

Note the \047 is written verbatim, and don’t forget the semicolon. ACLs should be updated for both forward and reverse zones as desired.

Proxy configuration

Update the proxy DNS configuration file (/etc/foreman-proxy/settings.d/dns.yml) with the following setting:

Restart the smart proxy service. Next, go to Update the configuration in Foreman.

Update the configuration in Foreman

After you have added a DNS smart proxy, you must instruct Foreman to rescan the configuration on each affected smart proxy by using the drop-down menu by its name and selecting “Refresh Features”.

Now, you are allowed to enable this in each subnet (reverse lookup of domain) and domain (forward lookup of domain) that you want this smart proxy to assist. You do this by navigating there and selecting it in the drop-down menu for DNS.

4.3.6 Puppet

Activate the Puppet management module within the Smart Proxy instance. This module has two functions:

reads the Puppet modules and manifests from the Puppet master, reporting the environments and classes that are declared, used when importing classes into Foreman

optionally triggers immediate Puppet runs on clients using one of a number of implementations

It should be activated on Puppet masters that have the environments and modules available to import data from. To use the Puppet run functionality, it also needs to be capable of executing puppetrun or equivalent implementation listed in the section below. This works independently of the Puppet CA functionality, which may only be one of many Puppet masters in the environment.

To enable this module, make sure these lines are present in /etc/foreman-proxy/settings.d/puppet.yml:

:enabled: https
:puppet_version: 4.5.0

Replace 4.5.0 with the version of Puppet installed on the Puppet master, this will be used to determine which APIs and commands it supports. If Puppet is later upgraded, this version number should also be changed to match.

Puppet class/environment imports

Parsing manifests is done by Puppet itself, which means the manifests must be valid and pass syntax checks, else they won't show up. Use puppet parser validate example.pp to validate the content of a manifest.

The proxy generates a list of all Puppet classes and their parameters of the Puppet modules inside the environments declared in puppet.conf. These are imported by Foreman to generate the list of classes, smart class parameters and environments that they belong to. The mechanism used depends on the version of Puppet (specified by :puppet_version):

On Puppet 4, the smart proxy will use the environments and environment_classes or resource_types API to list classes and parameters. environment_classes API is available and used on Puppet 4.4 or higher, resource_types API is used on 4.0 to 4.3.

On Puppet 3.2 to 3.8 with directory environments (environmentpath), the smart proxy will use the environments Puppet Master API to list modulepaths and will load the Puppet library to parse manifests to compile a list of classes and parameters.

Else on Puppet 2 or 3, the smart proxy will parse puppet.conf and load the Puppet library to parse manifests from environment modulepaths to compile a list of classes and parameters.

The sections below describe the configuration options for the different methods.

Puppet 4 configuration options (puppet_proxy_puppet_api.yml)

To get a list of environments, classes and their parameters, the proxy queries the Puppet master on its own API. The URL and settings used for the proxy to Puppet master API query can be controlled with the following settings in /etc/foreman-proxy/settings.d/puppet_proxy_puppet_api.yml:

Puppet 2 or 3 configuration options (puppet_proxy_legacy.yml)

There are two ways to declare environments within Puppet. Config environments are environments explicitly declared in puppet.conf, either with a single “modulepath” setting (which creates a single “production” environment or may be a wildcard), or with [development] section headers. The proxy will parse puppet.conf in the same manner as Puppet to try and determine the known environments.

More information on configuring them is available in the Puppet environment docs. Since Puppet 3.5, these are deprecated in favor of directory environments.

Directory environments are enabled by adding “environmentpath” to puppet.conf. When the proxy finds this setting, it uses this mode too. The :use_environment_api proxy setting can be used to force this mode on or off, but when unset, it follows the presence of environmentpath (the default). More information on configuring directory environments is available in the Puppet docs.

To get a list of environments and module paths when using directory environments, the proxy queries the Puppet master on its own API. The path to puppet.conf plus the URL and settings used for the proxy to Puppet master API query can be controlled with the following settings in /etc/foreman-proxy/settings.d/puppet_proxy_legacy.yml:

The Puppet master has to permit this API query. Older installations of Puppet that have been upgraded may need a new entry in auth.conf prior to the last ‘deny’ entry:

path /v2.0/environments
method find
allow *

When scanning Puppet manifests, a cache is kept in memory to speed up subsequent import calls. It can be enabled/disabled with the following setting:

# Cache options
:use_cache: true

Puppet run providers

For the optional Puppet run functionality, one of a number of implementations can be chosen in /etc/foreman-proxy/settings.d/puppet.yml.

:use_provider: puppet_proxy_puppetrun

Available providers are:

puppet_proxy_puppetrun - for puppetrun/kick, deprecated in Puppet 3, not available in Puppet 4, see section below

puppet_proxy_mcollective - uses mco puppet, see section below

puppet_proxy_ssh - run puppet over SSH

puppet_proxy_salt - uses salt puppet.run

puppet_proxy_customrun - calls a custom command with args

Once a provider is configured, in Foreman itself, enable “puppetrun” under Administer > Settings > Puppet to activate the “Run Puppet” button on individual host pages.

puppetrun (deprecated)

puppet kick (or puppetrun in 2.x) can be used to trigger an immediate Puppet run on a client by connecting to the agent daemon on the client over HTTPS. This functionality is not available in Puppet 4 and was deprecated in Puppet 3, therefore isn’t recommended for new deployments - consider alternatives, e.g. SSH or MCollective.

More information can be found in the puppet kick documentation, specifically the Usage Notes which describe the configuration of the agents to listen and authorize connections.

Its configuration options are in /etc/foreman-proxy/settings.d/puppet_proxy_puppetrun.yml:

# User for execution of puppetrun commands
#:user: peadmin

The :user setting controls which user to sudo to, which on some installations (notably PE) may be different. When unset, it will sudo to root.

sudo access for the proxy is required to run the client - in your sudoers file ensure you have the following lines (use /opt/puppet/bin/puppet for Puppet Enterprise):

SSH

The puppet_proxy_ssh provider uses SSH to connect to the client using SSH keys and run the Puppet agent command directly. It is controlled by the following settings in /etc/foreman-proxy/settings.d/puppet_proxy_ssh.yml:

# the command which will be sent to the host
:command: /usr/bin/puppet agent --onetime --no-usecacheonfailure --no-daemonize
#
# whether to use sudo before the ssh command
:use_sudo: false
#
# With which user should the proxy connect
#:user: root
#:keyfile: /etc/foreman-proxy/id_rsa
#
# wait for the command to finish (and capture exit code), or detach process and return 0
#:wait: false

The wait setting controls whether to block on completion of the Puppet command, so the result of the Puppet run can be returned to Foreman, else it’s usually asynchronous. When true, increase proxy_request_timeout under Administer > Settings in Foreman itself to ensure it waits longer for a response, as the Puppet run may take some time to complete.

Here is a howto on enabling the SSH feature.

On the foreman-proxy server, enable the SSH provider and uncomment the user and SSH key settings:

An additional step, but not required (security warning) is to disable host keys checking. It means any host allowing this SSH keys to connect will be reachable, without the need to run ssh root@client as foreman-proxy user to accept the host key. The goal here is to allow automatic deployment by only populating the authorized_keys file on new clients.

To enable such behavior, we will create a SSH client configuration file to disable host key checking, and disable storing of known keys:

customrun

The customrun provider allows configuration of a script that implements the Puppet run action in any way you require. Set the following configuration in /etc/foreman-proxy/settings.d/puppet_proxy_customrun.yml:

# Set :customrun_cmd to the full path of the script you want to run, instead of /bin/false
:command: /bin/false
# Set :customrun_args to any args you want to pass to your custom script. The hostname of the
# system to run against will be appended after the custom commands.
:command_arguments: -ay -f -s

4.3.7 Puppet CA

Activate the Puppet CA management module within the Smart Proxy instance. This is used to manage the autosign configuration and handle listing, signing and revocation of individual certificates.

This should only be enabled in the Smart Proxy that is hosted on the machine responsible for providing certificates to your puppet clients. You would expect to see a directory /var/lib/puppet/ssl/ca on such a host.

:enabled: https

If your puppet SSL directory is located elsewhere, you’ll need to set ‘ssldir’ as well.

:ssldir: /etc/puppet/ssl

The ‘autosignfile’ setting is used to find autosign.conf:

:autosignfile: /etc/puppet/autosign.conf

The proxy requires write access to the puppet autosign.conf file, which is usually owner and group puppet, and has mode 0644 according to the puppet defaults.

4.3.8 Realm

4.3.8.1 realm.yml

Activate the realm management module within the Smart Proxy instance. This manages Kerberos realms or domains, allowing Foreman to add and remove hosts to enable them to join the realm/domain automatically during provisioning.

:enabled: https
:use_provider: realm_freeipa

Builtin providers are:

realm_freeipa - host object management in FreeIPA

The configuration for each provider should be in its respective file, i.e: /etc/foreman-proxy/settings.d/realm_freeipa.yml.

The following settings control authentication of the proxy to the realm for management of hosts.
In realm_freeipa.yml:

4.3.8.2 FreeIPA Realm

The FreeIPA implementation of the realm proxy is able to add a host entry to FreeIPA, send the hostgroup name, and request a one-time registration password.

Configuration of FreeIPA

In order to create the realm user and keytab to authenticate to FreeIPA, you can use the included foreman-prepare-realm tool. Your Smart Proxy must be registered to the FreeIPA realm already, and have the ipa-admintools package installed.

Simply provide a user with admin rights in FreeIPA, and a target user to create.

Do not use 'foreman-proxy' as the username for this -- this is a local user used for running the Smart Proxy service.

You will need to disable the DNS proxy for hosts that are provisioned with a realm set, as FreeIPA adds the forward record for you. In order to support adding a reverse lookup record also, you will need to go into the settings for the forward lookup zone on the IPA server and tick Allow PTR sync. This will make sure that FreeIPA creates the PTR records for you.

Using Automember Rules

FreeIPA supports the ability to setup automember rules based on attributes of a system. When using the FreeIPA proxy, the Foreman host group is available as a parameter in FreeIPA known as userclass. Nested host groups are sent as displayed in the Foreman UI, e.g. “Parent/Child/Child”. Note that Foreman does send updates to FreeIPA, however automember rules are only applied at initial add. This will be coming in a future version of FreeIPA.

When a machine in Foreman is in the “webservers” host group, it will automatically be added to the FreeIPA
“webservers” host group as well. FreeIPA host groups allow for Host-based access controls (HBAC), sudo policies,
etc.

4.3.9 TFTP

tftp.yml

Activate the TFTP management module within the Smart Proxy instance. This is designed to manage files on a TFTP server, e.g. bootloaders for OS installation and PXE menu files.

The tftproot value is directory into which TFTP files are copied and then served from. The TFTP daemon will also be expected to chroot to this location. This component is only supported in a Unix environment.

:enabled: https
:tftproot: /var/lib/tftpboot
:tftp_servername: name of your tftp server (used for next server value in your dhcp reservation) - defaults to the host name of your proxy.

The foreman-proxy user must have read/write access to the _tftpboot/pxelinux.cfg_ and _tftpboot/boot_ directories.

Unattended installation

An essential first step in netbooting a system is preparing the TFTP server with the PXE configuration file and boot images. This document assumes that you have already configured your DHCP infrastructure, either via manual configuration or through the DHCP smart proxy.

Setting Up the Proxy Server Host

Regardless of the filesystem setup is performed, you must also make sure you have the wget utility installed and in the default path. wget is used to download OS specific installation when a given host is enabled for the build process.

Automatic Setup

Foreman includes a TFTP server module that will perform all of the basic setup. It defaults to TFTP root of /var/lib/tftpboot, which may change if necessary. You will still need to provide the basic TFTP load images in your TFTP root directory. For vanilla PXE booting via PXELinux, this includes pxelinux.0, menu.c32, and chain.c32, for PXEGrub this includes grub2/ and grub/ subdirectories.

Manual Setup

The setup is very simple, and may be performed manually if desired.

The TFTP root directory must exist (we will use /var/lib/tftpboot in this example).

Populate /var/lib/tftpboot with PXE booting prerequisites. These can be taken from syslinux (usually in /usr/share/syslinux on RHEL) . At a minimum, this should include:

pxelinux.0

menu.c32

chain.c32

ldlinux.c32 if syslinux provides it

Populate the following prerequisites when PXE Grub bootloader is planned. These files can be found in OS distribution repositories, DVD/CD or packages (e.g. grub2-efi on Red Hats which installs into /boot/EFI). Alternatively, these files can be built from modules using grub2-mkimage or grub-mkimage and signed for SecureBoot support.

/var/lib/tftpboot/grub2 with grubx64.efi or grubia32.efi

/var/lib/tftpboot/grub with bootx64.efi or bootia32.efi

Create the directory /var/lib/tftpboot/boot and make it writeable by the foreman proxy user (foreman-proxy, for instance, when installing through a rpm package).

Create the directory /var/lib/tftpboot/pxelinux.cfg and make it writeable by the foreman proxy user (foreman-proxy).

Make sure /var/lib/tftpboot/grub and /var/lib/tftpboot/grub2 are both writeable by the foreman proxy user (foreman-proxy).

Verify SELinux labels when using SELinux.

Note: if CentOS 7 is used, please make sure to edit the URL under Hosts -> Installation Media, to to exclude the $minor version. For example: http://mirror.centos.org/centos/$major/os/$arch

Setting Up Foreman

In most cases, the default templates should work fine. You do, however, need to make sure that a PXELinux or iPXE template is associated with your hosts. See Unattended Installations for details. The template will be used to define the PXE configuration file when a host is enabled for build.

Workflow

This is a rough outline of the steps triggered on the TFTP smart proxy host when you click on the “Build” link for a host.

Call mkdir -p /var/lib/tftpboot/pxelinux.cfg if it does not already exist.

Create a host-specific TFTP configuration file in /var/lib/tftpboot/pxelinux.cfg/01-XX-XX-XX-XX-XX-XX, named based off of the MAC address, using the associated PXE template.

Call mkdir -p /var/lib/tftpboot/boot if it does not already exist.

Download the OS specific kernel and initrd files using wget.

The download URLs are derived from the installation media path, and OS specific log (see app/models/redhat.rb and debian.rb in foreman for examples of the gory details).

The debian.rb file tries to guess if you want Ubuntu or Debian, based on the Name you give to your OS in the UI. If the name does not contain ‘ubuntu’ or ‘debian’, it may default to debian, hence fail to fetch the kernel/initrd.

cd into /var/lib/tftpboot/boot and check that the filesizes are not zero. Check /var/log/foreman-proxy/proxy.log for possible errors.

Once the host has completed installation, the OS specific installation script should inform foreman by retrieving the built URL.

The host-specific TFTP configuration file is deleted.

The kernel and initrd are not deleted, but left in place for future installs of the same OS and architecture combination. Please note that in the unlikely case that these files are modified, the simplistic freshness check of wget will likely get confused, corrupting the downloaded versions of the files. If this happens, you should simply delete the files and let them be re-downloaded from scratch.

To make sure that you trigger the above workflow make sure you’ve satisfied these requirements:

at least 1 host is put in build mode

the host is using a subnet with a TFTP proxy

Limitations

At the moment, the proxy is not able to fetch boot files using NFS.
As a workaround, expose your installation medium (or use a public mirror) over http/ftp to configure one machine with the require boot files.
this would be resolved as part of #992.

Global default templates

You can build PXE default on TFTP proxy from Foreman UI from ‘Provisioning Templates’ page using ‘Build PXE Default’ button. You also have the the ability to choose which templates are used for this action. Foreman exposes the following settings in the ‘Provisioning’ group for this purpose: Global default PXEGrub template, Global default PXEGrub2 template and Global default PXELinux template. When settings are empty, Foreman uses default values: PXELinux global default, PXEGrub global default and PXEGrub2 global default.

4.3.10 SSL

The smart proxy can work in SSL mode, where both sides verify and trust each other. Requests from Foreman will only be accepted if the SSL certificate can be verified. Since proxies abstract a high level of control over your infrastructure, the configuration and security of keys and certificates is important.

Using Puppet CA certificates

Since Foreman integrates with Puppet heavily, it is recommended to use the Puppet Certificate Authority (CA) to secure proxy access. See the Securing communications with SSL section for more advanced installations (multiple or internal CAs).

If the smart proxy host is not managed by Puppet, you will need to generate a certificate - skip forward to the generate section.

When using Puppet’s certificates, the following lines will be required in puppet.conf to relax permissions to the puppet group. The foreman and/or foreman-proxy users should then be added to the puppet group.

Please note, the smart proxy uses the OpenSSL suite naming scheme. For more information on suite names please see the OpenSSL docs.

Certain users may require to disable certain cipher suites due to security policies or newly discovered weaknesses. This can be done by using the :ssl_disabled_ciphers: option in /etc/foreman-proxy/settings.yml. For example:

:ssl_disabled_ciphers: ['AES128-SHA','AES256-SHA']

Generating a certificate

To generate a certificate for a proxy host that isn’t managed by Puppet, do the following:

Follow the configuration section above, however use the /etc/foreman-proxy paths instead of the Puppet defaults.

Configuring Foreman

For Foreman to connect to an SSL-enabled smart proxy, it needs configuring with SSL certificates in the same way. If the Foreman system is managed by Puppet, it will already have these, else certificates can be generated following the above instructions.

The locations of the certificates are managed in the Settings page, under Provisioning with the ssl_ca_file, ssl_certificate and ssl_priv_key settings. By default these will point to the Puppet locations - for manually generated certificates, or non-standard locations, they may have to be changed.

Lastly, when adding the smart proxy in Foreman, ensure the URL begins with https:// rather than http://.

4.3.11 Libvirt

In this chapter, we will describe how to setup DHCP and DNS for use with the
libvirt provider for dnsmasq.

This provider is able to change DHCP and DNS settings in libvirt with dnsmasq.
The smart proxy directly connects to the libvirt daemon.

The provider is currently limited by the libvirt API which does not provide
PTR records creation via the API itself, but dnsmasq automatically creates PTR
record for the first A/AAAA entry. Therefore PTR lookups do work in the
network, but it is not being created by Foreman orchestration.

The provider also returns active leases on systems with ruby-libvirt gem
version 0.6.1 or higher.

Create a TFTP root directory, make sure it is writeable by the foreman proxy
user (foreman-proxy for instance) and accessible to the account
dnsmasq is running on (in Fedora this is nobody), set gid flag for newly
copied files and copy necessary files to the new TFTP root directory:

Foreman is now configured for libvirt provisioning, this is the recommended
setup for git development checkouts.

4.3.12 Templates

In this chapter, we will describe how to setup a Smart Proxy to serve
provisioning templates.

The smart proxy is able to proxy template requests from hosts in isolated
networks to the Foreman server, when the proxy also handles TFTP.

Generally, you want the templates to be available on HTTP as well as HTTPS. When enabling HTTP on your smart proxy, ensure that other modules' configurations in /etc/foreman-proxy/settings.d/*.yml are secure by setting :enabled: to https instead of true.

Ensure the foreman_url in /etc/foreman-proxy/settings.yaml points to your Foreman instance, and that your smart proxy is listening on HTTP by uncommenting http_port. Now
configure /etc/foreman-proxy/settings.d/templates.yml:

:enabled: true
:template_url: http://smart-proxy.example.com:8000

Once you’ve completed the above steps, restart the foreman-proxy service and refresh the features on your Foreman server.

The templates feature is used automatically: any host that uses this proxy for TFTP will also use the proxy to retrieve its templates.

4.3.13 Logs

The smart proxy’s logs module provides an API to retrieve recently logged messages and information about failed modules. This will be displayed in Foreman under the Smart Proxy pages when the module is enabled.

The module has no configuration options of its own, and is just enabled by configuring /etc/foreman-proxy/settings.d/logs.yml:

:enabled: https

Once enabled, restart the foreman-proxy service and refresh the features on your Foreman server.

The number of logs is controlled by the main smart proxy logging settings, detailed in Smart Proxy Settings.

4.4 Provisioning

This chapter details the configuration of the required UI components necessary to provision an OS onto a host.

4.4.1 Operating Systems

The Operating Systems page (Hosts -> Operating Systems) details the OSs known to Foreman, and is the central point that the other required components tie into.

Creating an Operating System

Simply click New Operating system on the main page. You will be taken to a screen where you can create the bare essentials of a new OS. Not everything required for a successful provision is on this page (yet) - the remaining components will appear for selection as we create them.

You will need to fill in the first few parts of the form (Name, Major, Minor, Family, and possibly some family-dependant information). In the case of OSs like Fedora, it is fine to leave Minor blank.

If the default Partition Tables & Installation media are suitable, then you can assign them now. If not, return here after each step in this chapter to assign the newly created objects to your Operating System

Auto-created Operating Systems

Foreman does not come with any Operating Systems by default. However, Foreman will detect the Operating System of any host which reports in via Puppet - if the OS of that Host is supported, it will be created (with very basic settings) and assigned to the Host. Thus you may find some OSs already created for you.

4.4.2 Installation Media

The Installation Media represents the web URL from where the installation packages can be retrieved (i.e the OS mirror). Some OS Media is pre-created for you when Foreman is first installed. However, it is best to edit the media you are going to use and ensure the Family is set.

New Installation Media

If your OS of choice does not have a mirror pre-created for you, click the New Medium button to create one. There are a few variables which can be used to pad out the URL. For example:

http://mirror.averse.net/centos/$major.$minor/os/$arch

Be sure to set the Family for the Media

Assign to Operating System

If you have not already done so, return to the Operating System page for your OS and assign the Media to it now.

4.4.3 Provisioning Templates

The Provision Templates is the core of Foreman’s flexibility to deploy the right OS with the right options. There are several types of template, along with a flexible matching system to deliver different templates to different Hosts.

Foreman comes with pre-created templates for the more common OSs, but you will need to review these. All these templates are locked by default, hence they can not be modified. Most of them are customizable through parameters, but if you need some custom functionality, the recommended workflow is to clone the template and edit the clone. You can unlock the pre-created template and edit it directly, but note that any custom change will be overridden on any Foreman update. If you believe your change is worth of including in next Foreman release, please consider sending a patch to community-templates repository which we regularly synchronize with our codebase.

Template Kinds

There are several template kinds:

PXELinux, PXEGrub, PXEGrub2 - Deployed to the TFTP server to ensure the Host boots the correct installer with the correct kernel options (also referred to as PXE templates)

Finish - A post-install script used to take custom actions after the main provisioning is complete

user_data - Similar to a Finish script, this can be assigned to hosts built on user_data-capable images (e.g. Openstack, EC2, etc)

Script - An arbitrary script, not used by default, useful for certain custom tasks

iPXE - Used in {g,i}PXE environments in place of PXELinux (do not confuse with PXE templates above)

In practice, most environments only make use of the first 3. The Create Host action deploys the PXELinux template to the TFTP server. The PXELinux template directs the host to retrieve the Provision template. The Provision template will direct the installer to retrieve and run the Finish template at the end of the install, and the Finish template will notify Foreman the build is complete just before reboot.

Editing Templates

Unlocked templates can be edited from the Hosts > Provisioning templates menu, or from an existing host page under its Templates tab (which shows the templates in use).

The templates use the ERB (Embedded Ruby) templating language, allowing data from the host in Foreman to be added to the template output and for conditional content. The default templates make heavy use of the ERB feature, adding and changing the template behavior based on parameters, the operating system, or the networking configuration assigned to the host.

There are two general types of ERB syntax in templates. The <%= prefix outputs the value of the following expression into the rendered template, e.g. to output the hostname:

<%= @host.name %>

The <% prefix without the equals sign (=) is a general code block that may contain conditionals, variable assignments, or loops which are not output when rendered. Comments may also be in these blocks, prefixed with #.

<%
a_variable = @host.name
%>
<%= a_variable %>

Other examples of ERB syntax are given on the Help tab of the template editor, and many more examples are available on the Template Writing wiki page. The Help tab also lists available Global methods (functions) provided by Foreman such as foreman_url (the URL for unattended calls to Foreman), and template_name.

The methods available on the provided @host variable are limited by default (when safemode_render is enabled) to prevent exploitation of Foreman through templates. The permitted methods on all types of objects can be found in the Safe mode methods and variables table under the Help tab.

As noted in section 4.1.4 Auditing, changes to the templates are logged as diffs - you can browse the history of changes to the templates from the History tab within the Edit Template page. You can also revert changes here.

Template Association

When editing a Template, you must assign a list of Operating Systems which this Template can be used with. Optionally, you can restrict a template to a list of Hostgroups and/or Environments

When a Host requests a template (e.g. during provisioning), Foreman will select the best match from the available templates of that type, in the following order:

Host-group and Environment

Host-group only

Environment only

Operating system default

The final entry, Operating System default, can be set by editing the Operating System page.

Associating an Operating System default template

You will need to associate at least one PXE, Provision, and Finish template to your Operating System, and this must be done in two steps. First edit each of the templates, switch to the Association tab, and ensure the appropriate OSs are checked. Then edit the Operating System, switch to the Templates tab, and choose a default template for each template kind.

More than one PXE template can be associated. In this case, all associated PXE templates are deployed to the TFTP server and only one is picked up during provisioning according to the PXE Loader setting (see below).

Templates Details

For image based installs there are two methods to customize and finish the installation. Finish templates and User Data templates:

Finish Templates

Finish templates are available for all hypervisors that support image based installs where the foreman server can reach the newly installed machine via ssh and scp. The script generated from the finish template is copied by the Foreman to the newly installed system via scp using username and password specified with the image. It is then executed by connecting again via ssh, making the script executable and either executing it directly or via sudo if the specified user is not root. Standard output and standard error are logged to a file in the same directory named bootstrap-UUID.log.

User Data Templates

User Data Templates are available for hypervisors that support customization via tools like cloud-init. In this case the installed machine does not need be reachable via ssh by the Foreman server. However, the installed must be able to reach Foreman or a Smart Proxy with the templates feature via http(s) to notify the setup has finished.

PXE Loader

When creating a new Host, the PXE Loader option must be selected in order to pass
the correct DHCP filename option to the client. One option out of the following
must be chosen:

PXELinux BIOS (loads pxelinux.0 filename from TFTP)

PXELinux UEFI (loads pxelinux.efi filename from TFTP)

PXEGrub UEFI (loads grub/bootx64.efi filename from TFTP)

PXEGrub UEFI SecureBoot (loads grub/shim.efi filename from TFTP)

PXEGrub2 UEFI (loads grub2/grubx64.efi filename from TFTP)

PXEGrub2 UEFI SecureBoot (loads grub2/shim.efi filename from TFTP)

None - no filename passed (e.g. for HTTP booting via iPXE)

Grub filenames are different for each individual architecture associated with
the Host:

grub/bootia32.efi (for Intel named "i*86" where * can be any character)

grub/bootx64.efi (for Intel named "x86-64")

grub2/grubia32.efi (for Intel named "i*86" where * can be any character)

grub2/grubx64.efi (for Intel named "x86-64")

grub2/grubaa64.efi (for ARM 64 named either "aa64" or "aarch64")

grub2/grubppc64.efi (for IBM POWER named "ppc64”)

grub2/grubppc64le.efi (for IBM POWER Little Endian named "ppc64le")

grub2/grubXYZ.efi (for arbitrary Architecture named "XYZ")

Foreman installer only installs pxelinux.0 and grub2/grubx64.efi (if grub2
is available). In order to boot systems via other loaders like PXELinux EFI or
Grub 1 (legacy), deploy the required bootloader files in the TFTP directory.

Some operating systems use a “shim” loader for SecureBoot (e.g. Red Hat
Enterprise Linux and clones). To use SecureBoot with an operating system that
does not use a shim chainloader, make a copy of the signed EFI loader named
shim.efi or make a symlink in order to do secure boot.

4.4.4 Partition Tables

Partition templates are a subset of normal Provisioning Templates. They are handled separately because it is frequently the case that an admin wants to deploy the same host template (packages, services, etc) with just a different harddisk layout to account for different servers’ capabilities.

Foreman comes with pre-created templates for common Operating Systems, but it is good to edit the template, check it’s content and it’s Family setting. If the Family is wrong, be sure to go back to Operating Systems and associate it with your Operating System.

Per-Host Partition tables

When creating a new Host, you will be given the option to create an individual partition table. This is essentially a ‘one-off’ partition table that is stored with the host and used only for that host. It replaces the choice of Partition Table from the normal list of those associated with the selected OS.

Dynamic Partition tables

Some operating systems allow you to create partition tables via scripts. At the moment Kickstart and AutoYaST based systems can use this feature. Partition templates starting with #Dynamic are interpreted as scripts rather than static partition tables. The Provisioning Template needs to support this feature (search for @dynamic). This enables you to make choices on the fly during provisioning (or re-provisioning).

Kickstart Dynamic Partition tables

Kickstart will run dynamic partition tables as a pre-install bash script using a %pre scriplet. This script needs to create a complete Kickstart partition table in ‘/tmp/diskpart.cfg’. This partition table will then be read by anaconda for the installation by using %include /tmp/diskpart.cfg.

Example Dynamic Partition table:

#Dynamic - this line tells Foreman this is a script rather then a static layout
#This snippets define the swap partition size, it would generate a partition twice the size of the memory if your physical memory is up to 2GB
#or will create a swap partition with your memory size + 2GB.
#get the actual memory installed on the system and divide by 1024 to get it in MB
act_mem=$((`grep MemTotal: /proc/meminfo | sed 's/^MemTotal: *//'|sed 's/ .*//'` / 1024))
#check if the memory is less than 2GB then swap is double the memory else it is memory plus 2 GB
if [ "$act_mem" -gt 2048 ]; then
vir_mem=$(($act_mem + 2048))
else
vir_mem=$(($act_mem * 2))
fi
#copy all the HDD partitions to the temp file for execution
cat <<EOF > /tmp/diskpart.cfg
zerombr yes
clearpart --all --initlabel
part swap --size "$vir_mem"
part /boot --fstype ext3 --size 100 --asprimary
part / --fstype ext3 --size 1024 --grow
EOF

AutoYaST Dynamic Partition tables

AutoYaST will run dynamic partition tables as a pre-install bash script. This script needs to create a AutoYaST XML file in /tmp/profile/modified.xml. The modified.xml file will be read by YaST after your script has finished. An example for getting the same functionality as with Kickstart would be to create your XML partition table in /tmp/diskpart.cfg and sed it together with the original AutoYaST XML like this: sed '/<\/ntp-client>/ r /tmp/diskpart.cfg' /tmp/profile/autoinst.xml > /tmp/profile/modified.xml. Inserting after ntp-client section is just a suggestion that uses the same style the community-templates do. The example uses a simplified version of the AutoYaST LVM Partition table template.

The inclusion of the keyword string #Dynamic at the start of a line lets Foreman know that this is not an explicit
disk layout and must treated as a shell script, executed prior to the install process and that the explicit partition
table will be found at /tmp/diskpart.cfg during the build process.

The dynamic partitioning style is currently only available for the Red Hat family of operating systems,
all others must provide an explicit list of partitions and sizes.

You may also associate one or more operating systems with this partition table or alternatively set this up later on
the Operating systems page.

4.4.5 Architectures

Architectures are simple objects, usually created by Foreman automatically when Hosts check in via Puppet. However, none are created by default, so you may need to create them if you’re not using Foreman for reporting.

Creating a new Architecture

Simply click New Architecture to create a new one. This should match the Facter fact :architecture e.g. “x86_64”. If you’ve already created some Operating Systems, you can associate the Architecture with the OS now; if not, the list of Architectures will be present when you create an OS.

4.4.6 Workflow

Foreman performs a number of orchestration steps when performing unattended installation or provisioning, which vary depending on the integration options chosen - e.g. use of compute resources, configuration management tool and provisioning method (network/PXE/image).

4.4.6.1 Example: PXE booting an instance with Salt configuration

The following example uses:

Compute resource (oVirt), also applicable to Libvirt and VMware

Network (PXE) provisioning with DHCP and TFTP orchestration

DNS orchestration

Salt configuration management, also applicable to Puppet

Steps

On the New Host page, the default VM configuration is shown and compute profiles can be applied.

An unused IP address is requested from the DHCP smart proxy associated with the subnet.

The IP address field is filled in on the New Host page.

n/a

The New Host page is submitted.

Foreman contacts the compute resource to create the virtual machine.

The compute resource creates a virtual machine on a hypervisor.

The VM’s MAC address is returned from the compute resource and stored on the host.

A reservation is created on the DHCP smart proxy associated with the subnet.

DNS records are set up:

A forward DNS record is created on the smart proxy associated with the domain.

A reverse DNS record is created on the DNS smart proxy associated with the subnet.

A PXELinux menu is created for the host in the TFTP smart proxy associated with the subnet.

Foreman contacts the compute resource to power on the VM.

The compute resource powers up the virtual machine.

The host requests a DHCP lease from the DHCP server.

The DHCP lease response is returned with TFTP options (next-server, filename) set.

The host requests the bootloader and menu from the TFTP server.

The PXELinux menu and OS installer for the host is returned over TFTP.

The installer requests the “provision” template/script from Foreman.

Foreman renders the template and returns the resulting kickstart/preseed to the host.

Autosigning configuration for Salt (or Puppet) is added on the Salt or Puppet CA smart proxy.

The installer notifies Foreman of a successful build in the postinstall script.

The PXELinux menu is reverted to a “local boot” template.

The host requests its configuration from Salt or Puppet.

The host receives appropriate configuration using data defined in Foreman.

Configuration reports and facts are sent from Salt or Puppet to Foreman and stored.

4.4.6.2 Example: Cloud-based provisioning via cloud-init

This example shows workflow of cloud-based provisioning on IaaS (e.g.
OpenStack) via cloud-init which configures Puppet agent to finish off the
configuration.

4.4.6.5 Example: Anaconda PXE-based provisioning

4.4.7 Networking

Foreman can store information about the networking setup of a host that it’s provisioning, which can be used to configure the virtual machine, assign the correct IP addresses and network resources, then configure the OS correctly during the provisioning process.

This section details the options available for network interfaces in the New Host form and how they’re used.

Host interface options

Primary: each host must have a single primary interface, which is used as the name of the host itself. This should be considered the main hostname and would usually also carry the default route.

Provision: the interface on which provisioning of the operating system should be carried out. This will be used for PXE (if applicable) with TFTP menus, running SSH finish scripts etc. This may be different to the primary interface and should have access to Foreman and other provisioning systems.

Managed: whether Foreman orchestrates creation of DNS entries, DHCP reservations and configuration of the interface during provisioning. Unmanaged interfaces would be used for informational purposes only.

A simple, single-homed host would have one network interface with a DNS name set matching the hostname, then managed, primary and provision flags all ticked. This would create one interface with DNS and DHCP records (if configured) over which the OS would be set up.

A dual or multi-homed host could have one interface with primary enabled (“host.example.com”) and another network with provision enabled (“host-build.example.com”). If both are also managed, Foreman will create DNS and DHCP records for both, but on the provision interface, the next-server/filename options for PXE will also be set. A TFTP (PXELinux) menu would also be created for the provision interface’s MAC address so the host can PXE boot on that physical interface, while its hostname would be assigned from the primary interface.

Virtual machines and interfaces

When Foreman deploys a host onto a compute resource, it creates a new interface on the VM for each interface specified when creating the host.

After creation, Foreman reads back the network information and matches the created interfaces to the list of interfaces given for the host and stores the assigned MAC and IP addresses (depending on the compute resource type) in its database. It then continues with orchestration, creating DNS and DHCP records etc. for the addresses retrieved from the new VM. Once orchestration of these is complete, it powers up the VM.

This design alleviates the need to supply MAC addresses for hosts being created on compute resources.

Subnet options

Subnets are defined in Foreman under Infrastructure > Subnets, and have a few options that affect how hosts are provisioned.

IPAM: DHCP will use a DHCP-enabled smart proxy, checking for assigned leases and reservations and suggesting a new IP from the range. Internal DB will use Foreman’s list of already-assigned IPs and doesn’t rely on a DHCP smart proxy. None disables auto-suggestion of IP addresses.

Boot mode: during OS provisioning, the template will configure the interface with either a static IP address or to use DHCP depending on the value of this setting.

Various combinations of the IPAM and Boot mode settings make sense, but the most common are DHCP (IPAM) with DHCP (Boot mode) and Internal DB with Static.

Use within provisioning templates and Puppet

Provisioning templates (such as kickstart, preseed or finish scripts) can make use of the interfaces data stored in Foreman for the host to configure the network.

A snippet (“kickstart_networking_setup”) is supplied by default in Foreman for kickstart-based OSes, which configures all managed network interfaces after the main OS installation is complete. This can be used in the %post kickstart section. No template is currently available for preseed-based OSes (ticket)

A hash of interfaces data is also made available to Puppet via a global ENC parameter called “foreman_interfaces”. This can be used to fully configure the network from a Puppet run.

4.4.8 OS Specific Notes

4.4.8.1 FreeBSD

As the FreeBSD installer itself does not support a kickstart-like pulling of a response file, a custom mfsBSD image with zfsinstall is used. Prebuilt images are available for download to be placed into the boot directory of your TFTP server.

However, these images can also be built from scratch as described below:

Building an installer image

This is an example how to build an image for FreeBSD 10.2-RELEASE. For other releases, simply replace the version accordingly.

4.4.8.2 SLES

The installation media URL has to contain the contents of the first SLES DVD, it’s easiest to loopback mount the ISO image on a webserver. For Puppet, the systemsmanagement:puppet repository on OBS is used.

SLES 11

For Puppet, in addition to systemsmanagement:puppet also the devel:languages:ruby:backports repository on OBS and the SLES SDK DVD is used. The placeholder in the AutoYaST SLES template has to be updated with the actual SDK URL.

4.4.8.3 Windows

Provisioning Windows is a two step process. The first step, creating Installation Media, is not discussed here.
It includes getting the WIM files, updates and drivers and boot files ready.
The necessary boot files are are later downloaded by automatically by the smart proxy.

Tasks break down

Change / add a new Architecture and OS

Edit provision templates

Add installation media

Edit partition table

Add parameters

Link provisioning templates to OS

Architecture and OS

In Hosts > Architectures add a new architecture:

Name: x64

Add a new OS in Hosts > Operating systems if needed.
If you already have Windows hosts and with Puppet installed, the correct OS and architecture will have been auto created already.
This example covers Windows 8.1 / Windows Server 2012R2.

Name: windows

Major: 6

Minor: 3

OS family: windows

Description: Windows8

Root password hash: Base64

Architectures: x64

Take special care to set Root password hash = Base64. The templates do not render correctly if this is set otherwise.
Changing the encoding does not apply to existing hosts.

Note: Foreman’s Safe Mode does prevent using the password directly.
Thus, the string AdminPassword needs to be appended to your password when adding a new host. Eg P@55w0rd would become P@55w0rdAdminPassword.
This can be automated however by replacing the the password part with a ruby function and disabling safe mode render.

Add provision templates

Head to Hosts > Provisioning Templates and edit the templates starting with WAIK to meet your needs. Make sure to get the latest version of the WAIK templates from the community templates project.
Assign each of those templates to your Windows OS (does not apply to snippets).
The naming of the templates is a suggestion and up to you. This does not apply to snippets! There, the name is important.

Required templates

WAIK Finish

Name: WAIK Finish

Kind: Finish

WAIK unattend.xml

Name: WAIK unattend.xml

Kind: Provision

WAIK peSetup.cmd

Name: WAIK peSetup.cmd

Kind: Script

Note: To get the download folders nicely, the wget commands in this template might need tweaking. This could
especially be necessary if you intend to use the extraFinishCommands snippet.
Eg, --cut-dirs=3 would cut the first three directories form the download path when saving locally.
This way http://winmirror.domain.com/pub/win81x64/extras/puppet.msi will be stripped of pub/win81x64/extras and download to puppet.msi.

WAIK PXELinux

Name: WAIK PXELinux

Kind: PXE Linux

Optional templates

WAIK joinDomain.ps1

Name: WAIK joinDomain.ps1

Kind: User Data

WAIK local users

Name: WAIK local users

Kind: Snippet

Note: This snippet creates extra users in the unattended stage.
This may be very useful for debugging early stages of your deployment; since you
can find yourself locked out of the newly provisioned host.

Microsoft does not really care about password security in unattend.xml files; so it does not really matter if you use
<PlainText>true</PlainText> or not. If you prefer the encoded form, you need to append the string Password to your user password and encode it to Base64. The following ruby function is an example, it creates the encoded from of P@55w0rd:

Note: The commands here are executed at the last stage just before finishing host building.
Make sure they get executed in a synchronous way (eg. do not run in background like msiexec).
Otherwise the following reboot might kill them.

WAIK OU from host group

Name: WAIK OU from host group

Kind: Snippet

Note: This snippet may be used to generate the computer OU from the host’s host group and domain.

Example: Given a host example in domain ad.corp.com and in host group servers/windows/databases.
The snippet generates the OU path:
OU=databases,OU=windows,OU=servers,DC=ad,DC=corp,DC=com. Optionally, set the host parameter computerOuSuffix to add some arbitrary OU at the end.

Add installation media

For each of your Windows versions add a new installation medium pointing to the root of the folder containing boot and sources
Eg, http://winmirror.domain.com/pub/win81x64. Assign them to your operating system.

Modify partition table

The default partition table is a simple diskpart.exe script. It will wipe Disk 0

Define templates

Link all the created templates as well as the installation media and partition table to the OS:

Add Parameters

To render the the templates correctly, some parameters need to be added. They need to be available as global/host parameters. Most of them make the most sense as parameter on the the OS. Most parameters are not
required and have defaults. For the most up to date description see the template itself.

Important parameters

Note: The correct value for wimImageName depends on your install.wim. The provisioning will fail an incorrect value is supplied for a multi image WIM file and gets silently ignored if the image contains one image only.

Optional
The following parameters are only applied if they exist. Some, like domainJoinAccount and domainJoinAccountPasswd require each other.

computerOuSuffix: Used if computerOU is not present to generate the computer OU from host group and host domain. computerOU takes precedence! Note, the OU must still be manually created in active directory

computerDomain: domain.com - domain to join

Troubleshooting

Templates

The templates most likely need a lot of testing to work. This is not covered here; though some hints how to start. You should proceed in this order:

Get your templates to render correctly. Create random Bare Metal host in the desired host group for this purpose and make extensive use of Foreman’s template preview feature.

Continue tesing with VMs to test netbooting and basic installation

Debug peSetup.cmd by pausing it at the send (remove the comment from ::PAUSE). Then, use Ctrl-C to cancel the script altogether. This way you can debug the rendered peSetup.cmd quite nicely in WinPE (eg, notepad peSetup.cmd)

The WAIK Finish template uses sDelete.exe to remove all rendered commands from the provided host. Comment out all sDelete commands to debug finish scripts.

Use a manual installed host to test rendered snippets like WAIK extraFinishCommands directly.

Examine C:\foreman.log. - the output left from the finish script. Also, comment out the clean up stage in the finish script to examine and test the rendered scripts directly.

Netbooting

Sometimes wimboot seems not to be able to boot our winPE.wim. Symptoms range from black screens to kernel panics (aka BSOD). These problems seem to be more likely on older hardware.

In this case a workaround can be to simply use any other bootable media like USB thumb drives and CD-ROMs. The process is relatively simple:

Use a common tool Media Creator to create a bootable medium like a USB stick or ISO image. Since we do not use the image downloaded by the tool, the only important choice is architecture.

In the image or the USB drive, replace sources/boot.wim with the version from the installation media.

Boot from the medium.

4.5 Command Line Interface

The framework used for implementation of command line client for foreman provides many features common for modern CLI applications. The task of managing Foreman from command line is quite complex so the commands have to be organized in more levels of subcommands. There is help available for each level to make it easy to use. Some other features for greater comfort are option validation, logging and customizable output formatting.

4.5.2 Success Story

There was a set of common commands identified as necessary for basic Foreman management, we called it “success story” and track the progres of its implementation. The commands could also serve as a basic hammer cookbook.

The goal is to provision bare metal host on a clean install of Foreman. The following steps are necessary:

4.6 Email Management

Foreman is also able to send out a variety of email notifications either on an event, or summary messages on a regular schedule. Plugins are also able to extend this with their own summaries and notifications.

To send email requires a configured SMTP server or local MTA (e.g. sendmail), which is set up in /etc/foreman/email.yaml as per Configuration Options.

Scheduled emails are sent through rake tasks (reports:daily, reports:weekly, reports:monthly) run from cronjobs, which are configured in /etc/cron.d/foreman.

4.6.1 Email Preferences

Users

Email messages are sent to individual users registered to Foreman, to the email address configured on the account if present. Users can edit the email address by clicking on their name in the top-right hand corner of the web page and selecting My account.

To change which message subscriptions are received by an individual user, the Mail Preferences tab under the user account lists all available message types and the frequency at which each message should be received. A global checkbox to disable all email messages from Foreman is also available.

Event-based notifications can either be enabled or disabled, and these are sent from Foreman at the same time as the event occurring. Scheduled notifications can be sent either daily, weekly or monthly.

Hosts

Notifications relating to hosts can be disabled on a per-host basis, useful when errors are expected. On the host’s Additional Information tab, untick Enabled to disable notifications and remove the host from reports. Enabling and disabling notifications can also be done from the host list by using the tickboxes and selecting Enable/Disable Notifications from the Select Action dropdown menu.

Event notifications for a host are sent to the host’s registered owner. This is selected on the Additional Information tab of the host, and may be either an individual user or a user group. When set to a user group, all group members who are subscribed to the email type will receive a message.

4.6.2 Account Notifications

New account welcome email

When the send_welcome_email setting is enabled (Configuration Options), new account holders will receive an email providing their username and a link to Foreman.

4.6.3 Host Notifications

Build complete

When a host has completed its build process, either notifying Foreman of completion via a request at the end of its unattended installation or after Foreman has run a script remotely, this email notification will be sent to owners of the host.

Puppet error state

When a Puppet report is received that puts the host into a red error state, a corresponding email notification is sent to owners of the host.

4.6.4 Scheduled Emails

Audit summary

A regular summary email of all changes to objects in Foreman that triggered audit events (see Auditing), including the user that made the change, the time of the change and a link to further details.

Puppet summary

A regular overview of all hosts that a user has access to, and their Puppet status. This includes the number of Puppet events over the reporting period, such as applied, skipped and failed resources.

4.7 Managing Ansible

4.8 Managing Chef

4.9 Managing Salt

4.10 Monitoring

To monitor your infrastructure, host statuses are useful. In Foreman each host
has a global status that indicates which hosts need attention. Each host also
has sub-statuses that represents status of a particular feature. With any change
of a sub-status, the global status is recalculated and the result is determined
by stauses of all sub-statuses.

4.10.1 Global status

The global status represents the overall status of a particular host. The
status can have one of three possible values - OK, Warning or
Error.

OK means that no errors were reported by any sub-status. It is represented
with the color green.

Warning suggests that user should verify the status, while
no error was detected, some sub-status raised a warning. A good example would
be that there are no Puppet reports for the host even though the host is
configured to send Puppet reports. Therefore it is highlighted with the color
yellow.

The last possible value is Error which indicates that some sub-status
reports a failure. This could for example mean that Puppet run contains
some failed resources. Obviously it is something that should be fixed and
is user is alerted by the color red.

You can find global status on hosts overview page displayed as a small icon
next to host name with corresponding color. Hovering over the icon renders
a tooltip with sub-status information to quickly find out more details.

4.10.2 Sub-statuses

A sub-status monitors only a part of host capabilities. Currently Foreman ships
only two - build and configuration sub-statuses. Not all sub-statuses
are relevant for all hosts, therefore configuration is only considered if host
is using some configuration management system, e.g. has some Puppet proxy
associated. Build sub-status is relevant for managed hosts and when Foreman is
run in unattended mode.

You can see a global host status with all sub-statuses on the host detail page,
in the properties table. Note that there can be more sub-statuses added by
plugins.

Each sub-status can define own set of possible values that are mapped to three
global status values. Build sub-status has two possible values - pending
and built that are both mapped to global OK value. Configuration status
is more complicated and its possible values and mappings are described in table
below.

Status value

Maps to

Description

Error

Error

Error during configuration, e.g. Puppet run failed to install some package

Out of sync

Warning

Configuration report was not received even though it was expected based on puppet_interval and outofsync_interval settings.

No reports

Warning / OK

When there are no reports but the host uses configuration management system (e.g. Puppet proxy is associated) or always_show_configuration_status setting is set to true, it maps to Warning. Otherwise it is mapped to OK.

Active

OK

During last Puppet run, some resources were applied

Pending

OK

During last Puppet run, some resources would be applied but Puppet was configured to run in noop mode

No changes

OK

During last Puppet run, nothing has changed

4.10.3 Searching by statuses

You can search hosts by global status. Some examples can be found below:

search for all hosts that are OK

global_status = ok

search for all hosts that deserves some attention

global_status = error or global_status = warning

To search hosts based on configuration status you can search by last report
metrics like this:

find hosts that have at least one pending resource

status.pending > 0

find hosts that restarted some service during last puppet run

status.restarted > 0

find hosts that have an interesting last Puppet run (something happened)

status.interesting = true

5. Advanced Foreman

5.1 API

API v2 is the default, stable and recommended version for Foreman 1.16. API v1 is also available, but future versions of Foreman will eventually deprecate and remove it.

This section documents the JSON API conventions for the Foreman API v2 and Katello API v2. To explicitly select the API version, see Section 5.1.6.

5.1.1 CRUD Request Examples

The following examples show the basic CRUD operations (Create, Read, Update, Delete) using the JSON API.

subtotal - number of objects returned with given search parameters (if there is no search, then subtotal equals total)

page (Foreman only) - page number

per_page (Foreman only) - maximum number of objects returned per page

limit - (Katello only) specified number of objects to return in collection response

offset - (Katello only) number of objects skipped before beginning to return collection.

search - search string (based on scoped_scoped syntax)

sort

by - the field that the collection is sorted by

order - sort order, either ASC for ascending or DESC for descending

results - collection of objects. See Section 5.1.4 for how to change the root name from ‘results’ to something else.

5.1.3 JSON Response Format for Single Objects

Single object JSON responses are used to show a single object. The object’s unique identifier :id or :name is required in the GET request. Note that :name may not always be used as a unqiue identifier, but :id can always be used. The format for a single object JSON response consists of only the object’s attributes. There is no root node and no metadata by default. See Section 5.1.4 for how to add a root name.

Below is an example of the format for a single object JSON response: GET /api/domains/23 or GET /api/domains/qa.lab.example.com

Customize Partial Response Attributes

Currently, there is no option to change or customize which attributes are returned for collections or single objects. In the future, customized partial responses such as fields=field1,field2,field3 or fields=all may be implemented (#3019). Similarly, there is currently no option to specify child nodes in an API call or to remove child nodes if they are returned by default.

Custom Number of Objects in Collection Per Response

Foreman paginates all collections in the JSON response. The number of objects returned per request is defined in Administer > Settings > General > entries_per_page. The default is 20. Thus, if there are 27 objects in a collection, only 20 will be returned for the default page=1.

To view the next page, pass page= as a URL parameter. See example below:

This will return all the objects in one request since 27 is less than the per_page parameter set to 1000.

Custom Search of Collections Per Response

Foreman uses the scoped_search library for searching and filtering which allows all query search parameters to be specified in one string. The syntax is described in the Searching section, and matches exactly the syntax used for the web UI search boxes. This allows you use of the auto-completer and to test a query in the UI before reusing it in the API.

To filter results of a collection, pass search= as a URL parameter, ensuring that it is fully URL-escaped to prevent search operators being misinterpreted as URL separators. See example below:

This would set the domains for the subnet to be earendil and turgon. If another
domain for example belonged to the subnet before the request, it would be
removed.

5.1.8 Authentication

The API requires authentication for all endpoints, typically using HTTP Basic authentication. Requests with credentials are authenticated against the users stored in Foreman.

HTTP Basic authentication

HTTP Basic authentication (RFC 2617) is supported by a wide range of API and web clients and works by specifying a Base64-encoded username and password in an Authorization header. For example, these common clients can access the API with the following arguments:

curl -u admin:changeme, or curl -u admin (interactive prompt)

wget --user=admin --password=changeme

Every call to the API will require authentication, unless the client supports sessions (see below). Some clients may also support storing credentials in ~/.netrc or similar for more privacy.

No confidentiality is provided with this method, so it is very important to use HTTPS when connecting to Foreman to prevent the plain-text credentials from being obtained. (Note that when require_ssl is enabled, access to the API will only be allowed over HTTPS.)

Session support

When authenticating to the API, a new server-side session will be created on each request and the response will contain a cookie containing a session ID. If this cookie is stored by the client, it can be used on subsequent requests so the credentials are only passed over the connection once.

A basic authenticated request to the status API returns the following Set-Cookie header, containing a _session_id cookie:

Command-line clients may support cookie jars for automatic storage of cookies, e.g. curl -c ~/.foreman_cookies -b ~/.foreman_cookies will automatically store and use cookies.

5.1.9 Using OAuth

Alternatively to basic authentication, limited OAuth 1.0 authentication is supported
in the API.

Configuration of OAuth in Foreman

OAuth must be enabled in Foreman settings. In Administer > Settings > Authentication,
search for OAuth active configuration and set it to Yes. Then set OAuth consumer key
to some string. This will be a token used by all OAuth clients.

If you want all API requests made using OAuth to be authorized as built-in anonymous
admin user keep OAuth map users set to No. If you want to specify the user
under which the request is made, change this configuration option to Yes. This
allows client to send FOREMAN-USER header with the login of existing Foreman user.
Please note that this header is not signed in OAuth request so can be forged.
Anyone with valid consumer key can impersonate any Foreman user.

Request example

Usually some OAuth client library is used to generate the request. An example of
curl command can be found here to better understand how it works

In example above we list architectures using OAuth for authentication. We try to
do the request under user with login ares, if mapping is enabled on Foreman side,
the result will only include architectures, that user ares can see. Note that we
constructed the signature manually, this should change with any oauth_timestamp
change. Also it reflects every parameter, HTTP method and URI change. Therefore
we recommend using some OAuth client library that will construct all OAuth
parameters.

5.1.10 Using Apipie-Bindings

The following examples show how to do basic API operations using apipie-bindings.

Update an Object

Update a domain: PUT /api/domains/:id or PUT /api/domains/:name

Call the update function of the domains resorce with the object’s unique identifer, either :id or :name, plus a JSON data hash containing only the data to be updated. In this example, only the domain name is being updated.

5.2 Compute Resources

Foreman supports creating and managing hosts on a number of virtualization and cloud services - referred to as “compute resources” - as well as bare metal hosts.

The capabilities vary between implementations, depending on how the compute resource provider deploys new hosts and what features are available to manage currently running hosts. Some providers are able to support unattended installation using PXE, while others are image-based. Some providers have graphical consoles that Foreman interfaces to, and most have power management features. A summary of all providers and their support features is given below, and more detailed sections follow with specific notes.

Support for these features is aimed at being as transparent as possible, allowing the same configuration to be applied to hosts irrespective of the provider in use (compute resource or not). The selection of compute resource is made when creating a new host and the host in Foreman’s database remains associated to the VM that’s created, allowing it to be managed throughout the lifetime of the host.

Networking varies between providers - where “MAC” is specified, the compute resource provides the MAC address for newly created virtual machines (layer 2 networking), and IP addresses are assigned in/by Foreman. Where “IPv4” and/or “IPv6” is specified, the compute resource assigns an IP address for virtual machine interfaces (layer 3 networking) and the addresses will be stored by Foreman when creating a host.

5.2.1 Using Compute Resources

The following steps describe how to configure a compute resource and provision new hosts on it.

Add a compute resource under Infrastructure > Compute Resources > New Compute Resource. Select the provider type from the menu and appropriate configuration options will be displayed. Check the notes sections below for any provider-specific setup instructions.

Click the Test Connection button after entering the configuration. If no error is displayed, the test was successful.

After saving the compute resource, existing virtual machines can be browsed by clicking on the compute resource and the Virtual Machines tab.

For providers that use images, click on the compute resource, then the Images tab, where known images are listed. To register images that Foreman can use, click New Image and enter the details.

To provision a new host on this compute resource, from Hosts, click New Host and select the compute resource from the Deploy to menu.

Also note the following features:

When viewing a host, power management controls and the console access button are in the top right hand corner of the page.

If a host provisioned on a compute resource is deleted, the VM and associated storage on the compute resource will also be deleted.

Users in Foreman can have access restricted to hosts present on certain compute resources. For more information, see Filtering in 4.1.2 Roles and Permissions.

5.2.2 Using Compute Profiles

A compute profile is a way of expressing a set of defaults for VMs created on a
specific compute resource that can be mapped to an operator-defined label. This
means an administrator can express, for example, what “Small”, Medium” or
“Large” means on all of the individual compute resources present for a given
installation.

In combination with host groups, this allows a user to completely define a new
host from just the Host tab of the New Host form.

You can find the configuration for compute profiles at Infrastructure >
Compute Profiles

Default Profiles

By default, Foreman comes with 3 predefined profiles; “1-Small”, “2-Medium”,
and “3-Large” (the numbers are just to make them sort nicely). They come with
no associated configuration for any particular compute resource, and as such,
they can be deleted or renamed as required.

Assigning information to a Profile

This walkthrough will define what “1-Small” means for a particular
installation. It will also assume there are two compute resources; one Libvirt
and one EC2 (these make a good example as they are very different).

Start by editing the compute profile, by clicking its name in the profile
list. This leads to a list of all your current compute resources. Later,
once the configuration is done, this list will also display the current
defaults configured for each compute resource.

EC2

Clicking on the EC2 resource will bring up a page very similar to the one used
when provisioning a single host. Here an administrator can set what “1-Small”
means on this specific EC2 resource. For this example, “m1.small” is selected
as the size. Defaults can also be specified for the image choice, the security
groups, and so on.

The changes are submitted, and on returning to the profile list, the new EC2
defaults will be shown.

Libvirt

In a very similar manner, the Libvirt resource can be clicked upon, and some
defaults assigned. For this example, since this is the “1-Small” profile, 1
CPU, 512MB of RAM, a single bridged network device, and a 5GB disk are
selected.

Again, the changes are submitted.

Applying a Compute Profile

Now visit Hosts > New Host. At first, things look exactly as before, but once
a compute resource is selected which has at least one compute profile, a new
combo-box will appear. This permits the user to select a profile to apply to
this host. For this example, the Libvirt resource is selected, followed by the
“1-Small” profile.

Once the profile is selected, the Virtual Machine tab will automatically
update to use the defaults configured in the “1-Small” profile.

Assuming the defaults are suitable, the host has now been defined solely by
selecting a host group and a profile. It’s also possible to associate a profile
with a host group in the host group edit page, which will automatically select
that profile when the host group is selected.

5.2.3 EC2 Notes

Add a provisioning template of either type finish or user_data which will be executed on the new image.

‘finish’ templates complete the provisioning process via SSH - this requires Foreman to be able to reach the IP of the new host, and that SSH is allowing connections from Foreman. This uses the SSH key which Foreman uploaded to your compute resource when it was added to Foreman.

‘user_data’ templates instead provision by cloud-init (or similar meta-data retrieving scripts). This will not require Foreman to be able to reach the host, but the host must be able to reach Foreman (since user_data execution is asynchronous, the host must notify Foreman that the build is complete).

Ensure AMIs are added under the Images tab on the compute resource

Ensure the correct username is set for Foreman to SSH into the image (if using SSH provisioning).

Tick the user_data box if the image is capable of using user_data scripts (usually because it has cloud-init installed).

5.2.4 Google Compute Engine Notes

Requires client e-mail address of an authorised Google Cloud Console client ID is entered in the new compute resource screen and its associated .p12 private key file is manually transferred to the foreman server.

The certificate must be stored in a location the foreman user account has permission to read.

If your server enforces SELinux ensure the context is suitable or relabel it using restorecon -vv /usr/share/foreman/gce.p12

Specify the location on the foreman server as the certificate path value e.g /usr/share/foreman/gce.p12

Ensure images are associated under the Images tab on the compute resource.

Add a provisioning template of type finish which will be executed over SSH on the new image.

Ensure the finish template is associated to the OS (on the Associations tab) and is set as the default for the operating system too.

Click Generate new P12 key and save the new .p12 file. This should be uploaded to the Foreman server to a location that the ‘foreman’ user can read, such as /usr/share/foreman/gce.p12. You don’t need to provide any password to Foreman to use this PKCS12 key.

Change the .p12 file owner to 'foreman' and chmod 0600 for security. If your server uses SELinux ensure the context is suitable or relabel it using restorecon -vv /usr/share/foreman/gce.p12

Adding the compute resource

In Foreman, under Infrastructure > Compute resources > New compute resource, select Google from the provider dropdown menu and fill in the GCE-specific fields as follows:

If you have difficulty connecting, test access using the virsh command under the ‘foreman’ account on the Foreman host first, e.g. virsh -c qemu+ssh://hypervisor.example.com/system list.

Image provisioning

Image based provisioning can be used by provisioning a VM with a backing image and then running a finish script over SSH, in the same manner as the EC2 provider. The type of provisioning method can be selected under the “Operating system” tab when creating a new host. To configure image/template-based provisioning:

Add the image by navigating to the compute resource and clicking New Image, enter the full path to the backing image in the Image path field.

Ensure the image is not modified as long as hosts exists that are using it, or they will suffer data corruption.

Two methods to complete provisioning are supported. Either by SSHing into the newly created VM and running a script:

The template needs to have a username and password set up for Foreman to SSH in after provisioning and run the finish script.

This requires some form of DHCP orchestration for SSH access to the newly created host to work.

A finish template to perform any post-build actions (e.g. setting up Puppet) must also be associated to the host, usually by changing the OS default finish template.

Or select the userdata checkbox when adding the image to Foreman, and a cloud-init compatible disk will be attached to the VM containing the userdata:

The template will need cloud-init installed and set to run on boot.

A userdata template to perform any post-build actions (e.g. setting up Puppet) must also be associated to the host, usually by associating the UserData default template.

The template will need to “phone home” to mark the host as built.

5.2.6 OpenStack Notes

Supports OpenStack Nova for creating new compute instances.

Add a provisioning template of either type finish or user_data which will be executed on the new image.

‘finish’ templates complete the provisioning process via SSH - this requires Foreman to be able to reach the IP of the new host, and that SSH is allowing connections from Foreman. This uses the SSH key which Foreman uploaded to your compute resource when it was added to Foreman.

‘user_data’ templates instead provision by cloud-init (or similar meta-data retrieving scripts). This will not require Foreman to be able to reach the host, but the host must be able to reach Foreman (since user_data execution is asynchronous, the host must notify Foreman that the build is complete).

Ensure Glance Images are added under the Images tab on the compute resource.

Ensure the correct username is set for Foreman to SSH into the image (if using SSH provisioning).

Tick the user_data box if the image is capable of using user_data scripts (usually because it has cloud-init installed).

Security groups can be selected on the Virtual Machine tab when creating a host.

The Floating IP Network dropdown menu allows selection of the network Foreman should request a public IP on. This is required when using SSH provisioning.

Ensure that the selected template is associated to the OS (on the Associations tab) and is set as the default for the operating system too.

A finish-based example for configuring image-based provisioning is given on the Foreman blog, also applicable to OpenStack: EC2 provisioning using Foreman.

5.2.7 oVirt / RHEV Notes

SPICE consoles are displayed using an HTML5 client, so no native XPI extension is necessary.

Image provisioning

Image based provisioning can be used by provisioning a VM with a template and then running a finish script over SSH, in the same manner as the EC2 provider. The type of provisioning method can be selected under the “Operating system” tab when creating a new host. To configure image/template-based provisioning:

Images refer to templates and can be added by navigating to the compute resource and clicking New Image.

The template needs to have a username and password set up for Foreman to SSH in after provisioning and run the finish script.

This requires some form of DHCP orchestration for SSH access to the newly created host to work.

A finish template to perform any post-build actions (e.g. setting up Puppet) must also be associated to the host, usually by changing the OS default finish template.

Permissions required

When defining a compute resource you have to provide a user account used for communication with oVirt. It must have Admin account type role(s) with following permissions:

5.2.9 VMware Notes

Only VMware clusters using vSphere are supported, not standalone ESX or ESXi servers (#1945).

Image provisioning

Image based provisioning can be used by provisioning a new VM from a template and then running a finish script over SSH, in the same manner as the EC2 provider. The type of provisioning method can be selected under the “Operating system” tab when creating a new host. To configure image/template-based provisioning:

Images refer to templates stored in vSphere which will be used as the basis for a new VM.

Add the image by navigating to the compute resource and clicking New Image, enter the relative path and name of the template on the vSphere server, e.g. My templates/RHEL 6 or RHEL 6 if it isn’t in a folder. Do not include the datacenter name.

The template needs to have a username and password set up for Foreman to SSH in after provisioning and run the finish script.

This requires some form of DHCP orchestration for SSH access to the newly created host to work.

A finish template to perform any post-build actions (e.g. setting up Puppet) must also be associated to the host, usually by changing the OS default finish template.

Image provisioning without SSH

The same process can also be done using a user_data template. To configure image/template-based provisioning without SSH, make the following adjustments for the former procedure:

If permanent shared storage is available (direct-attach SAN, etc): rather than doing a file copy on each server, use a symlink instead. Once it’s changed on the shared storage, run a loop to refresh the firewall services. The local.sh file still needs to be created.

Required Permissions

The minimum permissions to properly provision new virtual machines are:

All Privileges -> Datastore -> Allocate Space

All Privileges -> Network -> Assign Network

All Privileges -> Resource -> Assign virtual machine to resource pool

All Privileges -> Virtual Machine -> Configuration (All)

All Privileges -> Virtual Machine -> Interaction

All Privileges -> Virtual Machine -> Inventory

All Privileges -> Virtual Machine -> Provisioning

Notes

Log in to the VMware vSphere Server that represents the Compute Resource. Create a role with the above permissions. Add the appropriate account to the role. To create user accounts, roles or for complete details on administration of VMware vSphere, please consult your VMware vSphere Server documentation.

The account that foreman uses to communicate with VCenter is assumed to have the ability to traverse the entire inventory in order to locate a given datacenter. A patch is required to instruct foreman to navigate directly to the appropriate datacenter to avoid permission issues (#5006).

5.2.10 Password Encryption

Compute resource passwords and secrets are stored on the Foreman database using a secret - the encryption key - and ciphered using AES-256-CBC.
The encryption key can usually be found in /etc/foreman/encryption_key.rb, which is symlinked to /usr/share/foreman/config/initializers/encryption_key.rb. The value of the ENCRYPTION_KEY variable must be at least 32 bytes long.

If you want to regenerate the key, you can run foreman-rake security:generate_encryption_key. Please remember that previously encrypted passwords cannot be decrypted with a different encryption key, so decrypt all passwords before changing your encryption key.

After you make sure you have a valid encryption key, you can encrypt your Compute Resource secrets in the database by running foreman-rake db:compute_resources:encrypt.
To unencrypt them, run the task foreman-rake db:compute_resources:decrypt.

Keep in mind passwords are encrypted in the Foreman database, but Foreman will decrypt them and use unencrypted credentials to authenticate to Compute Resources.

5.4.1 Securing Puppet Master Requests

In a typical ENC-based setup with reporting, puppet masters require access to Foreman for three tasks:

Retrieval of external nodes information (classes, parameters)

Uploading of host facts

Uploading of host reports

All traffic here is initiated by the puppet master itself. Other traffic from Foreman to the puppet master for certificate signing etc. is handled via smart proxies (SSL configuration covered in the next section).

Configuration options

The Foreman interface authorizes access to puppet master interfaces based on its list of registered smart proxies with the Puppet feature, and identifies hosts using client SSL certificates.

Five main settings control the authentication, the first are in Foreman under Settings, Authentication:

require_ssl_smart_proxies (default: true), requires a client SSL certificate on the puppet master requests, and will verify the CN of the certificate against the smart proxies. If false, it uses the reverse DNS of the IP address making the request.

restrict_registered_smart_proxies (default: true), only permits access to hosts that have a registered smart proxy with the Puppet feature.

trusted_puppetmaster_hosts, a whitelist of hosts that overrides the check for a registered smart proxy

And two in config/settings.yaml:

login (default: true), must be enabled to prevent anonymous access to Foreman.

require_ssl (default: false), should be enabled to require SSL for all communications, which in turn will require client SSL certificates if require_ssl_smart_proxies is also enabled. If false, host-based access controls will be available for HTTP requests.

Enabling full SSL communications

Using Apache HTTP with mod_ssl and mod_passenger is recommended. For simple setups, the Puppet certificate authority (CA) can be used, with Foreman and other hosts using certificates generated by puppet cert.

Set Foreman’s require_ssl_smart_proxies, restrict_registered_smart_proxies and require_ssl to true.

The mod_ssl configuration must contain:

*SSLCACertificateFile* set to the Puppet CA

*SSLVerifyClient optional*

*SSLOptions +StdEnvVars +ExportCertData*

Puppet ENC/report processor configuration (e.g. /etc/puppetlabs/puppet/foreman.yaml or /etc/puppet/foreman.yaml) should have these settings:

*:ssl_ca* set to the Puppet CA

*:ssl_cert* set to the puppet master's certificate

*:ssl_key* set to the puppet master's private key

Troubleshooting

No SSL cert with CN supplied indicates no client SSL certificate was supplied, or the CN wasn’t present on a certificate. Check the client script has the certificate and key configured and that mod_ssl has SSLVerifyClient set.

SSL cert has not been verified indicates the client SSL certificate didn’t validate with the SSL terminator’s certificate authority. Check the client SSL certificate is signed by the CA set in mod_ssl’s SSLCACertificateFile and is still valid. More information might be in error logs.

SSL is required indicates the client is using an HTTP URL instead of HTTPS.

No smart proxy server found on $HOST indicates Foreman has no smart proxy registered for the source host, add it to the Smart Proxies page in Foreman. A common cause of this issue is the hostname in the URL doesn’t match the hostname seen here in the log file - change the registered proxy URL to match. If no smart proxy is available or can be installed, use trusted_puppetmaster_hosts and add this hostname to the whitelist.

Advanced SSL notes

A typical small setup will use a single Puppet CA and certificates it provides for the Foreman host and puppet master hosts. In larger setups with multiple CAs or an internal CA, this will require more careful configuration to ensure all hosts can trust each other.

Ensure the Common Name (CN) is present in certificates used by Foreman (as clients will validate it) and puppet master clients (used to verify against smart proxies).

Foreman’s SSL terminator must be able to validate puppet master client SSL certificates. In Apache with mod_ssl, the SSLCACertificateFile option must point to the CA used to validate clients and SSLVerifyClient set to optional.

Environment variables from the SSL terminator are used to get the client certificate and verification status. mod_ssl’s SSLOptions +StdEnvVars +ExportCertData setting enables this. Variable names are defined by ssl_client_cert_env, ssl_client_dn_env and ssl_client_verify_env settings in Foreman.

Reduced security: HTTP host-based authentication

In non-SSL setups, host-based authentication can be performed, so any connection from a host running a puppet smart proxy is able to access the interfaces.

Set restrict_registered_smart_proxies to true.

Set require_ssl_smart_proxies and require_ssl to false.

No security: disable authentication

Entirely disabling authentication isn’t recommended, since it can lead to security exploits through YAML import interfaces and expose sensitive host information, however it may be useful for troubleshooting.

Set require_ssl_smart_proxies, restrict_registered_smart_proxies and require_ssl to false.

5.4.2 Securing Smart Proxy Requests

Foreman makes HTTP requests to smart proxies for a variety of orchestration tasks. In a production setup, these should use SSL certificates so the smart proxy can verify the identity of the Foreman host.

In a simple setup, a single Puppet Certificate Authority (CA) can be used for authentication between Foreman and proxies. In more advanced setups with multiple CAs or an internal CA, the services can be configured as follows.

Proxy configuration options

/etc/foreman-proxy/settings.yml contains the locations to the SSL certificates and keys:

---
# SSL Setup
# if enabled, all communication would be verified via SSL
# NOTE that both certificates need to be signed by the same CA in order for this to work
# see http://theforeman.org/projects/smart-proxy/wiki/SSL for more information
:ssl_certificate: /var/lib/puppet/ssl/certs/FQDN.pem
:ssl_ca_file: /var/lib/puppet/ssl/certs/ca.pem
:ssl_private_key: /var/lib/puppet/ssl/private_keys/FQDN.pem

In this example, the proxy is sharing Puppet’s certificates, but it could equally use its own. Under a Puppet 4 AIO installation, substitute above paths with /etc/puppetlabs/puppet/ssl/.

In addition it contains a list of hosts that connections will be accepted from, which should be the host(s) running Foreman:

# the hosts which the proxy accepts connections from
# commenting the following lines would mean every verified SSL connection allowed
:trusted_hosts:
- foreman.corp.com
#- foreman.dev.domain

Configuring Foreman

For Foreman to connect to an SSL-enabled smart proxy, it needs configuring with SSL certificates in the same way.

The locations of the certificates are managed in the Settings page, under Provisioning - the ssl_ca_file, ssl_certificate and ssl_priv_key settings. By default these will point to the Puppet locations - for manually generated certificates, or non-standard locations, they may have to be changed.

Lastly, when adding the smart proxy in Foreman, ensure the URL begins with https:// rather than http://.

Sharing Puppet certificates

If using Puppet’s certificates, the following lines will be required in puppet.conf to relax permissions to the puppet group. The foreman and/or foreman-proxy users should then be added to the puppet group.

Note that the “service” keyword will be interpreted by Puppet as the “puppet” service group.

5.5 Backup, Recovery and Migration

This chapter will provide you with information how to backup and recover
your instance. All commands presented here are just examples and should be
considered as a template command for your own backup script which differs from
one environment to other.

It is possible to perform a migration by doing backup one one host and
recovery on a different host, but in this case pay attention to different
configuration between the two hosts.

This can be applied to the Foreman application itself, but pay attention when
migrating smart-proxy and services because things like different IP addresses
or hostnames will need manual intervention.

5.5.1 Backup

This chapter will provide you with information how to backup a Foreman
instance.

Database

PostgreSQL, MySQL, SQLite

Run foreman-rake db:dump. It will print a message when it finishes with the dump
file location relative to the Foreman root.

SQLite disclaimer

SQLite databases are all contained in a single file, so you can back them up
by copying the file to another location, but it is recommended to shut down
the instance first, or at least verify the integrity of the created archive
using sqlite3 command. The dump command above is preferred.

Puppet master

On the puppet master node, issue the following command to backup Puppet
certificates on Red Hat compatible systems

tar --selinux -czvf var_lib_puppet_dir.tar.gz /var/lib/puppet/ssl

For all other distribution do similar command:

tar -czvf var_lib_puppet_dir.tar.gz /var/lib/puppet/ssl

Under a Puppet 4 AIO installation, back up /etc/puppetlabs/puppet/ssl instead.

DHCP, DNS and TFTP services

Depending on used software packages, perform backup of important data and
configuration files according to the documentation. For ISC DHCP and DNS
software, these are located within /etc and /var directories depending on your
distribution as well as TFTP service.

5.5.2 Recovery

Recovery process is supposed to be performed on the same host the backup was
created on on the same distribution and version.

If you planning to migrate Foreman instance, please read remarks in the
beginning of this chapter.

Note: Foreman instance must be stopped before proceeding.

PostgreSQL, MySQL, SQLite

Run foreman-rake db:import_dump file=/your/db/dump/location. This will load your
dump into the current database for your environment. It will print a message
to notify you when it has finished importing the dump.

Remember to stop the Foreman instance and any other process consuming data from the
database temporarily during the import and turn it back on after it ends.

Puppet masters: URLs and cert/key filenames in /etc/puppetlabs/puppet/foreman.yaml or /etc/puppet/foreman.yaml

5.6 Rails Console

Foreman is a Ruby on Rails application, which provides an interactive console for advanced debugging and troubleshooting tasks. Using this allows easy bypass of authorization and security mechanisms, and can easily lead to loss of data or corruption unless care is taken.

To access the Rails console, choose the method below appropriate to the installation method.

RPM and Debian installations

As root, execute:

yum install foreman-console
foreman-rake console

or to run in sandboxed mode, which rolls back changes on exit, execute:

foreman-rake console ----sandbox

Source installations

As the user running Foreman and in the source directory, execute:

RAILS_ENV=production bundle exec rails c

or to run in sandboxed mode, which rolls back changes on exit, execute:

RAILS_ENV=production bundle exec rails c --sandbox

Set up

To assume full admin permissions in order to modify objects, enter in the console:

User.current=User.only_admin.visible.first

5.7 External Authentication

The following tutorial explains how to set up Foreman authentication against FreeIPA (or Identity Management) server. First part of the tutorial describes how to configure Foreman machine via Foreman installer options. The second one shows how to achieve the same result without using these options.

5.7.1 Configuration via Foreman installer

We assume the Foreman machine is FreeIPA-enrolled:

ipa-client-install

On the FreeIPA server, we create the service.
(Please make sure you have obtained Kerberos ticket before this step - for example, by using kinit.)

ipa service-add HTTP/<the-foreman-fqdn>

Then we install Foreman.

foreman-installer --foreman-ipa-authentication=true

This option can be used for the reconfiguration of existing installation as well.

In case you want to use IPA server’s host-based access control (HBAC) features (make sure allow_all rule is disabled), the default PAM service name (which would be matched by HBAC service name) is foreman. You can override the default name with:

Chances are there will be HBAC rule allow_all matching besides our new allow_foreman_prod rule. See http://www.freeipa.org/page/Howto/HBAC_and_allow_all for steps to disable the catchall allow_all HBAC rule while maintaining the correct operation of your FreeIPA server and enrolled clients. The goal is only allow_foreman_prod matching when checked with ipa hbactest.

5.7.3 Kerberos Single Sign-On

In this part of the tutorial we will show how to set up Foreman authentication manually (without using installer option).

At first we enroll Foreman machine and define HTTP/<the-foreman-fqdn> service in the FreeIPA server. Then we define HBAC service and rules (for more information see the previous section). In the following steps we will use the HBAC service name foreman-prod.

Next step is to define matching PAM service on the Foreman machine. We create file /etc/pam.d/foreman-prod with the following content:

auth required pam_sss.so
account required pam_sss.so

We will also want to enable two SELinux booleans on the Foreman machine:

Until all the packages are part of your operation system distribution, you can get them from Jan Pazdziora’s copr yum repo. At http://copr.fedoraproject.org/coprs/adelton/identity_demo/ choose the correct .repo file. For example, for Foreman on RHEL 6, the following command will configure yum:

We tell Foreman that it is OK to trust the authentication done by Apache by adding to /etc/foreman/settings.yml or under Administer > Settings > Authentication:

:authorize_login_delegation:true

We restart Apache:

service httpd restart

The machine on which you run the browser to access Foreman’s WebUI needs to be either FreeIPA-enrolled to the FreeIPA server or at least configured (typically in /etc/krb5.conf) to know about the FreeIPA server Kerberos services. The browser needs to have the Negotiate Authentication enabled; for example in Firefox, in the about:config settings, network.negotiate-auth.trusted-uris needs to include the Foreman server FQDN or its domain. If you then kinit as existing Foreman user to obtain Kerberos ticket-granting ticket, accessing Foreman’s WebUI should not ask for login/password and should display the authenticated dashboard directly.

Please note that we use directive require pam-account foreman-prod to also check the access against FreeIPA’s HBAC rule. If you do not see Kerberos authentication passing, check that the user is allowed access in FreeIPA (in the section about HBAC configuration we’ve named the HBAC rule allow_forman_prod).

5.7.4 PAM Authentication

The FreeIPA server can be used as an authentication provider for Foreman’s standard logon form. We assume the Foreman machine is already FreeIPA-enrolled so sssd is configured to be able to facilitate the authentication, and we have PAM service foreman-prod configured.

We will install the necessary Apache modules:

yum install -y mod_intercept_form_submit mod_authnz_pam

We will then configure Apache to perform PAM authentication (and access control check) using the PAM service foreman-prod, for example in configuration file /etc/httpd/conf.d/intercept_form_submit.conf:

After restarting Apache with service httpd restart, you should be able to log in to Foreman’s WebUI as existing user, using password from the FreeIPA server. Please note that intercept_form_submit_module uses authnz_pam_module to run not just the authentication, but access check as well. If the authentication does not pass and you are sure you use the correct password, check also that the user is allowed access in FreeIPA HBAC rules.

5.7.5 Populate users and attributes

So far we have tried external authentication for existing Foreman users.

However, it is also possible to have the user’s records in Foreman created automatically, on the fly when they first log in using external authentication (single sign-on, PAM).

The first step to enable this feature is to add

:authorize_login_delegation_auth_source_user_autocreate: External

to /etc/foreman/settings.yaml or under Administer > Settings > Authentication.

Since we will want the newly created user records to have valid name and email address, we need to set up sssd to provide these attributes and mod_lookup_identity to pass them to Foreman. We start by installing the packages:

Now when you log in either using Kerberos ticket or using user’s FreeIPA password (make sure the user has access allowed in FreeIPA HBAC rule), even if the user did not log in to Foreman before, their record will be populated with name and email address from the FreeIPA server (you can check in the top right corner that the full name is there) and they will also be updated upon every subsequent externally-authentication logon.

You might notice that the newly created user does not have many access right. To fully use the central identity provider like FreeIPA, it can be useful to link group membership of externally-authenticated Foreman users to the group membership of users in FreeIPA, and then set Foreman roles to these user groups. That way when a new network administrator has their record created in FreeIPA with proper user groups and then logs in to Foreman for the first time, their Foreman account will automatically get group memberships in Foreman groups, giving them appropriate roles and access rights.

The prerequisite is obviously to have the user groups and mamberships set appropriately for your organization in FreeIPA.

For each FreeIPA user group that should have some semantics in Foreman, we create new user groups in Foreman, and then use the tab External groups and Add external user group to add name of the user group in FreeIPA, for Auth source EXTERNAL. We can then assign roles to this Foreman user group to match the desired role for users from the given FreeIPA user group.

Upon their first login, externally-authenticated users will get their group membership in Foreman set to match the mapping to FreeIPA groups and their group membership in FreeIPA. Upon subsequent externally-authenticated logons, the membership in these mapped groups will be updated to match the current membership in FreeIPA.

5.7.6 Namespace separation

If clear namespace separation of internally and externally authenticated users is desired, we can distinguish the externally authenticated (and populated) users by having @REALM part in their user names.

For the Kerberos authentication, using KrbLocalUserMapping Off will keep the REALM part of the logon name:

For the PAM authentication, using InterceptFormLoginRealms EXAMPLE.COM will make the user’s login include this @REALM part (even if the
user did not explicitly specify it), thus matching the username seen by Foreman when authenticated via Kerberos ticket:

With this configuration, the @REALM will be part of the username and it would be clear that bob is INTERNAL-authenticated and bob@EXAMPLE.COM is different user, EXTERNAL-authenticated. The admin then can manually create another admin@EXAMPLE.COM user (with administrator privileges) and even the admin can use Kerberos or PAM authentication in this setup.

5.8 Multiple Foreman instances

The following steps are suggested when configuring multiple Foreman instances to work together. They will ensure that data, passwords, and cookies are shared between multiple instances.

$app_root is wherever you installed Foreman, usually /usr/share/foreman.

5.8.1 Sharing the database

All Foreman instances in a cluster/group must point to the same database. This can be done using foreman-installer or by directly altering /etc/foreman/database.yaml and pointing the correct environment (usually production) to your Foreman DB, then restarting Foreman.

5.8.2 Encrypting passwords

As described in 5.2.10, passwords stored locally in Foreman’s DB are encrypted. In order for multiple Foreman instances to encrypt and decrypt passwords correctly, they all need to have the same encryption key defined in /etc/foreman/encryption_key.rb.

5.8.3 Signing cookies

The last file required to make a Foreman cluster work is $app_root/config/initializers/local_secret_token.rb, which is used to sign cookies. This should be set the same across all Foreman servers in your cluster. Once you have set local_secret_token.rb, restart Foreman and clear Foreman’s cache:

6. Plugins

7. Troubleshooting

7.1 NoVNC

Foreman uses the excellent javascript VNC library noVNC, which allows clientless VNC within a web browser. When a console is opened by the user’s web browser, Foreman opens a connection to TCP Port 5910 (and up) on the hypervisor and redirects that itself.

Requirements

Recent web browser

Open network connection from the workstation where the web browser runs on to your Foreman server and from your Foreman server to the hypervisor on TCP ports 5910 - 5930.

Encrypted Web Sockets

For VNC only, encrypted connections are the default on new installations. If you have an older installation of Foreman, you can configure encrypted websockets by adding these lines to /etc/foreman/settings.yml, and configuring the correct path to the same SSL certificates apache uses:

Known issues

SPICE connections are not encrypted.

For encrypted connections, you will need to trust the Foreman CA. This is typically stored in /var/lib/puppet/ssl/certs/ca.pem, you may wish to copy this to something like /var/www/html/pub/ca.crt so that users may easily find it.

Keyboard mappings are currently fixed to English only.

When using Firefox, if you use Foreman via HTTPS, Firefox might block the connection. To fix it, go to about:config and enable network.websocket.allowInsecureFromHTTPS.

When using Chrome, browse to chrome://flags/ and enable allow-insecure-websocket-from-https-origin. Recent versions of Chrome (e.g. 44) have removed the flag. An alternative workaround is to launch Chrome with a command-line argument like this $ google-chrome-stable --allow-running-insecure-content &

Troubleshooting Steps

Check for a “websockify.py” process on your Foreman server when opening the console page in Foreman

If websockify.py is missing, check /var/log/foreman/production.log for stderr output with logging increased to debug

Look at the last argument of the process command line, it will have the hypervisor hostname and port - ensure you can resolve and ping this hostname

Make sure you access Foreman web UI via FQDN as the certificate does not have shortened hostname.

Try a telnet/netcat connection from the Foreman host to the hypervisor hostname/port

The penultimate argument of websockify.py is the listening port number, check if your web client host can telnet to it

If using Firefox, check the known issues above and set the config appropriately

The error “WebSock error: [object Event]” can be caused by a self signed certificate, where the certificate`s algorithm is too weak, e.g. SHA1.
Debugging the issue with the Firefox JavaScript Console will show a warning similar to “This site makes use of a SHA-1 Certificate; it’s recommended you use certificates with signature algorithms that use hash functions stronger than SHA-1”. See Weak Signature Algorithms on Mozilla website.

To solve this issue, use stronger SSL certificates like SHA-2 algorithms instead.

Check your current algorithm used for the SSL certificate with openssl and generate a new one if necessary:

7.3 No Reports

If you just installed a fresh Foreman server with Puppet 4.x and it looks like it doesn’t receive any
reports from Puppet clients, this is possible due to a known issue in puppet server:
https://tickets.puppetlabs.com/browse/SERVER-17.

The following is a workaround tested on Ubuntu 16.04:

Install bouncycastle provider for Java:

sudo apt-get install libbcprov-java

Edit java.security (location depends on the Java version installed)

sudo sensible-editor /etc/java-8-openjdk/security/java.security

Insert the bouncycastle provider at the second position (around line 69 of the file)

Forum

Gathering information

In order to troubleshoot and get relevant data use foreman-debug which collects information about your OS, Foreman and related components.
If you installed from packages, the command is available to root:

# foreman-debug

If you installed from git, you can find it in the Foreman directory:

# script/foreman-debug

If you run it without any options, it will collect data, filter out possible
passwords or tokens and create a tarball which can be safely handed over to
us.

To upload the tarball to our public server via rsync use:

# foreman-debug -u

This is a write-only directory (readable only by Foreman core developers), please note that the rsync transmission is UNENCRYPTED.