1. Foreman 1.6 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 allow for TFTP, DHCP, DNS, and Puppet, and the Puppet CA.

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.

Foreman Architecture

Release notes for 1.6

Headline features

Smart Proxy plugin support

The Smart Proxy has followed Foreman itself in getting support for plugins, enabling developers to write new APIs and integrate it with other types of systems. The first plugins extend the proxy with functionality around ABRT (Automatic Bug Reporting Tool), Pulp and Salt.

Future plugins will likely be paired with Foreman plugins, enabling management of other services or extending provisioning models (e.g. discovery). Existing proxy functionality may be split out in later versions, enabling faster development and better dependency management via packaging.

For existing proxy users, the most notable change is in configuration, which has been split from a single settings.yml file into a directory at /etc/foreman-proxy/settings.d/. During package upgrades, existing config files will be migrated to the new layout. Reference information is in the updated Smart Proxy Settings chapter.

API version 2 is stable

API version 2 (aka APIv2) is now declared stable and is recommended for use instead of version 1. This version is largely similar, but adds a lot of routes for managing nested resources such as Puppet class parameters, network interfaces and compute profiles. Future releases of Foreman will avoid incompatible changes in the format of the API, however sometimes the meaning and presence of attributes may change.

Notable general features about the API format are:

  • Lists of resources are enclosed in a ‘results’ node, alongside metadata such as the number of entries
  • References to other resources may use names or IDs, e.g. “domain_id” / “domain_name”, or “domain_ids” / “domain_names”
  • Deeper nesting of resources, e.g. /api/v2/puppetclasses/example::class/smart_class_parameters/example_parameter/override_values

The API chapter has more information about accessing the API and the layout of requests and responses. Also see the APIv2 reference documentation available on our website, or via your own Foreman installation by appending /apidoc to the URL to see the API routes available.

External user groups for LDAP and Kerberos group support

User groups in Foreman are now able to be linked to an “external” group in an authentication source - either LDAP, including POSIX, FreeIPA and Active Directory, or via SSSD.

As roles can be assigned to user groups, this enables new users to log in and automatically receive permissions in Foreman via their assigned groups in LDAP etc.

The installer is now able to configure integration between Foreman, Apache and FreeIPA to enable SSO (Single Sign On), instead of requiring manual configuration.

Support for RHEL 7

Foreman 1.6 adds full support for RHEL 7, from installation through to the web UI and proxy services. This relies on Red Hat Software Collections 1.1 (RHSCL) in the same way as EL6 support. Packages are available in the same repositories under ‘el7’.

Please note that rebuilds (CentOS, Scientific Linux) of RHEL 7 are not yet supported as SCL 1.1 is unavailable. As soon as this issue has been resolved, documentation will be updated.

Configurable and extensible dashboard

The dashboard shown after logging in has been revamped to allow plugins to add their own widgets, showing relevant information about other aspects of Foreman to users.

It also allows users to drag and drop the widgets around and to remove widgets that aren’t of interest, then to save or revert customizations from the dropdown menu.

Puppet directory environment support

Puppet 3.6’s directory environments feature allows simple and reliable configuration of environments under /etc/puppet/environments, a layout that Foreman installer users will be familiar with.

From Foreman 1.6, the installer configures the same layout using directory environments and the Smart Proxy is able to import Puppet modules laid out in this way (also available in 1.5.2).

Deprecation warnings

Last release for Debian 6.X (Squeeze)

Due to Squeeze’s advancing age, troubles with building packages, and the small number of downloads from deb.theforeman.org, the decision has been taken that 1.6 will be the last major release for Debian Squeeze. Minor releases of the 1.6 series will continue to be built for Squeeze, but users are encouraged to upgrade.

The prior debate over this can be viewed on the Google Groups mailing list.

Ruby 1.8.7 support in Foreman core

The core Foreman application will likely drop support for running under Ruby 1.8.7 in the next major release or two (mailing list, #4656). Please note that this does not affect the Smart Proxy, installer or Hammer CLI.

This may affect users running Foreman from source, who are recommended to seek a newer Ruby interpreter (1.9.3 or 2.0.0), either from packages (SCLs, PPAs etc) or a tool such as RVM.

EL users are unaffected due to Software Collections providing newer versions, and Debian 7 (Wheezy), Ubuntu 14.04 (Trusty) or Fedora 19 users are unaffected as Ruby 1.9.3 is used. Debian 6 (Squeeze) users are referred to the previous notice, and support for Ubuntu 12.04 is aimed to continue via #7227.

LDAP authentication with $login

When authenticating users with LDAP, Foreman can use the user’s own login and password to bind to the LDAP server to retrieve information. Foreman 1.6 introduces support for mapping LDAP groups to Foreman user groups, and so a dedicated service account is now recommended to use this new feature.

If the account listed in the LDAP server config (in Adminster > LDAP authentication) uses $login in the username, this should be changed to a dedicated account with bind, read and search permissions in the directory. Future versions of Foreman may remove support for $login.

Release notes for 1.6.3

Foreman 1.6.3 is a bug fix release for all components, and should be the last release in the 1.6 series.

Installer

  • Fix API validation failure with new apipie-bindings on EL7 (#8308)

Proxy and Services

  • Allow STDOUT as a log_file destination (#8006)
  • Fix API response when BMC shutdown is abrupt (#8320)

Security

  • Fix SELinux error when starting VM console (#7719)
  • Fix SELinux error when using LDAP authentication on EL7 (#7932)

Various fixes and features

  • Fix error when using both bootdisk and salt plugins (#8009)

A full list of changes in 1.6.3 is available via Redmine

Release notes for 1.6.2

Foreman 1.6.2 is a security fix release, only covering foreman-proxy and foreman-installer. The Foreman application and SELinux policy components will remain at version 1.6.1.

We strongly recommend that users update to Foreman 1.6.2 as soon as possible due to the security issue that has been fixed in this version. See the Security advisories page for more information, including mitigations if an upgrade isn’t immediately possible.

It’s recommended that the trusted_hosts setting is used in /etc/foreman-proxy/settings.yml on all smart proxies to list the Foreman servers that should be using the proxy, rather than permitting any host with a valid certificate. See the Smart Proxy Settings section for more information.

Installer

  • Set trusted_hosts smart proxy setting to FQDN by default

Proxy and Services

A full list of changes in 1.6.2 is available via Redmine

Release notes for 1.6.1

Foreman 1.6.1 is a security and bug fix release. The installer component will remain at version 1.6.0.

We recommend that users update to Foreman 1.6.1 as soon as possible due to the minor security issues that have been fixed in this version. See the Security advisories page for more information.

API

  • Add image user data flag to API response (#4111)
  • Add set_console_password flag to compute resource API (#5896)
  • Fix Puppet class import performance with a single environment (#6856)
  • Fix list of all API endpoints on root (#7054)
  • Fix marking of top level resource hash as optional (#7261)
  • Fix missing host attribute in LDAP auth sources (#7409)
  • Fix listing of facts when host has none (#7257)
  • Fix role render error with oj 2.10.3 (#7818)

Authentication and Authorization

  • Fix errors in some SSO methods that didn’t specify logout URLs (#7738)

Proxy and Services

  • Fix 500 error when requests were halted (#7749)
  • Fix error when the libvirt/virsh DNS provider encountered an error (#7297)
  • Fix errors when proxy plugins specified dependencies (#7596)

Internationalization

  • Fix translation when deleting host groups with children (#7436)

Security

  • Prevent XSS in provisioning template preview mode (CVE-2014-3653, #7483)
  • Prevent CSRF vulnerability on user logout link (CVE-2014-3590, #6999)
  • Fix upgrade of SELinux policy (#7388)
  • SELinux: permit websockify (consoles) to read /etc/pki certificates (#7729)
  • SELinux: permit connections to OpenStack port 5000 (#7346)

Web Interface

  • Fix incorrect counters between resources across web interface (#5692)
  • Add “fix_cached_counters” rake task to recalculate existing counter values (#7247)
  • Truncate long names in resource listings (#6713)
  • Fix display of original hostname when cloning a host (#7620)
  • Fix filtering of Puppet certificates in non-English locales (#3105)
  • Fix listing of organizations/locations in search autocomplete (#6763)
  • Fix HTML shown in error when deleting multiple hosts (#6903)
  • Fix stray tooltip in network/storage sections of compute resource forms (#7639)

Various fixes and features

  • Fix PGError when template audit comment exceeds 255 characters
  • Fix validation error with config groups when a host and host group shared IDs (#7329)

A full list of changes in 1.6.1 is available via Redmine

Release notes for 1.6.0

API

  • APIv2 is stable and recommended instead of v1
    • Foreman 1.6 keeps v1 as the default and the next version will change the default to v2. Users are strongly recommended to use versioned access to the API, either with /api/v2/ or headers (see Section 5.1.6).
    • API v1 will be deprecated and removed in a later version of Foreman.
    • Non-JSON requests will be refused in APIv2 to match docs (#6446)
  • Add API for host/compute resource association and disassociation (#4155)
  • Add API for external user groups (#5734)
  • Add API for showing disk uage of a VMware storage domain (#6608)
  • Add APIs for showing VMware folders and resource pools (#6756)
  • Improved permission and filter related responses under APIv2 (#6532)
  • Remove root node in some APIv2 JSON responses (#6248)
  • Add search parameter to template kinds API (#6794)
  • Add search and order parameters to parameters API (#6768)
  • Fix parsing of non-string values when updating settings (#6285)
  • Fix missing API documentation for org/location routes (#7028)
  • Fix output of roles and permissions API (#5945)
  • Fix list of APIv2 routes on /api/v2 (#6844)
  • Fix error when using compute_resource_name in host updates (#5679)
  • Fix org/location creation when only a name is given (#6786)
  • Fix org/location host attributes in API documentation (#6236)
  • Fix setting parameter override flag when adding override_values (#6161)
  • Fix handling of boolean value for host overwrite parameter (#6998)
  • Fix need for some root node wrapped parameters in users, compute resources and host updates (#5178)
  • Fix API examples that show error messages instead of valid responses (#6753, #6749)
  • Fix description of Puppet class import API (#6929)
  • Refactor role filters API internals (#6825)

Authentication and Authorization

  • Users can be linked to user groups stored in external auth sources with external user groups (#5241)
    • Support population of user group membership from LDAP (#813)
    • Support population of user groups from REMOTE_USER authentication (#3892)
  • ‘admin’ user can be replaced by another admin-enabled user (#3272)
  • User attributes and groups updated from LDAP/external sources on login (#5242)
  • Remove unlimited “view_hosts” permission from Anonymous role (#6361)
  • permissions:reset rake task now accepts a PASSWORD parameter (#6586)
  • Add utility method for plugins to check permission (#5221)
  • Allow authorization of menu items for plugins by specific URL (#5537)

CLI

Hammer CLI was updated to 0.1.3.

hammer-cli
  • Fixed detection of list type options (#7144)
  • Key-value normalizer accepts arrays (#7133)
  • Make the zanata settings consistent (#7111)
  • Adding system locale domain (#7083)
  • Allow override of request options, e.g. :response => :raw
  • Lazy loaded subcommands (#6761)
  • I18n - fixed error message + docs
  • I18n - fix apipie warning string to be properly extracted
  • I18n - add mark_translated to highlight extracted strings
  • I18n - add en_GB locale
  • I18n - extracting new, pulling from tx
  • Project-Id-Version is fixed after tx pull
  • Restrict ci_reporter gem to less than 2.0.0 to fix CI (#6779)
  • Fixed dependency on simplecov
  • Parameters are not wrapped (#6343)
  • Rest-client > 1.7 does not support ruby 1.8 (#6534)
  • Exit cleanly when EOF/ctrl+d given in shell (#6148)
  • Fix incorrect –server help text (#6219)
  • Fixed wrong config file path in installation docs
  • Empty list in csv adapter does not work (#6238)
  • Resource name mapping (#6092)
  • Tests for EnumList normalizer, fixed missing quotes in description
  • ListEnum normalizer
  • Add –server cli option (#6219)
  • CSV handles collection or container (#5111)
  • build_options configurable with block (#5747)
  • Add pkg:generate_source task to generate gem (#5793)
hammer-cli-foreman
  • Update foreman.yml
  • Update the zanata.xml file to push to de-DE and es-ES (#7112)
  • Adding system locale domain (#7083)
  • Name options for puppet proxies in hostgroup (#7085)
  • I18n - extracting new, pulling from tx
  • Docs for name->id resolution
  • Update with installation details and IRC channel
  • Lazy loaded subcommands (#6761)
  • I18n - fix some broken subcommand description extractions
  • I18n - fix strings to be properly extracted without interpolation
  • I18n - add en_GB locale
  • I18n - extracting new, pulling from tx
  • Initial update of translations, fixed Makefile
  • Fixed pagination (#6766)
  • Restrict ci_reporter gem to less than 2.0.0 to fix CI (#6779)
  • Add proxy refresh-features command (#3387)
  • Fixed simplecov dependences
  • Params from searchables are not wrapped (#6343)
  • rest-client > 1.7 does not support ruby 1.8 (#6534)
  • Tests updated to use apidoc export for v1.6 (#2922)
  • Commands for managing roles, filters, permissions and usergroups (#2922, #4004)
  • Obey refresh_cache default of false (#6478)
  • Creating a more generic hook for search_options (#6203)
  • Permit only –hostgroup when creating host (#6335)
  • Better option descriptions (#6093)
  • Mapping resource names in options (#6092)
  • Add –server cli option (#6219)
  • Fix for wrong parameters in proxy import (#6090)
  • Resolving ids in foreman base command (#6090)
  • Documentation for fine grained control over name expansion (#5747)
  • Fine grained control over name expansion (#5747)
  • Scoped options were not cleaning original options (#5873)
  • List actions don’t resolve ids for optional parameters (#5873)
  • Help for associating commands is too generic (#3512)
  • Add pkg:generate_source task to generate gem (#5793)

Compute resources and Hosts creation

  • Support AltLinux operating system (#3377)
  • oVirt VMs can be created with preallocated disks (#5197)
  • Add hardware version field to VMware host creation (#5760)
  • Add websockets_* settings to enable browser encrpytion of consoles (#3601)
  • Support 64-bit MAC addresses (#5915)
  • Add ability to turn off IP address auto-suggestion in subnet (#6529)
  • Add eager zeroing option for vSphere volumes (#5240)
  • Validate installation media is present for PXE installation (#6229)
  • Kickstart templates now enable iptables, auditd etc by default (#5895)
  • Validate length of root passwords set through host group (#6067)
  • Validate org/location when creating hosts (#6430)
  • Fix display of Fog-related errors during VM creation (#6099)
  • Fix error updating oVirt VMs when marking build as complete, preventing loops (#4375)
  • Fix rename of host when certname is set by clearing the stored value (#6566)
  • Fix provisioning via template onto oVirt 3.3 (#6495)
  • Fix error when provisioning without a quota onto oVirt (#6816)
  • Fix misleading message during background VM deletion (#5969)
  • Disable provisioning method radio boxes after host provisioning (#6228)
  • Fix recommended oVirt port as default HTTPS now used (#5965)

Proxy and Services

  • Proxy moved to a modular architecture enabling plugins (#4866)
  • Serve requests for /dhcp etc without trailing slash (#6661)
  • Support 64-bit MAC addresses (#5915)
  • Add foreman-prepare-realm script to set up FreeIPA realm user (#6542)
  • Fix simultaneous TFTP boot file downloads with locking (#6289)
  • Fix virsh provider support for CIDR prefixes as well as netmasks (#6085)
  • Fix command exit code handling under Ruby 1.9+ (#6585)
  • Fix conflict (409) error on identical DHCP record creation (#6745)
  • Fix exit code check when running Puppet commands (#6700)
  • Refactor dhcp_subnets code between ISC and Native MS DHCP providers (#6743)
  • Refactor nested and copying of arrays in ISC DHCP config parser (#6744)
  • Refactor use of Enumerable#find (#6583)
  • Refactor use of Kernel#open (#6584)
  • Refactor ForemanRequest for more general use by plugins (#6522)
  • Add test suite for DHCP API (#6742)
  • Fix tests for Proxy::Puppet::Runner (#6700)

Installer and packaging

  • Support installation on EL7 (#4447)
    • Packages built for EL7 (#4451, #4452)
    • EL7 updates to the installer (#4454)
    • EL7 updates to spec files (#4453)
  • Add support to configure Foreman authentication against FreeIPA (#6445)
  • Deploy Puppet directory environments on Puppet 3.6 or higher (#4700)
  • Initial admin user account has random password, can be overridden with parameters (#3272)
  • Refresh proxy features in Foreman when settings change (#3185)
  • Use apipie-bindings for foreman_smartproxy registration (#5395)
  • Fix SELinux labelling of node.rb by depending on foreman-selinux (#5924)
  • Fix use of VLAN and alias interfaces for DHCP and DNS configuration (#6751)
  • Fix configuration of Puppet master when upper case hostname used (#6352)
  • Fix loading of jsonp under bundler_ext (#2972)
  • RPM spec files moved to foreman-packaging repository (#5987)

Installer modules have been updated, see their respective changelogs for more detailed notes:

Internationalization

  • Add Portuguese (Brazilian) locale support
  • Fix untranslated column name on reports list (#3285)
  • Fix untranslated strings on smart class parameter/variable page (#3300)
  • Fix untranslated confirmation string when deleting architectures (#3303)
  • Fix untranslated string on IP suggestion link (#5442)

Puppet and Puppet integration

  • Fix creation of smart variable with the same name as a smart class parameter (#6633)
  • Fix removal of smart class parameter with long name (#2940)

Security

  • Add SELinux policy for Katello plugin (#5930)
  • Add SELinux policy to permit access to smart proxy on port 9090 (#5827)
  • Permit access to SSL certificates for websockify and consoles (#6961)
  • Permit creation of Rails log files (#7036)
  • Update relabel paths for EL7 (#7034)
  • Fix AVCs affecting Passenger for Puppet and Foreman under EL7 (#6013, #6014)
  • Fix parsing of CNs via separator characters from SSL DNs (#6205)

Web Interface

  • Add customizable dashboard which can be extended by plugins (#5345)
  • Show required fields with asterisk on all forms (#6400)
  • Focus name fields automatically when creating new resources (#6497)
  • Use consistent icon set for operating systems (#6487)
  • Improve two pane loading speed by removing page layout (#6857)
  • Fix display of parameter validation errors (#6693)
  • Fix capitalization of text during orchestration (#5520)
  • Fix styling of combo boxes in multi-select windows (#7082)
  • Fix stylign of combo box in report view (#7157)
  • Fix error when idle_timeout set to large number (#6537)
  • Fix poor error message when deleting current user (#6650)
  • Fix layout of buttons when editing orgs/locations (#6582)
  • Fix highlight of navigation tabs from plugin pages (#6057)
  • Make copyright section of About page modifiable by plugins (#6121)
  • Fix hidden buttons when switching tabs on compute profile form (#5939)
  • Fix org/location menu to be easier to navigate with the mouse (#5832)
  • Fix tooltip display for resources inherited from parent orgs/locations (#5140)
  • Fix display of tooltips above charts (#6982)
  • Fix inefficient SQL query for recent reports on dashboard (#7009)
  • Reduce server load during autocompletion with a delay (#7174)
  • Hide parent selection on host group/org/location form if not applicable (#5809)

Various fixes and features

  • Enable deletion of installation media associated to hosts or host groups (#3664)
  • Automatically add current user to org/location on creation (#5854)
  • Add “parent_hostgroup” search field to find hosts/groups under a given host group (#6116)
  • Add ability to clone provisioning templates (#1646)
  • Add ability to lock templates to restrict editing/deletion (#3103)
  • Enable plugins to filter logged request parameters (#6441)
  • Enable plugins to hook database seed ordering (#6308)
  • Enable plugins to extend auto-completion in filter create/edit (#5753)
  • Enable plugins to extend test helper (#6620)
  • Enable plugins to disable API debug logging (#7191)
  • Add ‘log’ rake task to get debug logging from other rake tasks (#6852)
  • Add setup of initial org/location when seeding the database (#5029)
  • Permit blank values for global/host etc parameters (#215)
  • Add @provisioning_type variable to templates to identify host group provisioning (#6861)
  • Add ident helper to templates to help format YAML in cloud-init templates (#6618)
  • Permit any format for role names (#4350)
  • Refactor smart proxy list code for plugins (#7121)
  • Fix use of regexp match in safemode (#6496)
  • Fix safemode access to additional host group attributes (#6860)
  • Remove default “x86_64” text when creating an architecture (#6506)
  • Fix partition table creation with name consisting of a single space (#5923)
  • Fix audit error when OS is created with long name (#6636)
  • Fix DB errors when entering data longer than database fields (#6694)
  • Fix acceptance of negative numbers in OS version fields (#6657)
  • Fix background PostgreSQL error when deleting user with associated roles (#4641)
  • Fix inclusion of rotated log files in foreman-debug (#6969)
  • Fix inclusion of split smart proxy configs in foreman-debug (#7079)
  • Fix duplicate error message when no provisioning template name entered (#6888)
  • Fix missing checks for presence of various attributes (#6432)
  • Fix and simplify eval calls (#6498)
  • Fix singularization of host class names (#6267)
  • Fix warning about duplicate “roots” scope (#4564)
  • Fix noisy seeds output during tests (#6528)
  • Fix deletion of test.log under spork (#6112)

A full list of changes in 1.6.0 is available via Redmine

Contributors

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

Aaron Stone, Adam Price, Adam Ruzicka, Alyssa Hardy, Amos Benari, Anthony Somerset, Arnold Bechtoldt, Boaz Shuster, Brad Buckingham, Bryan Kearney, Christine Fouant, Claer, cristi1979, Daniel Lobato García, David Davis, David Swift, Dmitri Dolguikh, Dominic Cleal, Dustin Tsang, Eric D. Helms, Especialista em Automatizaçao, Ewoud Kohl van Wijngaarden, Félix Barbeira, Flamarion Jorge Flamarion, Florentin Raud, francis, Fredrik Wendt, Gael Chamoulaud, Graeme Gillies, Greg Petras, Greg Sutcliffe, Guido Günther, Hnk Reno, Ivan Nečas, Jan Pazdziora, Jason Montleon, Jimmi Dyson, johnny.westerlund, Joseph Mitchell Magen, Joshua Hoblitt, Julien Pivotto, Justin Sherrill, Kick-Buttowski, Kot, Leon Strong, luizvasconcelos, Lukáš Zapletal, Marek Hulán, Maria Nita, Martin Bačovský, Martin Ducar, Martin Matuska, Martin Milata, Mattias Giese, Michael Moll, Mickaël Canévet, Mike Burns, Nacho Barrientos, nefeli, Neil Miao, Nick, Ohad Levy, Ori Rabin, Paul Puschmann, Petr Chalupa, Pierre-Emmanuel Dutang, red-tux, Romain Vrignaud, sacharv, Scott Seago, Serge Logvinov, Sergio Ocón, sidkhemka, simon11, Spencer, starless72, Stephen Benjamin, Thomas Weißschuh, Tomas Strachota, Tomer Brisker, Tom McKay, Tomoyuki KATO, Trey Dockendorf, Ulrich Habel, Vincent Kramar, Walden Raines, Zdenek Janda, Zordrak.

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

Supported platforms

  • CentOS or Scientific Linux 6 or 7
  • Debian 6 (Squeeze) or 7 (Wheezy)
  • Fedora 19
  • Red Hat Enterprise Linux 6 or 7
  • Ubuntu 12.04 (Precise) or 14.04 (Trusty)

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

2.1 Installation

The Foreman installer uses Puppet to install Foreman. This guide assumes that you have a newly installed operating system, on which the installer will setup Foreman, a Puppet master with Passenger and the Smart Proxy by default.

Select operating system

To provide specific installation instructions, please select your operating system:

Repositories

No operating system selected.

First, enable the RHEL Optional and RHSCL repos:

yum-config-manager --enable rhel-6-server-optional-rpms rhel-server-rhscl-6-rpms

Check the repositories are enabled with yum repolist after running the above command, as it can silently fail when subscription does not provide it. More information about accessing RH Software Collections (RHSCL) is available from the Customer Portal.

If you're using RH Satellite 5, you should instead sync and enable the channels there.

First, enable the RHEL Optional and RHSCL repos:

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

Check the repositories are enabled with yum repolist after running the above command, as it can silently fail when subscription does not provide it. More information about accessing RH Software Collections (RHSCL) is available from the Customer Portal.

If you're using RH Satellite 5, you should instead sync and enable the channels there.

Foreman 1.6 is the last release that will support Debian 6 (Squeeze). Please consider using Debian 7 (Wheezy) instead.

Backports are providing some required dependencies and a slightly more recent version of Puppet. To enable backports, run:

echo "deb http://http.debian.net/debian-backports squeeze-backports main" > /etc/apt/sources.list.d/backports.list
Foreman on Fedora 19 has some known issues, and we'd recommend using a different distro instead.

Using a recent version of Puppet is recommended, which is available from the Puppet Labs repository. You may skip this and use the older version from EPEL without a problem, however it has reduced community support.

rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-el-6.noarch.rpm

Enable the EPEL (Extra Packages for Enterprise Linux) and the Foreman repos:

rpm -ivh http://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
yum -y install http://yum.theforeman.org/releases/1.6/el6/x86_64/foreman-release.rpm

Using a recent version of Puppet is recommended, which is available from the Puppet Labs repository. You may skip this and use the older version from EPEL without a problem, however it has reduced community support.

rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-el-7.noarch.rpm

Enable the EPEL (Extra Packages for Enterprise Linux) and the Foreman repos:

rpm -ivh http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum -y install http://yum.theforeman.org/releases/1.6/el7/x86_64/foreman-release.rpm

Due to late-added support for EL7, configure the SCL repositories with:

yum -y --nogpgcheck install foreman-release-scl

You may optionally use the latest available version of Puppet from the Puppet Labs repositories, which is a bit newer than that provided by Fedora itself.

rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-fedora-19.noarch.rpm

Enable the Foreman repo:

yum -y install http://yum.theforeman.org/releases/1.6/f19/x86_64/foreman-release.rpm

Using a recent version of Puppet is recommended, which is available from the Puppet Labs repository. You may skip this and use the older version from Debian Backports without a problem, however it has reduced community support.

apt-get -y install ca-certificates
wget https://apt.puppetlabs.com/puppetlabs-release-squeeze.deb
dpkg -i puppetlabs-release-squeeze.deb

Enable the Foreman repo:

echo "deb http://deb.theforeman.org/ squeeze 1.6" > /etc/apt/sources.list.d/foreman.list
echo "deb http://deb.theforeman.org/ plugins 1.6" >> /etc/apt/sources.list.d/foreman.list
wget -q http://deb.theforeman.org/pubkey.gpg -O- | apt-key add -

Using a recent version of Puppet is recommended, which is available from the Puppet Labs repository. You may skip this and use the older version from Debian without a problem, however it has reduced community support.

apt-get -y install ca-certificates
wget https://apt.puppetlabs.com/puppetlabs-release-wheezy.deb
dpkg -i puppetlabs-release-wheezy.deb

Enable the Foreman repo:

echo "deb http://deb.theforeman.org/ wheezy 1.6" > /etc/apt/sources.list.d/foreman.list
echo "deb http://deb.theforeman.org/ plugins 1.6" >> /etc/apt/sources.list.d/foreman.list
wget -q http://deb.theforeman.org/pubkey.gpg -O- | apt-key add -

Using a recent version of Puppet is recommended, which is available from the Puppet Labs repository. You may skip this and use the older version from Ubuntu without a problem, however it has reduced community support.

apt-get -y install ca-certificates
wget https://apt.puppetlabs.com/puppetlabs-release-precise.deb
dpkg -i puppetlabs-release-precise.deb

Enable the Foreman repo:

echo "deb http://deb.theforeman.org/ precise 1.6" > /etc/apt/sources.list.d/foreman.list
echo "deb http://deb.theforeman.org/ plugins 1.6" >> /etc/apt/sources.list.d/foreman.list
wget -q http://deb.theforeman.org/pubkey.gpg -O- | apt-key add -

You may optionally use the latest available version of Puppet from the Puppet Labs repositories, which is a bit newer than that provided by Ubuntu itself.

apt-get -y install ca-certificates
wget https://apt.puppetlabs.com/puppetlabs-release-trusty.deb
dpkg -i puppetlabs-release-trusty.deb

Enable the Foreman repo:

echo "deb http://deb.theforeman.org/ trusty 1.6" > /etc/apt/sources.list.d/foreman.list
echo "deb http://deb.theforeman.org/ plugins 1.6" >> /etc/apt/sources.list.d/foreman.list
wget -q http://deb.theforeman.org/pubkey.gpg -O- | apt-key add -

Downloading the installer

No operating system selected.
yum -y install foreman-installer
apt-get update && apt-get -y install foreman-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
foreman-installer --foreman-configure-scl-repo=false

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

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 3+ 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. If you have Puppet 2.7.14 or higher, install the module automatically from Puppet Forge to our “production” environment (the default):

puppet module install -i /etc/puppet/environments/production/modules saz/ntp

On older versions, download the tar.gz and unpack to /etc/puppet/environments/production/modules/. Rename the directory to “ntp”, removing the author and version number.

In Foreman, go to Configure > Puppet 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 server_list parameter on the left hand side. Tick the Override checkbox so Foreman manages the “server_list” 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 server_list 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:

  • Red Hat Enterprise Linux 6 or 7
    • EPEL is required
    • Enable the Optional and RHSCL 1 repositories/channels:
      • yum-config-manager --enable rhel-6-server-optional-rpms rhel-server-rhscl-6-rpms
      • check the above repositories because the command can silently fail when subscription does not provide it: yum repolist
    • Apply all SELinux-related erratas.
  • CentOS or Scientific Linux 6
    • EPEL is required
    • Version 7 will be supported when SCL becomes available
  • Fedora 19
  • Debian 7 (Wheezy)
  • Debian 6 (Squeeze)
    • Ensure Puppet is updated from backports
  • Ubuntu 14.04 (Trusty)
  • Ubuntu 12.04 (Precise)

It is recommended to apply all OS updates if possible.

All platforms will require Puppet 2.7 or higher. Puppet 3.x is supported and may be installed from 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 derivatives (CentOS) 3+
  • Fedora
  • Ubuntu
  • Debian
  • Solaris 8, 10
  • OpenSUSE 11.4

3.1.2 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 and Facter that Foreman is compatible with are listed below.

Puppet version Foreman installer Smart proxy Report/fact processors External node classifier
0.25.x Not supported Untested Untested Supported *
2.6.0 - 2.6.5 Not supported Untested Untested Supported *
2.6.5+ Not supported Supported Supported Supported
2.7.x Supported Supported Supported Supported
3.0.x Limited support 1.1 or higher Supported Supported
3.1.x - 3.4.x 1.1 or higher 1.1 or higher Supported Supported
3.5.x 1.4.3 or higher 1.4.2 or higher Supported Supported
3.6.0+ 1.4.3 or higher 1.5.1 or higher Supported Supported

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

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

Facter compatibility

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

For Facter 2.x, both Foreman installer and Foreman 1.4.2 or higher are required.

Compatibility with structured facts in Facter 2.x is being introduced via #4528.

3.1.3 Firewall Configuration

Protect your Foreman environment by blocking all unnecessary and unused ports.

Port Protocol Required For
53 TCP & UDP DNS Server
67, 68 UDP DHCP Server
69 UDP * TFTP Server
80, 443 TCP * HTTP & HTTPS access to Foreman web UI - using Apache + Passenger
3000 TCP HTTP access to Foreman web UI - using standalone WEBrick service
3306 TCP Separate MySQL database
5910 - 5930 TCP Server VNC Consoles
5432 TCP Separate PostgreSQL database
8140 TCP * Puppet Master
8443 TCP Smart Proxy, open only to Foreman

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

3.2.1 Installation

The Foreman installer uses Puppet to install Foreman. This guide assumes that you have a newly installed operating system, on which the installer will setup Foreman, a puppet master with Passenger and the Smart Proxy by default.

Downloading the installer

For Red Hat variants, run this (replace ‘el6’ with ‘el7’ if on RHEL 7, or ‘f19’ on Fedora 19):

yum -y install http://yum.theforeman.org/releases/1.6/el6/x86_64/foreman-release.rpm
yum -y install foreman-installer

For Debian variants, run this (replace ‘wheezy’ with ‘trusty’ if on Ubuntu 14.04, ‘precise’ if on Ubuntu 12.04, or ‘squeeze’ for Debian 6):

echo "deb http://deb.theforeman.org/ wheezy 1.6" > /etc/apt/sources.list.d/foreman.list
echo "deb http://deb.theforeman.org/ plugins 1.6" >> /etc/apt/sources.list.d/foreman.list
wget -q http://deb.theforeman.org/pubkey.gpg -O- | apt-key add -
apt-get update && apt-get install foreman-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 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/foreman-installer.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.

More information about compute resources can be found in the Compute Resources section and plugins in the Plugins section.

Option Description
--[no-]enable-foreman Enable 'foreman' puppet module
--[no-]enable-foreman-compute-ec2 Enable 'foreman_compute_ec2' puppet module
--[no-]enable-foreman-compute-gce Enable 'foreman_compute_gce' puppet module
--[no-]enable-foreman-compute-libvirt Enable 'foreman_compute_libvirt' puppet module
--[no-]enable-foreman-compute-openstack Enable 'foreman_compute_openstack' puppet module
--[no-]enable-foreman-compute-ovirt Enable 'foreman_compute_ovirt' puppet module
--[no-]enable-foreman-compute-rackspace Enable 'foreman_compute_rackspace' puppet module
--[no-]enable-foreman-compute-vmware Enable 'foreman_compute_vmware' puppet module
--[no-]enable-foreman-plugin-bootdisk Enable 'foreman_plugin_bootdisk' puppet module (foreman_bootdisk)
--[no-]enable-foreman-plugin-chef Enable 'foreman_plugin_chef' puppet module (foreman_chef)
--[no-]enable-foreman-plugin-default-hostgroup Enable 'foreman_plugin_default_hostgroup' puppet module (foreman_default_hostgroup)
--[no-]enable-foreman-plugin-discovery Enable 'foreman_plugin_discovery' puppet module (foreman_discovery)
--[no-]enable-foreman-plugin-hooks Enable 'foreman_plugin_hooks' puppet module (foreman_hooks)
--[no-]enable-foreman-plugin-puppetdb Enable 'foreman_plugin_puppetdb' puppet module (puppetdb_foreman)
--[no-]enable-foreman-plugin-setup Enable 'foreman_plugin_setup' puppet module (foreman_setup)
--[no-]enable-foreman-plugin-tasks Enable 'foreman_plugin_tasks' puppet module (foreman-tasks)
--[no-]enable-foreman-plugin-templates Enable 'foreman_plugin_templates' puppet module (foreman_templates)
--[no-]enable-foreman-proxy Enable 'foreman_proxy' puppet module
--[no-]enable-foreman-proxy-plugin-pulp Enable 'foreman_proxy_plugin_pulp' puppet module (smart-proxy-pulp)
--[no-]enable-puppet Enable 'puppet' puppet module

Available options

Option Description
--foreman-admin-email E-mail address of the initial admin user
--foreman-admin-first-name First name of the initial admin user
--foreman-admin-last-name Last name of the initial admin user
--foreman-admin-password Password of the initial admin user, default is randomly generated
--foreman-admin-username Username for the initial admin user
--foreman-app-root Name of foreman root directory
--foreman-authentication Enable user authentication. Initial credentials are set using admin_username and admin_password.
--foreman-configure-epel-repo If disabled the EPEL repo will not be configured on RedHat family systems.
--foreman-configure-ipa-repo Enable custom yum repo with packages needed for external authentication via IPA, this may be needed on RHEL 6.5 and older.
--foreman-configure-scl-repo If disabled the SCL repo will not be configured on Red Hat clone systems. (Currently only installs repos for CentOS and Scientific)
--foreman-custom-repo No need to change anything here by default if set to true, no repo will be added by this module, letting you to set it to some custom location.
--foreman-db-adapter Database 'production' adapter
--foreman-db-database Database 'production' database (e.g. foreman)
--foreman-db-host Database 'production' host
--foreman-db-manage if enabled, will install and configure the database server on this host
--foreman-db-password Database 'production' password (default is random)
--foreman-db-port Database 'production' port
--foreman-db-sslmode Database 'production' ssl mode
--foreman-db-type Database 'production' type (valid types: mysql/postgresql/sqlite)
--foreman-db-username Database 'production' user (e.g. foreman)
--foreman-environment Rails environment of foreman
--foreman-foreman-url URL on which foreman is going to run
--foreman-gpgcheck turn on/off gpg check in repo files (effective only on RedHat family systems)
--foreman-group Primary group for the Foreman user
--foreman-http-keytab Path to keytab to be used for Kerberos authentication on the WebUI
--foreman-initial-location Name of an initial location
--foreman-initial-organization Name of an initial organization
--foreman-ipa-authentication Enable configuration for external authentication via IPA
--foreman-ipa-manage-sssd If ipa_authentication is true, should the installer manage SSSD? You can disable it if you use another module for SSSD configuration
--foreman-locations-enabled Enable locations?
--foreman-oauth-active Enable OAuth authentication for REST API
--foreman-oauth-consumer-key OAuth consumer key
--foreman-oauth-consumer-secret OAuth consumer secret
--foreman-oauth-map-users Should foreman use the foreman_user header to identify API user?
--foreman-organizations-enabled Enable organizations?
--foreman-pam-service PAM service used for host-based access control in IPA
--foreman-passenger Configure foreman via apache and passenger
--foreman-passenger-interface Defines which network interface passenger should listen on, undef means all interfaces
--foreman-passenger-min-instances Minimum passenger worker instances to keep when application is idle.
--foreman-passenger-prestart Pre-start the first passenger worker instance process during httpd start.
--foreman-passenger-scl Software collection name (on RHEL currently 'ruby193', undef on others)
--foreman-passenger-start-timeout Amount of seconds to wait for Ruby application boot.
--foreman-puppet-home Puppet home directory
--foreman-repo This can be stable, rc, or nightly
--foreman-selinux when undef, foreman-selinux will be installed if SELinux is enabled setting to false/true will override this check (e.g. set to false on 1.1)
--foreman-server-ssl-ca Defines Apache mod_ssl SSLCACertificateFile setting in Foreman vhost conf file.
--foreman-server-ssl-cert Defines Apache mod_ssl SSLCertificateFile setting in Foreman vhost conf file.
--foreman-server-ssl-chain Defines Apache mod_ssl SSLCertificateChainFile setting in Foreman vhost conf file.
--foreman-server-ssl-key Defines Apache mod_ssl SSLCertificateKeyFile setting in Foreman vhost conf file.
--foreman-ssl Enable and set require_ssl in Foreman settings (note: requires passenger, SSL does not apply to kickstarts)
--foreman-unattended Should foreman manage host provisioning as well
--foreman-use-vhost Enclose apache configuration in ...
--foreman-user User under which foreman will run
--foreman-user-groups Additional groups for the Foreman user
--foreman-version foreman package version, it's passed to ensure parameter of package resource can be set to specific version number, 'latest', 'present' etc.
--foreman-websockets-encrypt Whether to encrypt websocket connections
--foreman-websockets-ssl-cert SSL certificate file to use when encrypting websocket connections
--foreman-websockets-ssl-key SSL key file to use when encrypting websocket connections
--foreman-cli-foreman-url URL on which Foreman runs
--foreman-cli-manage-root-config Whether to manage /root/.hammer configuration.
--foreman-cli-password Password for authentication
--foreman-cli-refresh-cache Check API documentation cache status on each request
--foreman-cli-request-timeout API request timeout, set -1 for infinity
--foreman-cli-username Username for authentication
--foreman-plugin-discovery-initrd name of initrd image file
--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-kernel name of kernel file
--foreman-plugin-discovery-source mirror url from which the image files should be obtained, you can use http(s):// or file://
--foreman-plugin-discovery-version version string of discovery image, in form of x.y.z-r
--foreman-proxy-autosign-location Path to autosign configuration file
--foreman-proxy-bmc Use BMC
--foreman-proxy-bmc-default-provider BMC default provider.
--foreman-proxy-custom-repo No need to change anything here by default if set to true, no repo will be added by this module, letting you to set it to some custom location.
--foreman-proxy-customrun-args Puppet customrun command arguments
--foreman-proxy-customrun-cmd Puppet customrun command
--foreman-proxy-dhcp Use DHCP
--foreman-proxy-dhcp-config DHCP config file path
--foreman-proxy-dhcp-gateway DHCP pool gateway
--foreman-proxy-dhcp-interface DHCP listen interface
--foreman-proxy-dhcp-key-name DHCP key name
--foreman-proxy-dhcp-key-secret DHCP password
--foreman-proxy-dhcp-leases DHCP leases file
--foreman-proxy-dhcp-managed DHCP is managed by Foreman proxy
--foreman-proxy-dhcp-nameservers DHCP nameservers
--foreman-proxy-dhcp-range Space-separated DHCP pool range
--foreman-proxy-dhcp-vendor DHCP vendor
--foreman-proxy-dir Foreman proxy install directory
--foreman-proxy-dns Use DNS
--foreman-proxy-dns-forwarders DNS forwarders
--foreman-proxy-dns-interface DNS interface
--foreman-proxy-dns-managed DNS is managed by Foreman proxy
--foreman-proxy-dns-provider DNS provider
--foreman-proxy-dns-reverse DNS reverse zone name
--foreman-proxy-dns-server Address of DNS server to manage
--foreman-proxy-dns-tsig-keytab Kerberos keytab for DNS updates using GSS-TSIG authentication
--foreman-proxy-dns-tsig-principal Kerberos principal for DNS updates using GSS-TSIG authentication
--foreman-proxy-dns-ttl DNS default TTL override
--foreman-proxy-dns-zone DNS zone name
--foreman-proxy-foreman-base-url Base Foreman URL used for REST interaction
--foreman-proxy-freeipa-remove-dns Remove DNS entries from FreeIPA when deleting hosts from realm
--foreman-proxy-gpgcheck Turn on/off gpg check in repo files (effective only on RedHat family systems)
--foreman-proxy-keyfile DNS server keyfile path
--foreman-proxy-log Foreman proxy log file
--foreman-proxy-manage-sudoersd Whether to manage File['/etc/sudoers.d'] or not. When reusing this module, this may be disabled to let a dedicated sudo module manage it instead.
--foreman-proxy-oauth-consumer-key OAuth key to be used for REST interaction
--foreman-proxy-oauth-consumer-secret OAuth secret to be used for REST interaction
--foreman-proxy-oauth-effective-user User to be used for REST interaction
--foreman-proxy-port Port on which will foreman proxy listen
--foreman-proxy-puppet-group Groups of Foreman proxy user
--foreman-proxy-puppet-ssl-ca SSL CA used to verify connections when accessing the Puppet master API
--foreman-proxy-puppet-ssl-cert SSL certificate used when accessing the Puppet master API
--foreman-proxy-puppet-ssl-key SSL private key used when accessing the Puppet master API
--foreman-proxy-puppet-url URL of the Puppet master itself for API requests
--foreman-proxy-puppet-use-environment-api Override use of Puppet's API to list environments. When unset, the proxy will try to determine this automatically.
--foreman-proxy-puppet-user Which user to invoke sudo as to run puppet commands
--foreman-proxy-puppetca Use Puppet CA
--foreman-proxy-puppetca-cmd Puppet CA command to be allowed in sudoers
--foreman-proxy-puppetdir Puppet var directory
--foreman-proxy-puppetrun Enable puppet run/kick management
--foreman-proxy-puppetrun-cmd Puppet run/kick command to be allowed in sudoers
--foreman-proxy-puppetrun-provider Set puppet_provider to handle puppet run/kick via mcollective
--foreman-proxy-puppetssh-command The command used by puppetrun_provider puppetssh
--foreman-proxy-puppetssh-keyfile The keyfile for puppetrun_provider puppetssh commands
--foreman-proxy-puppetssh-sudo Whether to use sudo before commands when using puppetrun_provider puppetssh
--foreman-proxy-puppetssh-user The user for puppetrun_provider puppetssh
--foreman-proxy-realm Use realm management
--foreman-proxy-realm-keytab Kerberos keytab path to authenticate realm updates
--foreman-proxy-realm-principal Kerberos principal for realm updates
--foreman-proxy-realm-provider Realm management provider
--foreman-proxy-register-in-foreman Register proxy back in Foreman
--foreman-proxy-registered-name Proxy name which is registered in Foreman
--foreman-proxy-registered-proxy-url Proxy URL which is registered in Foreman
--foreman-proxy-repo This can be stable, rc, or nightly
--foreman-proxy-ssl Enable SSL, ensure proxy is added with "https://" protocol if true
--foreman-proxy-ssl-ca If CA is specified, remote Foreman host will be verified
--foreman-proxy-ssl-cert Used to communicate to Foreman
--foreman-proxy-ssl-key Corresponding key to a certificate
--foreman-proxy-ssldir Puppet CA ssl directory
--foreman-proxy-tftp Use TFTP
--foreman-proxy-tftp-dirs Directories to be create in $tftp_root
--foreman-proxy-tftp-root TFTP root directory
--foreman-proxy-tftp-servername Defines the TFTP Servername to use, overrides the name in the subnet declaration
--foreman-proxy-tftp-syslinux-files Syslinux files to install on TFTP (copied from $tftp_syslinux_root)
--foreman-proxy-tftp-syslinux-root Directory that hold syslinux files
--foreman-proxy-trusted-hosts Only hosts listed will be permitted, empty array to disable authorization
--foreman-proxy-use-sudoersd Add a file to /etc/sudoers.d (true) or uses augeas (false)
--foreman-proxy-user User under which foreman proxy will run
--foreman-proxy-version foreman package version, it's passed to ensure parameter of package resource can be set to specific version number, 'latest', 'present' etc.
--foreman-proxy-virsh-network Network for virsh DNS/DHCP provider
--foreman-proxy-plugin-pulp-enabled enables/disables the plugin
--foreman-proxy-plugin-pulp-group group owner of the configuration file
--foreman-proxy-plugin-pulp-pulp-url pulp url to use
--puppet-agent Should a puppet agent be installed
--puppet-agent-noop Run the agent in noop mode.
--puppet-agent-template Use a custom template for the agent puppet configuration.
--puppet-allow-any-crl-auth Allow any authentication for the CRL. This is needed on the puppet CA to accept clients from a the puppet CA proxy.
--puppet-auth-template Use a custom template for the auth configuration.
--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-package Install a custom package to provide the puppet client
--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-dns-alt-names Use additional DNS names when generating a certificate. Defaults to an empty Array.
--puppet-group Override the name of the puppet group.
--puppet-hiera-config The hiera configuration file. Defaults to '$confdir/hiera.yaml'.
--puppet-listen Should the puppet agent listen for connections.
--puppet-main-template Use a custom template for the main puppet configuration.
--puppet-nsauth-template Use a custom template for the nsauth configuration.
--puppet-pluginsource URL to retrieve Puppet plugins from during pluginsync
--puppet-pluginsync Enable pluginsync.
--puppet-port Override the port of the master we connect to.
--puppet-puppetmaster Hostname of your puppetmaster (server directive in puppet.conf)
--puppet-runinterval Set up the interval (in seconds) to run the puppet agent.
--puppet-runmode Select the mode to setup the puppet agent. Can be either 'cron', 'service', or 'none'.
--puppet-server Should a puppet master be installed as well as the client
--puppet-server-app-root Directory where the application lives
--puppet-server-ca Provide puppet CA
--puppet-server-ca-proxy The actual server that handles puppet CA. Setting this to anything non-empty causes the apache vhost to set up a proxy for all certificates pointing to the value.
--puppet-server-certname The name to use when handling certificates.
--puppet-server-common-modules-path Common modules paths (only when $server_git_repo_path and $server_dynamic_environments are false)
--puppet-server-config-version How to determine the configuration version. When using git_repo, by default a git describe approach will be installed.
--puppet-server-dir Puppet configuration directory
--puppet-server-directory-environments Enable directory environments, defaulting to true with Puppet 3.6.0 or higher
--puppet-server-dynamic-environments 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-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-external-nodes External nodes classifier executable
--puppet-server-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-path Git repository path
--puppet-server-group Name of the puppetmaster group.
--puppet-server-httpd-service Apache/httpd service name to notify on configuration changes. Defaults to 'httpd' based on the default apache module included with foreman-installer.
--puppet-server-manifest-path Path to puppet site.pp manifest (only when $server_git_repo_path and $server_dynamic_environments are false)
--puppet-server-package Custom package name for puppet master
--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.
--puppet-server-passenger-max-pool The PassengerMaxPoolSize parameter. If your host is low on memory, it may be a good thing to lower this. Defaults to 12.
--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-puppet-home Puppet var directory
--puppet-server-report-api What version of report processor to deploy. Valid values are 'v2' for latest, and 'v1' for Foreman =< 1.2
--puppet-server-reports List of report types to include on the puppetmaster
--puppet-server-service-fallback 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-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-user Name of the puppetmaster user.
--puppet-server-vardir Puppet 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-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-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'.

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/foreman-installer.yaml. By default, the all-in-one setup will include Foreman, a puppetmaster, Puppet agent, and the Smart Proxy:

---
foreman:
  custom_repo: true
foreman_proxy:
  custom_repo: true
puppet:
  server: true

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

3.2.3 Installation Scenarios

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

Setting up Foreman with external Puppet masters

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

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

  1. Generate a new certificate following the steps in the SSL CA section and transfer it to the new Puppet master host
  2. 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:

# puppet cert generate new-puppetmaster.example.com
Notice: new-puppetmaster.example.com has a waiting certificate request
Notice: Signed certificate request for new-puppetmaster.example.com
Notice: Removing file Puppet::SSL::CertificateRequest new-puppetmaster.example.com at '/var/lib/puppet/ssl/ca/requests/new-puppetmaster.example.com.pem'
Notice: Removing file Puppet::SSL::CertificateRequest new-puppetmaster.example.com at '/var/lib/puppet/ssl/certificate_requests/new-puppetmaster.example.com.pem'

# ls /var/lib/puppet/ssl/*/new-puppetmaster.example.com.pem
/var/lib/puppet/ssl/certs/new-puppetmaster.example.com.pem
/var/lib/puppet/ssl/private_keys/new-puppetmaster.example.com.pem
/var/lib/puppet/ssl/public_keys/new-puppetmaster.example.com.pem

Transfer the following files to the same paths on the new host:

  • /var/lib/puppet/ssl/certs/ca.pem
  • /var/lib/puppet/ssl/certs/new-puppetmaster.example.com.pem
  • /var/lib/puppet/ssl/private_keys/new-puppetmaster.example.com.pem

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.

Command line arguments:

foreman-installer \
  --no-enable-foreman \
  --no-enable-foreman-cli \
  --no-enable-foreman-plugin-bootdisk \
  --no-enable-foreman-plugin-setup \
  --enable-puppet \
  --puppet-server-ca=false \
  --puppet-server-foreman-url=https://foreman.example.com \
  --enable-foreman-proxy \
  --foreman-proxy-puppetca=false \
  --foreman-proxy-tftp=false \
  --foreman-proxy-foreman-base-url=https://foreman.example.com \
  --foreman-proxy-trusted-hosts=foreman.example.com \
  --foreman-proxy-oauth-consumer-key=<key here> \
  --foreman-proxy-oauth-consumer-secret=<secret here>

Fill in the OAuth consumer key and secret values from your Foreman instance, retrieve them from Administer > Settings > Auth, 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.

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.

Command line arguments:

foreman-installer \
  --puppet-server=false \
  --foreman-proxy-puppetrun=false \
  --foreman-proxy-puppetca=false

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.

Command line arguments for a basic smart proxy installation:

foreman-installer \
  --no-enable-foreman \
  --no-enable-foreman-cli \
  --no-enable-foreman-plugin-bootdisk \
  --no-enable-foreman-plugin-setup \
  --no-enable-puppet \
  --enable-foreman-proxy \
  --foreman-proxy-tftp=false \
  --foreman-proxy-foreman-base-url=https://foreman.example.com \
  --foreman-proxy-trusted-hosts=foreman.example.com \
  --foreman-proxy-oauth-consumer-key=<key here> \
  --foreman-proxy-oauth-consumer-secret=<secret here>

Fill in the OAuth consumer key and secret values from your Foreman instance, retrieve them from Administer > Settings > Auth, 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:

foreman-installer \
  --no-enable-foreman \
  --no-enable-foreman-cli \
  --no-enable-foreman-plugin-bootdisk \
  --no-enable-foreman-plugin-setup \
  --no-enable-puppet \
  --enable-foreman-proxy \
  --foreman-proxy-tftp=false \
  --foreman-proxy-puppetca=false \
  --foreman-proxy-puppetrun=false \
  --foreman-proxy-dns=true \
  --foreman-proxy-dns-interface=eth0 \
  --foreman-proxy-dns-zone=example.com \
  --foreman-proxy-dns-reverse=0.0.10.in-addr.arpa \
  --foreman-proxy-dns-forwarders=8.8.8.8 \
  --foreman-proxy-dns-forwarders=8.8.4.4 \
  --foreman-proxy-foreman-base-url=https://foreman.example.com \
  --foreman-proxy-trusted-hosts=foreman.example.com \
  --foreman-proxy-oauth-consumer-key=<key here> \
  --foreman-proxy-oauth-consumer-secret=<secret here>

Ensure the dns-interface argument is updated with the correct network interface name for the DNS server to listen on.

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

foreman-installer \
  --no-enable-foreman \
  --no-enable-foreman-cli \
  --no-enable-foreman-plugin-bootdisk \
  --no-enable-foreman-plugin-setup \
  --no-enable-puppet \
  --enable-foreman-proxy \
  --foreman-proxy-puppetca=false \
  --foreman-proxy-puppetrun=false \
  --foreman-proxy-tftp=false \
  --foreman-proxy-dhcp=true \
  --foreman-proxy-dhcp-interface=eth0 \
  --foreman-proxy-dhcp-gateway=10.0.0.1 \
  --foreman-proxy-dhcp-range="10.0.0.50 10.0.0.200" \
  --foreman-proxy-dhcp-nameservers="10.0.1.2,10.0.1.3" \
  --foreman-proxy-foreman-base-url=https://foreman.example.com \
  --foreman-proxy-trusted-hosts=foreman.example.com \
  --foreman-proxy-oauth-consumer-key=<key here> \
  --foreman-proxy-oauth-consumer-secret=<secret here>

Also ensure here that the dhcp-interface argument is updated for the interface to run DHCP on.

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 19

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

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

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

All RHEL and derivatives require Red Hat Software Collections (RHSCL) 1 or rebuild, e.g. Software Collections for CentOS. RHSCL is available to RHEL customers as a separate repository or child channel. More information on Software Collections for CentOS is available here and for Scientific Linux it is available here.

Please note that SCL is not available at the time of writing for CentOS or Scientific Linux 7, so Foreman cannot yet be installed using packages on these operating systems.

To enable both optional and software collections on a RHEL 6 system using subscription-manager, run:

yum-config-manager --enable rhel-6-server-optional-rpms rhel-server-rhscl-6-rpms

Optionally, the Puppet Labs repository can be configured to obtain the latest version of Puppet available, instead of the version on EPEL. See the Puppet Labs Package Repositories documentation on how to configure these.

Available repositories

Three main repos are provided at http://yum.theforeman.org:

  • /releases/latest or /releases/VERSION (e.g. /releases/1.6) carries the stable releases and updates of Foreman and its dependencies.
  • /rc carries release candidates only in the few weeks prior to a release. Ensure after a release is made that you use the main releases repo instead.
  • /nightly carries the latest development builds and as such, may be unstable or occasionally broken.

Under each repo are directories for each distribution, then each architecture.

Release packages

To set up the repository, foreman-release packages are provided which add a repo definition to /etc/yum.repos.d. Install the appropriate release RPM from these lists:

yum localinstall http://yum.theforeman.org/releases/1.6/el6/x86_64/foreman-release.rpm
yum localinstall http://yum.theforeman.org/releases/1.6/el7/x86_64/foreman-release.rpm
yum localinstall http://yum.theforeman.org/releases/1.6/f19/x86_64/foreman-release.rpm

For release candidate or nightly RPMs, change the URL as appropriate based on the above list of available repositories.

Signing

Release and release candidate packages are signed by the “Foreman Automatic Signing Key (2014) packages@theforeman.org” (0x1AA043B8). Nightly packages are not signed.

A copy of the key is available from public keyservers or here.

Available packages

Install foreman and other foreman-* packages to add functionality:

foreman               Foreman server
foreman-proxy         Foreman Smart Proxy
foreman-compute       EC2, OpenStack and Rackspace provisioning support
foreman-libvirt       libvirt provisioning support
foreman-ovirt         oVirt/RHEV provisioning support
foreman-vmware        VMware provisioning support
foreman-cli           Foreman CLI utility
foreman-console       Console additions
foreman-selinux       SELinux targeted policy
foreman-mysql2        MySQL database support
foreman-postgresql    PostgreSQL database support
foreman-sqlite        SQLite database support

Setup

  1. Configure by editing /etc/foreman/settings.yaml and /etc/foreman/database.yml
  2. After changing the database, migrate it: sudo -u foreman /usr/share/foreman/extras/dbmigrate
  3. Start the foreman service or set up passenger: service foreman start

Upgrade

See upgrade instructions

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.

The current stack is “ruby193”, which provides Ruby 1.9.3 and Ruby on Rails 3.2. All packages will have a “ruby193-“ prefix, allowing them to be easily identified, and will install entirely underneath /opt/rh/ruby193.

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, ruby193-rake and ruby193-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 ruby193 'other command' can be used. It is also possible to run scl enable ruby193 bash to get a shell within the context of the SCL. Foreman rake tasks should be run with “foreman-rake”, which automates this process.

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
  • ruby193-rubygem-passenger
  • ruby193-rubygem-passenger-native
  • ruby193-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 (ruby193-rubygem-*) and one for the system Ruby (rubygem-*).

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

LoadModule passenger_module modules/mod_passenger.so
<IfModule mod_passenger.c>
   PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-4.0.5
   PassengerRuby /usr/bin/ruby
</IfModule>

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/ruby193-ruby

The full foreman.conf template from the installer is available here for comparison.

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:

# ps auxww | grep RackApp
foreman  16627  0.1 15.4 466980 157196 ?       Sl   07:35   0:09 Passenger RackApp: /usr/share/foreman
puppet   16697  0.8 11.3 253080 115720 ?       Sl   07:35   1:13 Passenger RackApp: /etc/puppet/rack
# lsof -p 16697 | grep libruby
ruby    16697 puppet  mem    REG              253,0   951224  272286 /usr/lib64/libruby.so.1.8.7
# lsof -p 16627 | grep libruby
ruby    16627 foreman  mem    REG              253,0  2041096  171190 /opt/rh/ruby193/root/usr/lib64/libruby.so.1.9.1

3.3.3 Debian Packages

The Foreman packages should work on the following Debian-based Linux distributions:

Distributions

  • Debian Linux 7.0 (Wheezy)
  • Debian Linux 6.0 (Squeeze)
  • Ubuntu Linux 14.04 LTS (Trusty Tahr)
  • Ubuntu Linux 12.04 LTS (Precise Pangolin)

If you encounter any errors during the installation, please file a bug report!

Apt Configuration

Add one of the following lines to your /etc/apt/sources.list (alternatively in a separate file in /etc/apt/sources.list.d/foreman.list):

# Stable packages

# Debian Wheezy
deb http://deb.theforeman.org/ wheezy 1.6
# Debian Squeeze
deb http://deb.theforeman.org/ squeeze 1.6
# Ubuntu 14.04 Trusty
deb http://deb.theforeman.org/ trusty 1.6
# Ubuntu 12.04 Precise
deb http://deb.theforeman.org/ precise 1.6

# Nightly builds. Beware: HERE BE DRAGONS

# Debian Wheezy
deb http://deb.theforeman.org/ wheezy nightly
# Debian Squeeze
deb http://deb.theforeman.org/ squeeze nightly
# Ubuntu 14.04 Precise
deb http://deb.theforeman.org/ trusty nightly
# Ubuntu 12.04 Precise
deb http://deb.theforeman.org/ precise nightly

You may also want some plugins from the plugin repo (required for the Foreman Installer):

# Plugins compatible with Stable
deb http://deb.theforeman.org/ plugins 1.6
# Plugins compatible with Nightly
deb http://deb.theforeman.org/ plugins nightly

The public key for secure APT can be downloaded here

You can add this key with

apt-key add pubkey.gpg

or combine downloading and registering:

wget -q http://deb.theforeman.org/pubkey.gpg -O- | apt-key add -

The key fingerprint is

7059 542D 5AEA 367F 7873  2D02 B348 4CB7 1AA0 43B8
Foreman Automatic Signing Key (2014) <packages@theforeman.org>

Remember to update your package lists!

apt-get update

Install packages

The packages are now split by gem dependencies - there are 11 packages to choose from. These are:

Main package:

  • foreman

Database gems - you need at least one of these:

  • foreman-sqlite3
  • foreman-mysql2
  • foreman-pgsql

Optional functionality:

  • foreman-console
  • foreman-compute
  • foreman-gce
  • foreman-libvirt
  • foreman-ovirt
  • foreman-test
  • foreman-vmware

Command line interface:

  • ruby-hammer-cli
  • ruby-hammer-cli-foreman

Installation instructions are:

# Install packages  (adjust additional packages as needed)
apt-get install foreman foreman-sqlite3 foreman-libvirt

# Copy sample db config to /etc
cp /usr/share/foreman/config/database.yml.example /etc/foreman/database.yml

# Review settings and DB config
vi /etc/foreman/settings.yaml /etc/foreman/database.yml

# Perform initial DB setup
foreman-rake db:migrate
foreman-rake db:seed

The packages should auto-run db:migrate and db:seed if /etc/foreman/database.yml exists. So the initial DB setup is only needed during first install, upgrades should just work.

Upgrade

See upgrade instructions

3.4 Install From Source

Installing the latest development code: Foreman has now moved to using Rails 3 and Bundler to 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 1.8.7 or 1.9
  • rubygems
  • Puppet >= 0.24.4

The installation has been successfully tested on RHEL[5,6], Fedora[13,14,15,16,17], Debian Linux 6.0 (Squeeze) and Ubuntu Linux 12.04 (the community has reported varying success with other Debian/Ubuntu versions - 12.10 seems fine for example). For older operating systems you might need additional packages (e.g. sqlite). It is also known to work on Solaris and Mac.

to get latest “development” version do:

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, and libvirt-devel packages

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

yum groupinstall "Development Tools" "Development Libraries"
yum -y install gcc-c++ git ruby ruby-devel rubygems \
    libvirt-devel mysql-devel postgresql-devel openssl-devel \
    libxml2-devel sqlite-devel libxslt-devel zlib-devel \
    readline-devel tar

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.

git clone https://github.com/theforeman/foreman.git -b develop
cd foreman
cp config/settings.yaml.example config/settings.yaml
cp config/database.yml.example config/database.yml
gem install bundler
# depending on database configured in yml file you can skip others
# (we are assuming sqlite to be configured)
bundle install --without mysql2 pg test --path vendor # or postgresql
# set up database schema, precompile assets and locales
RAILS_ENV=production bundle exec rake db:migrate
RAILS_ENV=production bundle exec rake db:seed assets:precompile locale:pack

You can run Foreman with the command ”./script/rails s -e production”

This manual will recommend foreman-rake <task> to run rake tasks, however when installed from source, replace this with bundle exec rake <task> RAILS_ENV=production

Latest stable version

to get latest “stable” version do:

git clone https://github.com/theforeman/foreman.git -b 1.6-stable

CLI (Hammer)

To install hammer from git checkouts, you will just need rake installed on your system. Clone and install CLI core

$ git clone https://github.com/theforeman/hammer-cli.git
$ cd hammer-cli
$ rake install
$ cd ..

and clone plugin with foreman commands

$ git clone https://github.com/theforeman/hammer-cli-foreman.git
$ cd hammer-cli-foreman
$ rake install
$ cd ..

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.

In all cases, please use the production settings.

to initialize the database schema and content, run:

foreman-rake db:migrate
foreman-rake db:seed

For more information please see the database configuration page here

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

The ‘config/email.yaml’ file

An example settings file can be found at config/email.yaml.example, copy this file to config/email.yaml

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)

delivery_method

The mail transport method to be used.

Valid settings:

:smtp
:sendmail
Example email.yml Configurations
Simple Login Authentication (default settings)
production:
  delivery_method: :smtp
  smtp_settings:
    address: smtp.example.net
    port: 25
    domain: example.net
    authentication: :login
    user_name: foreman@example.net
    password: foreman
No Authentication

Example for an SMTP service provider with no authentication. Note the colon before none.

production:
  delivery_method: :smtp
  smtp_settings:
    address: smtp.nowhere.net
    port: 25
    domain: nowhere.com
    authentication: :none
Using sendmail command

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

production:
  delivery_method: :sendmail

The ‘Administer/Settings’ page

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

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: ‘’

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

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”]

document_root

Puppetdoc will create RDoc documents for your manifests if its available. This setting allows you to select the directory where you want these documents to be created. Default: foreman_root/public/puppet/rdoc

email_reply_address

The return address applied to outgoing emails. Default: Foreman-noreply@<your domain>

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

failed_report_email_notification

If this option is set to true then an email will be sent to the host’s owner whenever a report is received that contains errors. If the host is not owned or Foreman is not configured to use logins then send the email to the administrator. 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

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

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_puppet_facts_for_provisioning

If this option is set to true then Foreman will not update a host’s IP and MAC with the values that it receives in a host’s facts and it will also include Foreman’s values for IP and MAC to puppet in its node information. Default: false

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

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: ‘’

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

oauth_active

Enables OAuth authentication for API requests. Default: false

oauth_consumer_key

OAuth consumer key Default: ‘katello’

oauth_consumer_secret

OAuth consumer secret Default: ‘shhhh’

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

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

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

remote_addr

If Foreman is running behind Passenger or a remote load balancer, the IP of this load balance should be set 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_puppetmasters

When set to true, Foreman requires a client SSL certificate on requests from 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 Foreman and puppet masters, see Section 5.4.1 Default: true

restrict_registered_puppetmasters

When set to true, you will have to register your puppet masters as Smart Proxies with the Puppet feature so they can 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

The default templating system used within Foreman allows unlimited interpolated variables and expressions. This could obviously be abused so a evaluation environment is provided that restricts the template variables and expressions to a whitelist. When this option is true then only known helper methods and instance variables will be available in template expansion. Default: true

signo_sso

Use Signo as SSO login. Default: false

signo_url

Signo SSO url for login. Default: https://theforeman/signo

ssl_client_dn_env

Environment variable containing the subject DN from a client SSL certificate Default: SSL_CLIENT_S_DN

ssl_client_verify_env

Environment variable containing the verification status of a client SSL certificate Default: SSL_CLIENT_VERIFY

ssl_ca_file

The SSL Certificate Authority file that Foreman will use when connecting to its smart-proxies. Default: The CA file used by puppet

ssl_certificate

The SSL certificate that Foreman will use when connecting to its smart-proxies. Default: The host certificate used by puppet

ssl_priv_key

The SSL private key file that Foreman will use when connecting to its smart-proxies. Default: The private key file used by puppet

token_duration

Time in minutes installation tokens should be valid for, 0 to disable. Default: 60

trusted_puppetmaster_hosts

Other trusted puppet masters in addition to Smart Proxies to access fact/report importers and ENC output. i.e: [puppetmaster1.yourdomain.com, puppetmaster2.yourdomain.com] Default: []

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

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

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. When set to ‘auto’, it will be enabled if the session is using HTTPS and both websockets_ssl_key and websockets_ssl_cert are set.

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!

The database configuration file can be found at:

/etc/foreman/database.yml

SQLite (default)

When using SQLite, you can install the foreman-sqlite package. See 3.3 Install From Packages.

By default, the database will be created in the db subdirectory.

production:
  adapter: sqlite3
  database: db/production.sqlite3
  pool: 5
  timeout: 5000

MySQL

When using MySQL, you can install the foreman-mysql2 package. See 3.3 Install From Packages.

Edit your config/database.yml and modify:

production:
  adapter: mysql2
  database: foreman
  username: foreman
  password: password
  host: localhost
  socket: "/var/run/mysqld/mysqld.sock"

Afterwards you would need to re-populate your database, simply execute:

foreman-rake db:migrate
foreman-rake db:seed

PostgreSQL

When using PostgreSQL, you can install the foreman-postgresql package. See 3.3 Install From Packages.

Edit your config/database.yml and modify:

production:
  adapter: postgresql
  database: foreman
  username: foreman
  password: password
  host: localhost

Switching from SQLite to MySQL/PostgreSQL while maintaining existing data

We have a rake task for this. First setup your database.yml to have the sqlite db as production and the mysql/psql db as dev:

production:
  adapter: sqlite3
  database: db/production.sqlite3
  pool: 5
  timeout: 5000

development:
  adapter: postgresql
  database: foreman
  username: foreman
  password: password
  host: localhost

Now migrate both dbs so they’re consistent:

bundle exec rake db:migrate RAILS_ENV=production
bundle exec rake db:migrate RAILS_ENV=development

Now move the data to the new db

bundle exec rake db:convert:prod2dev

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

cat <<EOF > reset.sql
SELECT  'SELECT SETVAL(' ||quote_literal(S.relname)|| ', MAX(' ||quote_ident(C.attname)|| ') ) FROM ' ||quote_ident(T.relname)|| ';'
FROM pg_class AS S, pg_depend AS D, pg_class AS T, pg_attribute AS C
WHERE S.relkind = 'S'
    AND S.oid = D.objid
    AND D.refobjid = T.oid
    AND D.refobjid = C.attrelid
    AND D.refobjsubid = C.attnum
ORDER BY S.relname;
EOF
psql -Atq -f reset.sql -o temp foreman
psql -f temp foreman
rm temp reset.sql

(big thanks to Fixing Sequences for the fix)

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:

report = true

Without it, no reports will be sent.

Puppet master

First identify the directory containing report processors, e.g.

  • EL6 (e.g. RHEL, CentOS): /usr/lib/ruby/site_ruby/1.8/puppet/reports/
  • EL7 or Fedora: /usr/share/ruby/vendor_ruby/puppet/reports/
  • Debian or Ubuntu: /usr/lib/ruby/vendor_ruby/puppet/reports/
  • other OSes, look for tagmail.rb in the Puppet installation (locate tagmail.rb)

Copy the report processor source to this report directory and name it foreman.rb.

Create a new configuration file at /etc/puppet/foreman.yaml containing:

---
# Update for your Foreman and Puppet master hostname(s)
:url: "https://foreman.example.com"
:ssl_ca: "/var/lib/puppet/ssl/certs/ca.pem"
:ssl_cert: "/var/lib/puppet/ssl/certs/puppet.example.com.pem"
:ssl_key: "/var/lib/puppet/ssl/private_keys/puppet.example.com.pem"

# Advanced settings
:puppetdir: "/var/lib/puppet"
:puppetuser: "puppet"
:facts: true
:timeout: 10
:threads: null

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

Lastly add this report processor to your Puppet master configuration. In your master puppet.conf under the [main] section add:

reports=log, foreman

and restart your Puppet master.

You should start seeing reports coming in under the reports link.

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:

  1. 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.
  2. /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.
  3. 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:

  1. Expires all reports regardless of their status
    foreman-rake reports:expire days=7
  2. 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 to /etc/puppet/node.rb (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/puppet/foreman.yaml containing:

---
# Update for your Foreman and Puppet master hostname(s)
:url: "https://foreman.example.com"
:ssl_ca: "/var/lib/puppet/ssl/certs/ca.pem"
:ssl_cert: "/var/lib/puppet/ssl/certs/puppet.example.com.pem"
:ssl_key: "/var/lib/puppet/ssl/private_keys/puppet.example.com.pem"

# Advanced settings
:puppetdir: "/var/lib/puppet"
:puppetuser: "puppet"
:facts: true
:timeout: 10
:threads: null

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

sudo -u puppet /etc/puppet/node.rb [the name of a node, eg agent.local]

should output something like:

parameters:
  puppetmaster: puppet
  foreman_env: &id001 production
classes:
  helloworld:
environment: *id001

This output should match the information displayed when you click on the YAML button on the Host page in Foreman.

For further information see the Puppet Labs docs on external nodes

Debugging the ENC
  1. 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.
  2. 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.
  3. 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.

More information in the Configuration section.

Pushing facts to Foreman when not using the ENC functionality

There are several options for pushing fact data to Foreman if you are using Foreman for reporting/inventory only.

Using node.rb

The ENC script (node.rb) accepts an option to run in ‘batch-mode’. In this mode, the script iterates over the cached fact data stored on the puppet master, and uploads all of it to Foreman.

Download and configure the node.rb script as above, and then call it like this:

sudo -u puppet /etc/puppet/node.rb --push-facts

The following options are available for node.rb’s batch mode:

  • --push-facts uploads all facts sequentially which have changed since the last run.
  • --push-facts-parallel uploads all facts in parallel which have changed since the last run. The number of threads is specified by the :threads setting or the number of processors.
  • --watch-facts runs in the foreground and upload facts based on inotify events, used in conjunction with either –push-facts option.
Direct HTTP upload

As of Foreman 1.3, the fact-upload API endpoint accepts data in pure JSON. You can push data to Foreman as a hash containing:

{
  "name": "fqdn-of-host.domain.com",
  "certname": "optional-certname-of-host.domain.com",
  "facts": {
    "fact1": "string",
    "fact2": "true",
    "fact3": "1.2.3.4",
    ...
  }
}

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
  • :log_level: <level> - logging level. One of debug, info, warning, error, fatal
  • :log_owner: <owner> - logfile owner
  • :log_group: <group> - logfile group
  • :log_size: 1048576 - size in bytes, when exceeded the log rotates. Default is 1MB
  • :watch_plain: false - turn on/off syntax highlighting of data being logged in debug mode

Sample config

:modules:
    - hammer_cli_foreman

:foreman:
    :host: 'https://localhost/'
    :username: 'admin'
    :password: 'changeme'

:log_dir: '/var/log/foreman/'
:log_level: 'debug'

3.6 Upgrade

Upgrading to Foreman 1.6

Preparation

Before updating to 1.6, make sure you have successfully upgraded to 1.5 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.

Please note the following important change:

  • Proxy config migration: the smart proxy configuration will be migrated to a new split layout, with a file per module. It’s recommended to take a backup of /etc/foreman-proxy/settings.yml in case the automatic migration fails.

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 from the above list of release packages, e.g. for RHEL6

yum upgrade http://yum.theforeman.org/releases/1.6/el6/x86_64/foreman-release.rpm

Clean up the yum cache:

yum clean all

Next upgrade all Foreman packages:

yum upgrade ruby\* foreman\*

In order to catch all configuration changes and manage them properly you should install and run rpmconf from the EPEL repository along with vim-enhanced (for vimdiff):

rpmconf -a --frontend=vimdiff

You can skip to Step 3.

Step 2 (B) - Debian or Ubuntu package (deb) and installer setups

Upgrading from the last release to 1.6 has been tested on both Debian and Ubuntu. Updating the packages will upgrade the application and automatically migrate the database.

First edit /etc/apt/sources.list.d/foreman.list and change the release number from the previous release or “stable” to 1.6:

deb http://deb.theforeman.org/ wheezy 1.6
deb http://deb.theforeman.org/ plugins 1.6

Next upgrade all Foreman packages:

apt-get update
apt-get --only-upgrade install ruby\* foreman\*

You can skip to Step 3.

Step 2 (C) - Downloaded release (tar.bz2)
  • Uncompress the new program archive in a new directory.
  • Copy your database settings-file config/database.yml into the new config directory.
  • If your database is a simple file (e.g. SQLite), don’t forget to make it available in the new directory.

VERY IMPORTANT: do NOT overwrite config/settings.yml with the old one.

Step 2 (D) - git checkouts

Please note now that the development branch has moved to Rails 3, you MUST take care to select a branch and make sure you get the correct one.

  1. Go to the Foreman root directory and run the following command:

For staying on the stable branch:

  • git checkout 1.6-stable
  • git pull

The following step is the one that could change the contents of your database. Go to your new Foreman directory (or the git dir), then migrate and update the contents of your database:

foreman-rake db:migrate
foreman-rake db:seed

You should compile i18n strings and precompile assets now:

foreman-rake locale:pack
foreman-rake assets:precompile

Step 3 - Post-upgrade steps

Step 3 (A) - Database migration and cleanup

The database should be migrated already, but you can make sure by executing the migration script again, it should produce no errors or output:

foreman-rake db:migrate
foreman-rake db:seed

You should clear the cache and the existing sessions:

foreman-rake tmp:cache:clear
foreman-rake tmp:sessions:clear
Optional Step 3 (B) - 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

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

Common issues

See Troubleshooting

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

Foreman natively supports LDAP authentication using one or multiple LDAP directories.

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
  • Base DN: the top level DN of your LDAP directory tree, e.g. dc=example,dc=com
  • Group base DN: the top level DN of your LDAP directory tree that contains groups, e.g. ou=Groups,dc=example,dc=com
  • LDAP filter (optional): a filter to restrict your LDAP queries, for instance: (memberOf=cn=foreman-users,ou=Groups,dc=example,dc=com). Multiple filters can be combined using the syntax (& (filter1) (filter2)).

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.

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.

Additional Information:

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 sAMAccountName
First name attribute givenName
Surname attribute sn
Email address attribute mail
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
Login name attribute uid
First name attribute givenName
Surname attribute sn
Email address attribute mail
OpenLDAP

Typically LDAP on port 389 and with anonymous queries (leave Account blank), unless configured otherwise.

Setting Value
Account uid=foreman,dc=example,dc=com
Base DN dc=example,dc=com
Groups base DN dc=example,dc=com
Login name attribute uid
First name attribute givenName
Surname attribute sn
Email address attribute mail

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:external_usergroups or by refreshing the external user groups in the UI. Otherwise, the problem will eventually get fixed when the cronjob runs again.

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 addresses 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 Anonymous 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 are two builtin system roles

  1. Anonymous: This is a set of permissions that every user at your installation will be granted, irrespective of any other roles that they have.

  2. Default user: When a new Role is created this set of permissions are used as the template for the Role. The name is somewhat misleading but basically an ordinary default user who was assigned this Role would have these permissions set.

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:

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

  2. Compute resource membership: ‘compute_resource = Openstack’ - Will apply permissions to hosts deployed on compute resource Openstack.

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

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

Following table lists some of permissions and their impact:

Permission Description
Permissions for Architectures, Authentication providers, environments, External variables, Common parameters, Medias, Models, Operating systems, Partition tables, Puppet classes and User groups
view 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

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.

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 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 minimum for 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 successfully”
  • 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.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.

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.

Importing from Puppet

Foreman can detect all the environments and classes contained on a PuppetMaster, and import them automatically. To do this, go to Configure > Environments and click on *Import from *. Foreman will scan the PuppetMaster, and display a confirmation of the detected changes. Select the changes you wish to apply and confirm.

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 index, and then select Change Environment from the buttons at top of the page.

Environments with Hostgroups

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

The “Hosts” Column

Under Configure > Puppet 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.

This column currently suffers from a known bug. This bug means this count excludes host groups from final figure.

Ignoring classes on import

It’s often to have a module structure like this:

$ tree git/
git/
└── manifests
    ├── init.pp
    ├── install.pp
    ├── params.pp
    └── repo.pp

In this situation, Foreman would offer to create:

git
git::install
git::params
git::repo

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 takes a set of regular expressions - any class which matches one of them will not be imported. So, for this example, we might configure:

:filters:
  - !ruby/regexp '/install$/'
  - !ruby/regexp '/params$/'
  - !ruby/regexp '/repo$/'

Assigning Classes to Hosts

To cause Puppet to apply your classes, you will need to assign them to your Hosts. This can be done at either an individual host level, or at a group level. The process is the same; edit the Host(group), select an Environment, and then go to the Puppet Classes tab and select what classes you want in this Host(Group).

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 PuppetMaster - the classes will be in the “classes” hash.

4.2.3 Parameters

Foreman’s concept of parameters maps onto Puppet’s idea of default-scope parameters. Foreman allows us to define a hierarchy of parameter inheritance.

Global Parameters

These are defined in Configure > Global Parameters and will apply to every host in Foreman.

Domain Parameters

These are defined for all Hosts in a given domain. Edit the domain from Infrastructure > Domains and switch to the Parameters tab and specify a parameter. If it has the same name as a Global Parameter, it will override the Global one.

Hostgroup Parameters

These are defined for all Hosts in the Group. Edit the Hostgroup from Configure > Host Groups and switch to the Parameters tab and specify a parameter. If it has the same name as a Global or Domain Parameter, it will override it.

Host Parameters

The final (most-specific) level of Parameters applies only to a single Host. Edit a Host and switch to Parameters, and you will see all it’s inherited parameters from the other three layers (note: they will all be marked as “Scope: Global” as this refers to the Puppet scope, not the Foreman scope). You can override higher-level 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 PuppetMaster -the parameters will be in the “parameters” hash.

4.2.4 Smart Variables

Smart variables are a tool to provide data (Key / Value), normally to your puppet ENC, depending on a set of rules. They are intended to be a stepping stone to full parameterized classes.

Smart variable is usually associated with a puppet class, and may have multiple values, all depending on hierarchical context or various conditions a user can wish to apply.

for example:

Example

Creating a Smart Variable

Start by going to Configure > Puppet 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:

Name What the parameter will be called in the ENC data
Description A free form text box for your own information
Default Value What the ENC will use if no other criteria is matched
Type Validator A combo-box of data types. The type applies to the next field, the validator
Validator Constraint Used to enforce certain values for the Smart Variable. See below for examples
Order A list of variables which Foreman will search (in order) for the validator

Once you’ve created the defaults for your Smart variable, you then need to add at least one criterion to match against - click the “plus” under your variable, and two more input fields will appear:

Match 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

Validators

The fourth and fifth fields in the Smart Variable combine to produce a validation criteria for the final value of the Smart Variable.

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 Smart Variable will be checked against this list. If the value does not match the validator, and error will be raised.

Ordering

All the ordering information is stored in the sixth field of the Smart Variable (order). The order matters and is used to find the first match.

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:

Name target
Description The target server to talk to
Default Value server.foo
Type Validator string
Validator Constraint
Order fqdn
hostgroup
os
domain
Match 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:

Name port
Description The port to use
Default Value 80
Type Validator list
Validator Constraint 80,443,8080
Order fqdn
region
hostgroup
os
domain
Match region = europe
Value 8080
Match 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.

Name 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
Match fqdn = foo.domain
Value 67
Match region = europe, hostgroup = "web servers", environment = production
Value 8080

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

https://foreman/hosts/<fqdn>/lookup_keys/<key>

You can find a ready-made function for your puppet module here

4.2.5 Parameterized Classes

Parameterized Class Support (PCS) permits detecting, importing, and supplying parameters direct to classes which support it, via the ENC.

Requirements

  • Foreman 1.1+
  • Foreman-Proxy 1.1+
  • Puppet 2.6.5+

Setup

Firstly, you’ll need to enable the PCS support. Go to Administer > Settings, select the Puppet tab, and ensure Parameterized_Classes_in_ENC is set to true.

Settings

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)

Import

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:

3 Tabs

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

Edit

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

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:

User Param

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:

Matcher

This is a basic configuration - for more complex examples of using matchers, see the 4.2.4 Smart Variables page.

Complex Data

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

Array

This will be converted to the normal [“a”,”b”] syntax when you save. You can also use Hashes, YAML or JSON as data types too.

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:

Template Variable

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.

More information regarding templates can be found on the wiki. This page also contains the pre-existing functions and macros you can use in your templates and parameter classes.

Editing Param from within 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:

Host Edit

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

Host Matcher

Currently this only works for Hosts, not Hostgroups. For more complex logic, like matching on facts, use the Puppet Class page

Input Validation

The “Optional Input Validator” section can be used to restrict the allowed values for the parameter. This functions in the same way as for Smart Variables, but 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.

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

  • Type: List
  • Rule: foreman,foremandev

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.

Currently supported (Click on the links below for more details).

  • DHCP - ISC DHCP and MS DHCP Servers
  • DNS - Bind and MS DNS Servers
  • TFTP - any UNIX based tftp server
  • Puppet - Any Puppet server from 0.24.x
  • Puppet CA - Manage certificate signing, cleaning and autosign on a Puppet CA server
  • Chef Proxy - Allow authentication of facts and reports between chef-client and Foreman
  • Realm - Manage host registration to a realm (e.g. FreeIPA)

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

After you got it running, You would need to configure each one of the sub systems via the settings.yml file 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 and support the netsh dhcp utility, 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.

Source code

You can get the latest stable code from GitHub (via git).

git clone git://github.com/theforeman/smart-proxy.git

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

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.

YAML start

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

---

Core SSL 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

  :ssl_certificate: ssl/certs/fqdn.pem
  :ssl_ca_file: ssl/certs/ca.pem
  :ssl_private_key: ssl/private_keys/fqdn.key

This is the list of hosts from which the smart proxy will accept connections. If this list is empty then every verified SSL connection is allowed to access the API.

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

Server 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

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 for security, which also requires the three ssl_* settings to be set.

:http_port: 8443
# OR
:https_port: 8443

Logging (settings.yml)

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

  • WARN
  • DEBUG
  • ERROR
  • FATAL
  • INFO
  • UNKNOWN

See Ruby’s Logger class for details.

:log_file: /var/log/foreman-proxy/proxy.log
:log_level: DEBUG

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.

:enabled: true
:bmc_default_provider: freeipmi

Available providers are:

  • freeipmi - for IPMI control using the freeipmi implementation
  • ipmitool - using the ipmitool implementation
  • shell - specialized provider for controlling the proxy server itself (used for Foreman Discovery)

The credentials and addresses used to control hosts are passed from Foreman itself by adding a new network interface with the type set to “BMC” to hosts.

4.3.4 Chef

Chef proxy allows proxying of the reports and facts uploads between the chef-client on all your hosts and Foreman.

In order to use this feature, you will need to:

  • Use the gem chef_handler_foreman in you chef-client.rb (see documentation)
  • Use the foreman_chef plugin in Foreman for Facts upload (see documentation)

You can also authenticate the reports and facts upload. In order to do that, reports and facts are signed with chef-client private key in chef_handler_foreman plugin. When receiving a report or facts, the smart-proxy retreives the node’s public key and check if signature is valid. This requires:

  • the use of chef-server
  • a declared client for the smart-proxy with admin rights (to be able to fetch all clients public keys)

Configuration

In the smart-proxy settings.yml, you need to:

  • enable the chefproxy feature
  • configure foreman_url setting

If you want to authenticate reports and facts, you need to:

  • enable chef_authenticate_nodes feature
  • configure chef_server_url setting (make sure smart-proxy can reach your chef-server)
  • configure the chef_smartproxy_clientname: you should set a client with admin rights in chef-server
  • configure the chef_smartproxy_privatekey: this key should be the private associated with the chef_smartproxy_clientname and should be readable with smart-proxy user

4.3.5 DHCP

4.3.5.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).

:enabled: true

If the DHCP server is ISC compliant then set dhcp_vendor to isc. In this case Smart Proxy must run on the same host as the DHCP server. If the proxy is managing a Microsoft DHCP server then set dhcp_vendor to native_ms. Smart Proxy must then be run on an NT server so as to access the Microsoft native tools, though it does not have to be the same machine as the DHCP server. More details can be found in the Foreman Architecture.

:dhcp_vendor: isc

The DHCP component needs access to the DHCP configuration file as well as the currently allocated leases. For a Red Hat or Fedora-based host, the following values are typical:

:dhcp_config: /etc/dhcpd.conf
:dhcp_leases: /var/lib/dhcpd/dhcpd.leases

On a Debian or Ubuntu DHCP server, use the following values instead:

:dhcp_config: /etc/dhcp3/dhcpd.conf
:dhcp_leases: /var/lib/dhcp3/dhcpd.leases
The foreman-proxy account must be able to read both configuration files. In particular, check the permissions on the parent directory (e.g. /etc/dhcp) permit world read/execute.

If you secured your DHCP with an “omapi_key”, add the entries:

:dhcp_key_name: omapi_key
:dhcp_key_secret: XXXXXXXX

Large numbers of subnets can slow the Smart Proxy down when iterating over the reservations. You can request that the Smart Proxy only operate on a subset of the subnets managed by the DHCP server. This works with both isc and native_ms providers.

:dhcp_subnets: [192.168.1.0/255.255.255.0, 192.168.11.0/255.255.255.0]

4.3.5.2 ISC DHCP

ISC implementation is based on the OMAPI interface, which means:

  • No need for root permissions on your DHCP server
  • No need to restart (or “sync”) your DHCP server after every modifications.
Configuration
  • dhcpd configuration file: ensure you have the following line in your dhcpd.conf file (somewhere in the top first lines):
omapi-port 7911;
  • configure the settings file to point to your dhcpd.conf and dhcpd.leases files (make sure they are readable by the smart-proxy user)
  • make sure the omshell command (/usr/bin/omshell) can be executed by the smart-proxy user.
  • make sure that /etc/dhcp and /etc/dhcp/dhcpd.conf has group foreman-proxy
Securing the dhcp API

The dhcpd api server will listen to any host. You might need to add a omapi_key to provide basic security.

Example generating a key (on CentOS):

yum install bind97
dnssec-keygen -r /dev/urandom -a HMAC-MD5 -b 512 -n HOST omapi_key
cat Komapi_key.+*.private |grep ^Key|cut -d ' ' -f2-
  1. Edit your “/etc/dhcpd.conf”:

     omapi-port 7911;
     key omapi_key {
     algorithm HMAC-MD5;
     secret "XXXXXXXXX"; #<-The output from the generated key above.
     };
     omapi-key omapi_key;
     
  2. Make sure you also add the omapi_key to your proxy’s dns.yml

  3. Restart the dhcpd and foreman-proxy services

NOTE: if you don’t see DHCP in Smart Proxies Features, choose “Refresh features” from drop-down menu.

Testing

If everything works, you could browse your dhcp server data if you goto http://proxy:8443/dhcp

The next step is to set up appropriate Subnets in Foreman from the settings menu.

Sample dhcpd.conf
ddns-update-style interim;
ignore client-updates;
authoritative;
allow booting;
allow bootp;

omapi-port 7911;
#Optional key:
key omapi_key {
        algorithm HMAC-MD5;
        secret "2wgoV3yukKdKMkmOzOn/hIsM97QgLTT4CLVzg9Zv0sWOSe1yxPxArmr7a/xb5DOJTm5e/9zGgtzL9FKna0NWis==";
}
omapi-key omapi_key;

subnet 10.1.1.0 netmask 255.255.255.0 {
# --- default gateway
  option routers      10.1.1.254;
  option subnet-mask  255.255.255.0;

  option domain-name    "domain.com";
  option domain-name-servers  10.1.1.1, 8.8.8.8;
  option log-servers    syslog;
  option ntp-servers    ntp;

  range dynamic-bootp 10.1.1.10 10.1.1.250;
  default-lease-time 21600;
  max-lease-time 43200;

}

4.3.5.3 MS DHCP

The Microsoft smart-proxy installation procedure is very basic compared to the RPM or APT based solution.

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 that has netsh commands available.

  1. Go to the smart-proxy repository at https://github.com/theforeman/smart-proxy
  2. Select download and choose the latest revision
  3. Extract this to a directory that does not have any spaces in its name.
  4. Go to the rubyinstaller webpage at http://rubyinstaller.org/downloads/
  5. Download and install the “ruby 1.8.7 release 334”:http://rubyforge.org/frs/download.php/74293/rubyinstaller-1.8.7-p334.exe (Allow the ruby associations to be installed.)
  6. Open a CMD window and, using gem install –version X.X.X –platform ?????, add these gems
  columnize (0.3.2)
  highline (1.6.1)
  json (1.4.6 x86-mswin32)
  linecache (0.43 mswin32)
  mime-types (1.16)
  mocha (0.9.11)
  net-ping (1.3.7)
  rack (1.2.0)
  rake (0.8.7)
  rest-client (1.6.1)
  sinatra (1.1.0)
  tilt (1.1)
  win32-api (1.4.6 x86-mswin32-60)
  win32-open3 (0.3.2 x86-mswin32-60)
  win32-service (0.7.1 x86-mswin32-60)
  windows-api (0.4.0)
  windows-pr (1.1.2)

Command to download them all:

wget http://rubygems.org/downloads/columnize-0.3.2.gem \
     http://rubygems.org/downloads/haml-3.0.24.gem \
     http://rubygems.org/downloads/highline-1.6.1.gem \
     http://rubygems.org/downloads/json-1.4.6-x86-mswin32.gem \
     http://rubygems.org/downloads/linecache-0.43-mswin32.gem \
     http://rubygems.org/downloads/mime-types-1.16.gem \
     http://rubygems.org/downloads/mocha-0.9.11.gem \
     http://rubygems.org/downloads/net-ping-1.3.7.gem \
     http://rubygems.org/downloads/rack-1.2.0.gem \
     http://rubygems.org/downloads/rake-0.8.7.gem \
     http://rubygems.org/downloads/rest-client-1.6.1.gem \
     http://rubygems.org/downloads/sinatra-1.1.0.gem \
     http://rubygems.org/downloads/tilt-1.1.gem \
     http://rubygems.org/downloads/win32-api-1.4.6-x86-mswin32-60.gem \
     http://rubygems.org/downloads/win32-open3-0.3.2-x86-mswin32-60.gem \
     http://rubygems.org/downloads/win32-service-0.7.1-x86-mswin32-60.gem \
     http://rubygems.org/downloads/windows-api-0.4.0.gem \
     http://rubygems.org/downloads/windows-pr-1.1.2.gem

To get it to work on Windows 2008 R2 some of the packages has to change

 columnize (0.3.2)
 highline (1.6.1)
 json (1.4.6 x86-mingw32)
 linecache (0.43 mswin32)
 mime-types (1.16)
 mocha (0.9.11)
 net-ping (1.3.7)
 rack (1.2.0)
 rake (0.8.7)
 rest-client (1.6.1)
 sinatra (1.1.0)
 tilt (1.1)
 win32-api (1.4.6 x86-mingw32)
 win32-open3 (0.3.2 x86-mingw32)
 win32-service (0.7.1 x86-mswin32-60)
 windows-api (0.4.0)
 windows-pr (1.1.2)

Easy copy and paste method (platform may be different for you. Please check gem environment to find out.

  gem install --version 0.3.2 --platform x86-mingw32 columnize
  gem install --version 1.6.1 --platform x86-mingw32 highline
  gem install --version 1.4.6 --platform x86-mingw32 json
  gem install --version 0.43 --platform x86-mingw32 linecache
  gem install --version 1.16 --platform x86-mingw32 mime-types
  gem install --version 0.9.11 --platform x86-mingw32 mocha
  gem install --version 1.3.7 --platform x86-mingw32 net-ping
  gem install --version 1.2.0 --platform x86-mingw32 rack
  gem install --version 0.8.7 --platform x86-mingw32 rake
  gem install --version 1.6.1 --platform x86-mingw32 rest-client
  gem install --version 1.1.0 --platform x86-mingw32 sinatra
  gem install --version 1.1 --platform x86-mingw32 tilt
  gem install --version 1.4.6 --platform x86-mingw32 win32-api
  gem install --version 0.3.2 --platform x86-mingw32 win32-open3
  gem install --version 0.7.1 --platform x86-mingw32-60 win32-service
  gem install --version 0.4.0 --platform x86-mingw32 windows-api
  gem install --version 1.1.2 --platform x86-mingw32 windows-pr

Command to download them all:

wget http://rubygems.org/downloads/columnize-0.3.2.gem \
     http://rubygems.org/downloads/haml-3.0.24.gem \
     http://rubygems.org/downloads/highline-1.6.1.gem \
     http://rubygems.org/downloads/json-1.4.6-x86-mingw32.gem \
     http://rubygems.org/downloads/linecache-0.43-mswin32.gem \
     http://rubygems.org/downloads/mime-types-1.16.gem \
     http://rubygems.org/downloads/mocha-0.9.11.gem \
     http://rubygems.org/downloads/net-ping-1.3.7.gem \
     http://rubygems.org/downloads/rack-1.2.0.gem \
     http://rubygems.org/downloads/rake-0.8.7.gem \
     http://rubygems.org/downloads/rest-client-1.6.1.gem \
     http://rubygems.org/downloads/sinatra-1.1.0.gem \
     http://rubygems.org/downloads/tilt-1.1.gem \
     http://rubygems.org/downloads/win32-api-1.4.6-x86-mingw32.gem \
     http://rubygems.org/downloads/win32-open3-0.3.2-x86-mingw32.gem \
     http://rubygems.org/downloads/win32-service-0.7.1-x86-mswin32-60.gem \
     http://rubygems.org/downloads/windows-api-0.4.0.gem \
     http://rubygems.org/downloads/windows-pr-1.1.2.gem

8) CD to the root of the smart-proxy install directory

9) Edit config/settings.yml so that it looks a bit like this

Sample config/settings.yml file

 ---
 # HTTPS settings
 :ssl_certificate: c:\documents\smart-proxy\config\signed.pem
 :ssl_private_key: c:\documents\smart-proxy\config\private.pem
 :ssl_ca_file:     c:\documents\smart-proxy\config\ca.pem

 :trusted_hosts: [ foreman.someware.com]

 :daemon: false


 # Enable DHCP management
 :dhcp: true
 # The vendor can be either isc or native_ms
 :dhcp_vendor: native_ms
 # The dhcp_server is only used by the native_ms implementation
 :dhcp_server: 172.29.90.240

 # Where our proxy log files are stored
 # filename or STDOUT
 # Unix setting
 #:log_file: log/proxy.log
 # Windows setting
 :log_file: c:\tmp\proxy.log
 # valid options are
 # Logger::WARN, Logger::DEBUG, Logger::Error, Logger::Fatal, Logger:INFO, LOGGER::UNKNOWN
 #:log_level: Logger::DEBUG

10) Create the SSL key

10.1) Login to your puppetmaster

10.2) puppetca –generate Smart-proxy FQDN. (Do not use an alias here.)

10.3) Copy the private key, the public certificate and the ca.pem from /var/lib/puppet/ssl over to the locations that you specified in the setting file.

11) Test the installation by running ruby bin\smart-proxy.rb

12) Install the program as a service

12.1) ruby extra\register-service.rb

12.2) This may install the service but not run it. If so then try to start the service from the Ordinary Microsoft services snapin utility.

13) You may test connectivity by running the extra\query.rb utility from your foreman host. (Note that this file comes from the extra directory in the smart-proxy release.)

4.3.6 DNS

4.3.6.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 documentation. Additional providers are available for managing libvirt’s embedded DNS server (dnsmasq) and Microsoft Active Directory using dnscmd, for static DNS records, avoiding scavenging.

Available providers are:

  • nsupdate - dynamic DNS update using nsupdate
  • nsupdate_gss - dynamic DNS update with GSS-TSIG
  • virsh - libvirt embedded DNS (dnsmasq)
  • dnscmd - static DNS records in Microsoft Active Directory

The dns_key specifies a file containing a shared secret used to generate a signature for the update request (TSIG record). This option should not be used if you plan to use Kerberos/GSS-TSIG (for example for DNS servers shipped with FreeIPA or Microsoft AD).

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.

:enabled: true
:dns_provider: nsupdate
:dns_key: /home/proxy/keys/Kapi.+157+47848.private
:dns_server: dnsserver.site.domain.com
If you use a key file or keytab, make sure that the foreman-proxy account can read that file.

The 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

GSS-TSIG authentication is controlled using the following settings, see the GSS-TSIG section for further details.

:dns_tsig_keytab: /usr/share/foreman-proxy/dns.keytab
:dns_tsig_principal: DNS/host.example.com@EXAMPLE.COM

4.3.6.2 BIND

Bind configuration manipulation is based on nsupdate, which means that in theory could also be used to manipulate other dns servers which support nsupdate (such as Microsoft DNS server).

Configuration

In order to communicate securely with your dns server, you would need a key which will be used by nsupdate and your named daemon using ddns-confgen or dnssec-keygen

example using ddns-confgen

execute ‘ddns-confgen -k foreman -a hmac-md5’ - this should output something like the following:

# 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.6.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

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 the /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:

kdestroy

Now create the keytab file with ktutil:

ktutil: addent -password -p foreman@EXAMPLE.COM -k 1 -e RC4-HMAC
ktutil: wkt dns.keytab
ktutil: q

Once the keytab file has been created, test it using kinit:

kinit foreman@EXAMPLE.COM -k -t dns.keytab

If this works, clear the Kerberos ticket cache once again using kdestroy.

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

The DNS zone Dynamic Updates option on the DNS zones can now be set to Secure Only. Now follow the steps below under Proxy Configuration.

FreeIPA configuration

A service principal is required for the Smart Proxy, e.g. foremanproxy/proxy.example.com@EXAMPLE.COM.

First of all, create a new principal (FreeIPA service) for Foreman, e.g. ipa service-add foremanproxy/proxy.example.com@EXAMPLE.COM.

Then fetch the keytab, e.g. ipa-getkeytab -p foremanproxy/proxy.example.com@EXAMPLE.COM -s ipa-server.example.com -k /etc/foreman-proxy/dns.keytab.

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

Next, update the proxy configuration file (/etc/foreman-proxy/settings.yml) with the following settings:

:dns_provider: nsupdate_gss
:dns_tsig_keytab: /etc/foreman-proxy/dns.keytab
:dns_tsig_principal: foremanproxy/proxy.example.com@EXAMPLE.COM
:dns_key: false

4.3.7 Puppet

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

  • reads the Puppet modules and manifests on 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.

:enabled: true
:puppet_conf: /etc/puppet/puppet.conf
Puppet class/environment imports

The proxy parses all of the Puppet manifests inside the environments declared from puppet.conf (set by :puppet_conf), which generates a list of all Puppet classes and the parameters they take. These are imported by Foreman to generate the list of classes, smart class parameters and environments that they belong to.

Parsing manifests is done using 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.

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 :puppet_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, the proxy queries the Puppet master on its own API. Typically the defaults will suffice, but the URL and settings used for the proxy to Puppet master API query can be controlled with the following settings:

# URL of the puppet master itself for API requests
#:puppet_url: https://puppet.example.com:8140
# SSL certificates used to access the puppet master API
#:puppet_ssl_ca: /var/lib/puppet/ssl/certs/ca.pem
#:puppet_ssl_cert: /var/lib/puppet/ssl/certs/puppet.example.com.pem
#:puppet_ssl_key: /var/lib/puppet/ssl/private_keys/puppet.example.com.pem

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 *
Puppet run providers

For the optional Puppet run functionality, one of a number of implementations can be chosen in the config file.

:puppet_provider: puppetrun

Available providers are:

  • puppetrun - for puppetrun/kick, deprecated in Puppet 3, see section below
  • mcollective - uses mco puppet, see section below
  • puppetssh - run puppet over ssh
  • salt - uses salt puppet.run
  • customrun - calls a custom command with args

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

puppetrun

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 method however is deprecated in Puppet 3 and isn’t recommended for new deployments.

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.

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

Defaults:foreman-proxy !requiretty
foreman-proxy ALL = NOPASSWD: /usr/bin/puppet kick *

If you are using Puppet 2.x, the proxy will use the older puppetrun command instead. The sudoers entry should be:

Defaults:foreman-proxy !requiretty
foreman-proxy ALL = NOPASSWD: /usr/sbin/puppetrun

The :puppet_user setting controls which user to sudo to, which on some installations (notably PE) may be different. When unset (:puppet_user:) then sudo will not be used.

MCollective

The proxy can trigger Puppet runs using the MCollective “puppet” agent. To enable this, add this line to settings.yml:

:puppet_provider: mcollective

And then add a sudoers rule:

Defaults:foreman-proxy !requiretty
foreman-proxy ALL = NOPASSWD: /usr/bin/mco puppet runonce *

The :puppet_user setting applies in the same way as noted above for puppetrun.

puppetssh

The puppetssh 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:

# whether to use sudo before the ssh command
:puppetssh_sudo: false
# the command which will be sent to the host
:puppetssh_command: /usr/bin/puppet agent --onetime --no-usecacheonfailure
# With which user should the proxy connect
#:puppetssh_user: root
#:puppetssh_keyfile: /etc/foreman-proxy/id_rsa

Salt

The salt provider uses Salt for remote execution, by executing the puppet module’s run routine.

customrun

The customrun provider allows configuration of a script that implements the Puppet run action in any way you require.

# Set :customrun_cmd to the full path of the script you want to run, instead of /bin/false
:customrun_cmd: /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.
:customrun_args: -ay -f -s

4.3.8 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: true

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

:ssldir: /etc/puppet/ssl

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

:puppetdir: /etc/puppet

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.

Ensure the foreman-proxy user is added to the puppet group ( e.g. gpasswd -a foreman-proxy puppet or usermod -aG puppet foreman-proxy)

puppet.conf:

[master]
autosign = $confdir/autosign.conf {owner = service, group = service, mode = 664 }

sudo access for the proxy is required - in your sudoers file ensure you have the following lines:

foreman-proxy ALL = NOPASSWD: /usr/bin/puppet cert *
Defaults:foreman-proxy !requiretty

For older versions of Puppet (2.x) without separate commands:

foreman-proxy ALL = NOPASSWD: /usr/sbin/puppetca *
Defaults:foreman-proxy !requiretty

4.3.9 Realm

4.3.9.1 realm.yml

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

:enabled: true
:realm_provider: freeipa

freeipa is the only provider currently available.

The following settings control authentication of the proxy to the realm for management of hosts:

# Authentication for Kerberos-based Realms
:realm_keytab: /etc/foreman-proxy/freeipa.keytab
:realm_principal: realm-proxy@EXAMPLE.COM

4.3.9.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.
# foreman-prepare-realm admin realm-proxy
Password for admin@EXAMPLE.COM: 
---------------------------------------
Added permission "modify host password"
---------------------------------------
  Permission name: modify host password
  Permissions: write
  Attributes: userpassword
  Type: host
[...]
Keytab successfully retrieved and stored in: freeipa.keytab
Realm Proxy User:    realm-proxy
Realm Proxy Keytab:  /root/freeipa.keytab
Configuration of Smart Proxy

Copy the freeipa.keytab created above to /etc/foreman-proxy/freeipa.keytab and set the correct permissions:

    chown foreman-proxy /etc/foreman-proxy/freeipa.keytab
    chmod 600 /etc/foreman-proxy/freeipa.keytab

Then update realm.yml with the relevant settings.

If you’re using FreeIPA to manage DNS records, and want them to be automatically deleted when the host is deleted in Foreman, set this to true:

:freeipa_remove_dns: true

Finally, trust the IPA Certificate Authority. Ensure you have the most up-to-date version of the ca-certificates package installed.

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

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.

First, we create a host group in FreeIPA:

# ipa hostgroup-add webservers
Description: web servers
----------------------------
Added hostgroup "webservers" 
----------------------------
  Host-group: webservers
  Description: web servers

Define an automember rule:

# ipa automember-add --type=hostgroup webservers
----------------------------------
Added automember rule "webservers" 
----------------------------------
Automember Rule: webservers

Create an automember condition based on the userclass attribute:

# ipa automember-add-condition --key=userclass --type=hostgroup --inclusive-regex=^webserver webservers
----------------------------------
Added condition(s) to "webservers" 
----------------------------------
  Automember Rule: webservers
  Inclusive Regex: userclass=^webserver
----------------------------
Number of conditions added 1
----------------------------

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.10 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: true
: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, this includes pxelinux.0, menu.c32, and chain.c32.

Manual Setup

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

  1. The TFTP root directory must exist (we will use /var/lib/tftpboot in this example).
  2. 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
  3. 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).
  4. Create the directory /var/lib/tftpboot/pxelinux.cfg and make it writeable by the foreman proxy user (foreman-proxy).
  • 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 [[Foreman:Unattended_installations 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.

  1. Call mkdir -p /var/lib/tftpboot/pxelinux.cfg if it does not already exist.
  2. 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.
  3. Call mkdir -p /var/lib/tftpboot/boot if it does not already exist.
  4. Download the OS specific kernel and initrd files using wget.
    1. 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).
    2. 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.
    3. cd into /var/lib/tftpboot/boot and check that the filesizes are not zero. Check /var/log/foreman-proxy/proxy.log for possible errors.
  5. The exact wget command is wget --no-check-certificate -nv -c <src> -O "<destination>"
  6. At this point, the TFTP state is ready for the installation process.
  7. Once the host has completed installation, the OS specific installation script should inform foreman by retrieving the built URL.
  8. The host-specific TFTP configuration file is deleted.
  9. 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:

  1. at least 1 host is put in build mode
  2. 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.

4.3.11 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 Security Communciations 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.

[main]
privatekeydir = $ssldir/private_keys { group = service }
hostprivkey = $privatekeydir/$certname.pem { mode = 640 }
Configuring the proxy

Configure the locations to the SSL files in /etc/foreman-proxy/settings.yml, plus the list of trusted Foreman hosts:

: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

:trusted_hosts:
- foreman.corp.com
#- foreman.dev.domain
Generating a certificate

To generate a certificate for a proxy host that isn’t managed by Puppet, do the following:

  1. Generate a new certificate on your puppetmaster: puppet cert --generate <proxy-FQDN>
  2. Copy the certificates and key from the puppetmaster to the smart proxy in /etc/foreman-proxy:<ol>
  • /var/lib/puppet/ssl/certs/ca.pem
  • /var/lib/puppet/ssl/certs/proxy-FQDN.pem
  • /var/lib/puppet/ssl/private_keys/proxy-FQDN.pem
  • </ol>

    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.12 Libvirt

    In this chapter, we will describe how to setup DHCP and DNS for use with the virsh provider for libvirt.

    This provider is able to change DHCP and DNS settings in libvirt with dnsmasq. This is done via the virsh command. These settings can be for only a single session, or persistent on the libvirt instance.

    The provider is intended for development setups where libvirt is usually used. With simple steps, one can configure full provisioning on a box with libvirt.

    This provider is not recommended for production use.

    Configuration of libvirt

    Define the TFTP root first. Edit ‘default’ virtual network and add ‘tftp’, ‘bootp’ and ‘domain’ elements.

    <network>
     <name>default</name>
     <uuid>16b7b280-7462-428c-a65c-5753b84c7545</uuid>
     <forward mode='nat'/>
     <bridge name='virbr0' stp='on' delay='0' />
     <domain name="local.lan"/>
     <dns>
     </dns>
     <mac address='52:54:00:a6:01:5d'/>
     <ip address='192.168.122.1' netmask='255.255.255.0'>
       <tftp root='/var/tftproot' />
       <dhcp>
         <range start='192.168.122.2' end='192.168.122.254' />
         <bootp file='pxelinux.0' />
       </dhcp>
     </ip>
    </network>
    

    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:

    mkdir -p /var/tftproot/{boot,pxelinux.cfg}
    yum -y install syslinux
    cp /usr/share/syslinux/{pxelinux.0,menu.c32,chain.c32} /var/tftproot
    chown -R foreman-proxy:nobody /var/tftproot
    find /var/tftproot/ -type d | xargs chmod g+s
    

    Configuration of smart-proxy

    Configure smart-proxy in config/settings.yaml file:

    • enable tftp
    • set correct tftp boot and set explicit tftp_servername
    • enable dns virsh provider
    • enable dhcp virsh provider
    • check virsh_network name (default in our case)

    Important configuration values are (examples):

    :tftp: true
    :tftproot: /var/tftproot
    :tftp_servername: 192.168.122.1
    :dns: true
    :dns_provider: virsh
    :dhcp: true
    :dhcp_vendor: virsh
    :virsh_network: default
    

    Make sure the user foreman proxy will be running with has sudo and virsh commands available and password is not required for virsh command. Also make sure sudo does not require tty. An example /etc/sudoers configuration:

    Defaults !requiretty
    foreman-proxy ALL = NOPASSWD : /usr/bin/virsh
    

    Or for those who are running foreman-proxy under different user:

    %users ALL = NOPASSWD : /usr/bin/virsh
    

    Additional steps

    Make sure the DNS server is configured with the foreman instance by setting /etc/resolv.conf file or changing this in NetworkManager or dnsmasq configuration. Example:

    cat /etc/resolv.conf
    nameserver 8.8.8.8
    nameserver 8.8.4.4
    nameserver 192.168.122.1
    

    Foreman is now configured for libvirt provisioning, this is the recommended setup for git development checkouts. There is one limitation though, reverse DNS entries are not created (libvirt XML does not support them).

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

    Template Kinds

    There are 6 template kinds:

    • PXELinux - Deployed to the TFTP server to ensure the Host boots the correct installer with the correct kernel options
    • Provision - The main unattended installation file; e.g. Kickstart or Preseed
    • 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

    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

    Clicking a template will take you to the edit page. All templates are ERB-enabled, and you can access many variables about the to-be-installed-host within the template. See Template Writing for ideas.

    As noted in 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 PXELinux, 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.

    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.

    Dynamic Partition tables

    When creating a new Host, you will be given the option to create a Dynamic 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.

    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.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.1 Usage Examples

    Basic help and list of supported commands:

    $ hammer -h
    Usage:
        hammer [OPTIONS] SUBCOMMAND [ARG] ...
    
    Parameters:
        SUBCOMMAND                    subcommand
        [ARG] ...                     subcommand arguments
    
    Subcommands:
        shell                         Interactive Shell
        architecture                  Manipulate Foreman's architectures.
        global_parameter              Manipulate Foreman's global parameters.
        compute_resource              Manipulate Foreman's compute resources.
        domain                        Manipulate Foreman's domains.
        environment                   Manipulate Foreman's environments.
        fact                          Search Foreman's facts.
        report                        Browse and read reports.
        puppet_class                  Browse and read reports.
        host                          Manipulate Foreman's hosts.
        hostgroup                     Manipulate Foreman's hostgroups.
        location                      Manipulate Foreman's locations.
        medium                        Manipulate Foreman's installation media.
        model                         Manipulate Foreman's hardware models.
        os                            Manipulate Foreman's operating system.
        organization                  Manipulate Foreman's organizations.
        partition_table               Manipulate Foreman's partition tables.
        proxy                         Manipulate Foreman's smart proxies.
        subnet                        Manipulate Foreman's subnets.
        template                      Manipulate Foreman's config templates.
        user                          Manipulate Foreman's users.
    
    Options:
        -v, --verbose                 be verbose
        -c, --config CFG_FILE         path to custom config file
        -u, --username USERNAME       username to access the remote system
        -p, --password PASSWORD       password to access the remote system
        --version                     show version
        --show-ids                    Show ids of associated resources
        --csv                         Output as CSV (same as --adapter=csv)
        --output ADAPTER              Set output format. One of [base, table, silent, csv]
        --csv-separator SEPARATOR     Character to separate the values
        -P, --ask-pass                Ask for password
        --autocomplete LINE           Get list of possible endings
        -h, --help                    print help

    First level command help:

    $ hammer architecture -h
    Usage:
        hammer architecture [OPTIONS] SUBCOMMAND [ARG] ...
    
    Parameters:
        SUBCOMMAND                    subcommand
        [ARG] ...                     subcommand arguments
    
    Subcommands:
        list                          List all architectures.
        info                          Show an architecture.
        create                        Create an architecture.
        delete                        Delete an architecture.
        update                        Update an architecture.
        add_operatingsystem           Associate a resource
        remove_operatingsystem        Disassociate a resource
    
    Options:
        -h, --help                    print help

    Second level command help:

    $ hammer architecture create -h
    Usage:
        hammer architecture create [OPTIONS]
    
    Options:
        --name NAME                    
        --operatingsystem-ids OPERATINGSYSTEM_IDS 
                                      Operatingsystem ID’s
        -h, --help                    print help

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

    • create smart proxy
    hammer proxy create --name myproxy --url https://proxy.my.net:8443
    
    • create architecture
    hammer architecture create --name x86_64
    
    • create new subnet
    hammer subnet create --name "My Net" --network "192.168.122.0" --mask "255.255.255.0" --gateway "192.168.122.1" --dns-primary "192.168.122.1"
    
    • import existing subnet from a proxy

      missing, see #3355

    • create new domain

    hammer domain create --name "my.net" --fullname "My network"
    
    • associate domain with proxy
    hammer domain update --id 1 --dns-id 1
    
    • associate subnet with domain
    hammer subnet update --id 1 --domain-ids 1
    
    • associate subnet with proxy (DHCP, TFTP, DNS)
    hammer subnet update --id 1 --dhcp-id 1 --tftp-id 1 --dns-id 1
    
    • create new partition table
    hammer partition_table create --name "Redhat test" --file /tmp/rh_test.txt
    
    • create new OS
    hammer os create --name RHEL --major 6 --minor 4
    
    • create new template
    hammer template create --name "kickstart mynet" --type provision --file /tmp/ks.txt
    
    • edit existing pre-defined template
    hammer template dump --id 4 > /tmp/ks.txt
        vim /tmp/ks.txt
    hammer template update --id 4 --file /tmp/ks.txt
    
    • associate applicable OS with pre-defined template
    hammer template update --id 1 --operatingsystem-ids 1
    

    Listing associated OS’s is still missing - see #3360

    • associate OS with architecture
    hammer os update --id 1 --architecture-ids 1
    
    • associate OS with part table
    hammer os update --id 1 --ptable-ids 1
    
    • associate OS with install media
    hammer os update --id 1 --medium-ids 1
    
    • associate OS with install provision and pxelinux templates

      Missing, needs investigation, may be related to #3360

    • create libvirt compute resource

    hammer compute_resource create --name libvirt --url "qemu:///system" --provider Libvirt
    
    • import puppet classes

      missing - see #3035

    • and finally create a bare metal host entry

      works with some options, needs improvements - see #3063

    5. Advanced Foreman

    5.1 API

    API v1 is the default version for Foreman 1.6, but API v2 is stable and recommended. Future versions of Foreman will change the default version, eventually deprecating and removing v1.

    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.

     

    Show a Collection of Objects

    Get of a collection of domains: GET /api/domains

    Send a HTTP GET request. No JSON data hash is required.

    $ curl -k -u admin:changeme -H "Accept: version=2,application/json" https://foreman.example.com/api/domains
    

    This returns a collection JSON response. The format for a collection response is described in Section 5.1.2.

     

    Show a Single Object

    Get a single domain: GET /api/domains/:id or GET /api/domains/:name

    Send a HTTP GET request with the object’s unique identifier, either :id or :name. No JSON data hash is required.

    $ curl -k -u admin:changeme -H "Accept: version=2,application/json" \
        https://foreman.example.com/api/domains/42
    # or
    $ curl -k -u admin:changeme -H "Accept: version=2,application/json" \
        https://foreman.example.com/api/domains/foo
    

    This returns a single object in JSON format. The format for a single object response is described in Section 5.1.3.

     

    Create an Object

    Create a new domain: POST /api/domains

    Send a HTTP POST request with a JSON data hash containing the required fields to create the object. In this example, a domain is being created.

    $ curl -k -u admin:changeme -H "Accept: version=2,application/json" -H "Content-Type: application/json" \
        -X POST -d '{ "name":"foo.bar.com","fullname":"foo.bar.com description" }' \
        https://foreman.example.com/api/domains
    

    This returns the newly created object in JSON format. The format for a single object response is described in Section 5.1.3.

     

    Update an Object

    Update a domain: PUT /api/domains/:id or PUT /api/domains/:name

    Send a HTTP PUT request with the object’s unique identifier, 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.

    $ curl -k -u admin:changeme -H "Accept: version=2,application/json" -H "Content-Type: application/json" \
        -X PUT -d '{ "name": "a new name" }' https://foreman.example.com/api/domains/12
    # or
    $ curl -k -u admin:changeme -H "Accept: version=2,application/json" -H "Content-Type: application/json" \
        -X PUT -d '{ "name": "a new name" }' https://foreman.example.com/api/domains/foo
    

    This returns the newly updated object in JSON format. The format for a single object response is described in Section 5.1.3.

     

    Delete an Object

    Delete a domain: DELETE /api/domains/:id or DELETE /api/domains/:name

    Send a HTTP DELETE request with the object’s unique identifier, either :id or :name. No JSON data hash is required.

    $ curl -k -u admin:changeme -H "Accept: version=2,application/json" -X DELETE \
        https://foreman.example.com/api/domains/17
    # or
    $ curl -k -u admin:changeme -H "Accept: version=2,application/json" -X DELETE \
        https://foreman.example.com/api/domains/foo
    

    This returns the deleted object in JSON format. The format for a single object response is described in Section 5.1.3.

    5.1.2 JSON Response Format for Collections

    Collections are a list of objects (i.e. hosts, domains, etc). The format for a collection JSON response consists of a results root node and metadata fields total, subtotal, page, per_page. Note: for Katello objects, the metadata includes limit, offset instead of page, per_page.

    Below is an example of the format for a collection JSON response for a list of domains: GET /api/domains

    {
        "total": 3,
        "subtotal": 3,
        "page": 1,
        "per_page": 20,
        "search": null,
        "sort": {
            "by": null,
            "order": null
        },
        "results": [
            {
                "id": 23,
                "name": "qa.lab.example.com",
                "fullname": "QA",
                "dns_id": 10,
                "created_at": "2013-08-13T09:02:31Z",
                "updated_at": "2013-08-13T09:02:31Z"
            },
            {
                "id": 25,
                "name": "sat.lab.example.com",
                "fullname": "SATLAB",
                "dns_id": 8,
                "created_at": "2013-08-13T08:32:48Z",
                "updated_at": "2013-08-14T07:04:03Z"
            },
            {
                "id": 32,
                "name": "hr.lab.example.com",
                "fullname": "HR",
                "dns_id": 8,
                "created_at": "2013-08-16T08:32:48Z",
                "updated_at": "2013-08-16T07:04:03Z"
            }
        ]
    }
    

    The response metadata fields are described below:

    • total - total number of objects without any search parameters
    • 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 unique 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

    {
        "id": 23,
        "name": "qa.lab.example.com",
        "fullname": "QA",
        "dns_id": 10,
        "created_at": "2013-08-13T09:02:31Z",
        "updated_at": "2013-08-13T09:02:31Z"
    }
    

    5.1.4 Customize JSON Responses

    Customize Root Node for Collections

    The default root node name for collections is results but can be changed.

    To change the root node name per API request, pass root_name= as a URL parameter. See example below:

    $ curl -k -u admin:changeme -H "Accept: version=2,application/json" \
        https://foreman.example.com/api/domains?root_name=data
    

     

    Customize Root Node for Single Object

    There is no root node as the default for single object JSON responses, but it can be added.

    To change the object’s root node name per API request, pass object_name= as a URL parameter. See example below:

    $ curl -k -u admin:changeme -H "Accept: version=2,application/json" \
        https://foreman.example.com/api/domains/23?object_name=record
    

     

    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:

    $ curl -k -u admin:changeme -H "Accept: version=2,application/json" \
        https://foreman.example.com/api/domains?page=2
    

    The example above will show the remaining 7 objects in our example of 27 objects in the collection.

    To increase or decrease the number of objects per response, pass per_page= as a URL parameter. See example below:

    $ curl -k -u admin:changeme -H "Accept: version=2,application/json" \
        https://foreman.example.com/api/domains?per_page=1000
    

    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:

    $ curl -k -u admin:changeme -H "Accept: version=2,application/json" \
        https://foreman.example.com/api/domains?search=name%3Dexample.com
    

    The number of objects returned will be shown in the subtotal metadata field, and the query string will be shown in the search metadata field.

     

    Custom Sort of Collections Per Response

    Custom sort order per collection can be specified by passing order= as a URL parameter. See example below:

    $ curl -k -u admin:changeme -H "Accept: version=2,application/json" \
        https://foreman.example.com/api/domains?order=name+DESC
    

    The default sort order is ascending (ASC) if only a field name is passed. The sort parameters will be shown in sort by and order metadata fields.

    5.1.5 Nested API routes

    The goal is to implement nested routes for all objects as an alternative to filtering collections.

    For example, rather then filtering subnets by a specified domain using a search string

    $ GET /api/subnets?search=name%3Dqa.lab.example.com
    

    the alternative nested route below returns the same result as the above.

    $ GET /api/domains/qa.lab.example.com/subnets
    

    All actions will be accessible in the nested route as in the main route.

    5.1.6 API Versioning

    The default API version is v1 for Foreman 1.6.

    There are two methods of selecting API v2:

    1. In the header, pass Accept: application/json,version=2

    2. In the URL, pass /v2/ such as GET /api/v2/hosts

    Similarly, when API version v2 becomes the default, v1 can still be used by passing Accept: application/json,version=1 in the header or api/v1/ in the URL.

    5.1.7 Handling Associations

    Updating and creating associations are done in a few different ways in the API depending on the type of association.

    One-to-One and One-to-Many

    To update a one-to-one or a one-to-many association, simply set the name or id on the object. For example, to set a host group for a host, simply set the hostgroup_name or hostgroup_id of the host.

    $ curl -k -u admin:changeme -H "Accept: version=2,application/json" \
        -H "Content-Type: application/json" -X POST \
        -d '{ "hostgroup_name": "telerin" }' \
        https://foreman.example.com/api/hosts/celeborn.firstage
    
    $ curl -k -u admin:changeme -H "Accept: version=2,application/json" \
        -H "Content-Type: application/json" -X POST \
        -d '{ "hostgroup_id": 42 }' \
        https://foreman.example.com/api/hosts/celeborn.firstage
    

    Many-to-One and Many-to-Many

    To update an association for an object that contains a collection of other objects, there are a few options. First you can set the names or ids:

    $ curl -k -u admin:changeme -H "Accept: version=2,application/json" \
        -H "Content-Type: application/json" -X POST \
        -d '{ "host_names": ["enel.first", "celeborni.first", "elwe.first"] }' \
        https://foreman.example.com/api/hostgroups/telerin
    
    $ curl -k -u admin:changeme -H "Accept: version=2,application/json" \
        -H "Content-Type: application/json" -X POST \
        -d '{ "host_ids": [4, 5, 6] }' \
        https://foreman.example.com/api/hostgroups/telerin
    

    This will set the host group’s hosts to enel, celeborn, and elwe (or 4, 5, 6) and only those.

    Alternatively, you can pass in a set of objects:

    $ curl -k -u admin:changeme -H "Accept: version=2,application/json" \
        -H "Content-Type: application/json" -X POST \
        -d '{ "domains": [{ "name": "earendil", "id": 1}, { "name": "turgon", "id": 3 }] }' \
        https://foreman.example.com/api/subnets/iluvatar
    

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

    Provider Package Unattended installation Image-based Console Power management
    EC2 foreman-compute no yes read-only yes
    Google Compute Engine foreman-gce no yes no yes
    Libvirt foreman-libvirt yes yes VNC or SPICE yes
    OpenStack Nova foreman-compute no yes no yes
    oVirt / RHEV foreman-ovirt yes yes VNC or SPICE yes
    Rackspace foreman-compute no yes no yes
    VMware foreman-vmware yes yes VNC yes

    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.

    5.2.1 Using Compute Resources

    The following steps describe how to configure a compute resource and provision new hosts on it.

    1. Ensure the necessary package for the provider (from the above table) is installed, e.g. yum -y install foreman-ovirt. Restart the Foreman application to complete installation.

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

    3. Click the Test Connection button after entering the configuration. If no error is displayed, the test was successful.

    4. After saving the compute resource, existing virtual machines can be browsed by clicking on the compute resource and the Virtual Machines tab.

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

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

    1. When viewing a host, power management controls and the console access button are in the top right hand corner of the page.

    2. If a host provisioned on a compute resource is deleted, the VM and associated storage on the compute resource will also be deleted.

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

    Profile List

    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.

    Profile Edit

    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.

    EC2

    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.

    Libvirt

    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.

    Primary Tab

    Once the profile is selected, the Virtual Machine tab will automatically update to use the defaults configured in the “1-Small” profile.

    VM Tab

    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).
    • Enabling use_uuid_for_certificates in Administer > Settings is recommended for consistent Puppet certificate IDs instead of hostnames.
    • VPC subnets and security groups can be selected on the Network tab when creating a host.
    • The Managed IP dropdown menu allows selection between using the public and private IP address for communication from Foreman to the instance.
    • 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 EC2 provisioning is given on the Foreman blog: EC2 provisioning using Foreman.

    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/yourkey.p12 to
    • Specify the location on the foreman server as the certificate path value e.g /usr/share/foreman/yourkey.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.
    • Enabling use_uuid_for_certificates in Administer > Settings is recommended for consistent Puppet certificate IDs instead of hostnames.
    • The External IP checkbox means the public IP address (rather than private IP) will be used for communication with the instance from Foreman.

    5.2.5 Libvirt Notes

    • Currently only supports KVM hypervisors.
    • VM consoles will be configured by default to listen on 0.0.0.0, change this via libvirt_default_console_address in Administer > Settings > Provisioning.
    • libvirt’s DNS and DHCP server (dnsmasq) can be disabled and replaced by BIND and ISC DHCPD (managed by Foreman) by creating a new virtual network and disabling DHCP support.

    Connections

    To connect to the hypervisor using SSH:

    1. Configure SSH keys (ssh-keygen) for the ‘foreman’ user on the Foreman host to connect fully automatically to the remote hypervisor host.
    2. Change to the ‘foreman’ user, test the connection and ensure the remote host has been trusted.
    3. If connecting to the hypervisor as a non-root user, set up PolicyKit to permit access to libvirt. Note that different versions of PolicyKit have different configuration formats. 1, 2.
    4. Add the compute resource with a URL following one of these examples:
      • qemu+ssh://root@hypervisor.example.com/system to use the remote ‘root’ account
      • qemu+ssh://hypervisor.example.com/system to use the remote ‘foreman’ account

    The first two steps above can be done with something like:

    root# mkdir /usr/share/foreman/.ssh
    root# chmod 700 /usr/share/foreman/.ssh
    root# chown foreman:foreman /usr/share/foreman/.ssh
    

    When using SELinux make sure the directory and the files have correct labels of ssh_home_t:

    ls /usr/share/foreman/.ssh -Zd
    drwx------. foreman foreman system_u:object_r:ssh_home_t:s0  /usr/share/foreman/.ssh
    ls /usr/share/foreman/.ssh -Z
    -rw-------. foreman foreman unconfined_u:object_r:ssh_home_t:s0 id_rsa
    -rw-r--r--. foreman foreman unconfined_u:object_r:ssh_home_t:s0 id_rsa.pub
    -rw-r--r--. foreman foreman unconfined_u:object_r:ssh_home_t:s0 known_hosts
    

    If not, restore the context:

    restorecon -RvF /usr/share/foreman/.ssh
    

    To connect to the hypervisor over TCP without authentication or encryption (not recommended):

    1. Set the following options in libvirtd.conf:
      • listen_tls = 0
      • listen_tcp = 1
      • auth_tcp = "none"
    2. Enable libvirtd listening, e.g. set LIBVIRTD_ARGS="--listen" in /etc/sysconfig/libvirtd
    3. Add the compute resource with a URL following this example:
      • qemu+tcp://hypervisor.example.com:16509/system

    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:

    • Images refer to backing disks (usually qcow2) - create a disk containing the OS image in the libvirt storage pool.
    • 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.
    • 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.
    • Ensure the image is not modified as long as hosts exists that are using it, or they will suffer data corruption.

    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.

    5.2.8 Rackspace Notes

    • The compute resource URL refers to the identity API URL, e.g. https://identity.api.rackspacecloud.com/v2.0

    A full example for configuring image-based provisioning is given on the Foreman blog, also applicable to Rackspace: EC2 provisioning using Foreman.

    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.

    Console access

    Consoles are provided using VNC connections from Foreman to the ESX server, which requires a firewall change to open the respective ports (TCP 5910 to 5930)

    ssh root@esx-srv
    vi /etc/vmware/firewall/vnc.xml

    Add the following file content:

    <ConfigRoot>
    <service id='0032'>
     <id>VNC</id>
     <rule id = '0000'>
      <direction>inbound</direction>
      <protocol>tcp</protocol>
      <porttype>dst</porttype>
      <port>
       <begin>5910</begin>
       <end>5930</end>
      </port>
     </rule>
     <enabled>true</enabled>
    </service>
    </ConfigRoot>

    Apply and check the firewall rule:

    esxcli network firewall refresh
    esxcli network firewall ruleset list | grep VNC

    Lastly, make the rule persistent:

    cp /etc/vmware/firewall/vnc.xml /vmfs/volumes/datastore1/vnc.xml
    vi /etc/rc.local
    # At end of file:
    cp /vmfs/volumes/datastore1/vnc.xml /etc/vmware/firewall/
    esxcli network firewall refresh
    • 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.3 Install Locations

    Missing content. Consider contributing, you kind soul!

    5.4 Securing Communications with SSL

    The Foreman web application needs to communicate securely with associated smart proxies and puppet masters, plus users and applications connecting to the web interface. This section details recommended SSL configurations.

    5.4.1 Securing Puppet Master Requests

    In a typical ENC-based setup with reporting, puppet masters require access to Foreman for three tasks:

    1. Retrieval of external nodes information (classes, parameters)
    2. Uploading of host facts
    3. 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, Auth:

    • require_ssl_puppetmasters (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_puppetmasters (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_puppetmasters 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.

    1. Set Foreman’s require_ssl_puppetmasters, restrict_registered_puppetmasters and require_ssl to true.
    2. The mod_ssl configuration must contain:
    1. *SSLCACertificateFile* set to the Puppet CA
    2. *SSLVerifyClient optional*
    3. *SSLOptions +StdEnvVars*
    1. ENC script (e.g. /etc/puppet/node.rb) should have these settings:
    1. *:ssl_ca* set to the Puppet CA
    2. *:ssl_cert* set to the puppet master's certificate
    3. *:ssl_key* set to the puppet master's private key
    1. Report processor (e.g. /usr/lib/ruby/site_ruby/1.8/puppet/reports/foreman.rb) should have these settings:
    1. *$foreman_ssl_ca* set to the Puppet CA
    2. *$foreman_ssl_cert* set to the puppet master's certificate
    3. *$foreman_ssl_key* set to the puppet master's private key
    Troubleshooting

    Warning messages will be printed to Foreman’s log file (typically /var/log/foreman/production.log) when SSL-based authentication fails.

    • 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’s DN and verification status. mod_ssl’s SSLOptions +StdEnvVars setting enables this. Variable names are defined by 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.

    1. Set restrict_registered_puppetmasters to true.
    2. Set require_ssl_puppetmasters 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.

    1. Set require_ssl_puppetmasters, restrict_registered_puppetmasters 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 https://projects.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.

    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.

    [main]
    privatekeydir = $ssldir/private_keys { group = service }
    hostprivkey = $privatekeydir/$certname.pem { mode = 640 }
    

    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

    The pg_dump command can be used to backup the contents of a PostgreSQL database to a text file. The most reliable way of backing up PostgreSQL database is:

    su postgres -c "pg_dump -Fc foreman > foreman.dump"
    

    MySQL database

    The mysqldump command can be used to backup the contents of your MySQL database to a text file.

    mysqldump --opt foreman > foreman.sql
    

    Please follow MySQL documentation about other options for doing backups.

    SQLite database

    To backup SQLite database perform this simple step:

    sqlite3 /path/to/foreman/db/production.db .dump > foreman.dump
    

    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 lest verify the integrity of the created archive using sqlite3 command. The dump command above is preferred.

    Configuration

    On Red Hat compatible systems issue the following command to backup whole /etc directory structure:

    tar --selinux -czvf etc_foreman_dir.tar.gz /etc/foreman
    

    For all other distribution do similar command:

    tar -czvf etc_foreman_dir.tar.gz /etc/foreman
    

    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
    

    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

    The pg_restore command can be used to recover contents of your PostgreSQL database from the database dump. The most reliable way PostgreSQL database is:

    su postgres -c "pg_restore -C -d postgres foreman.dump"
    

    MySQL database

    The mysql command can be used to recover contents of your MySQL database from the database dump in SQL format.

    mysql < dump.sql
    

    Please follow MySQL documentation about other options for data recovery.

    SQLite database

    To recover from SQLite dump perform this simple step:

    sqlite3 /path/to/foreman/db/production.db < foreman.dump
    

    It is possible just to copy db file, but Foreman instance must be stopped.

    Configuration

    On Red Hat compatible systems issue the following command to restore whole /etc directory structure:

    tar --selinux -xzvf etc_foreman_dir.tar.gz -C /
    

    For all other distribution do similar command:

    tar -xzvf etc_foreman_dir.tar.gz -C /
    

    It is recommended to extract files to an empty directory first and inspect the content before overwriting current files (change -C option to an empty directory).

    Puppet master

    On the puppet master node, issue the following command to restore Puppet certificates on Red Hat compatible systems

    tar --selinux -xzvf var_lib_puppet_dir.tar.gz -C /
    

    For all other distribution do similar command:

    tar -xzvf var_lib_puppet_dir.tar.gz -C /
    

    It is recommended to inspect the content of the restore first (see above).

    DHCP, DNS and TFTP services

    Depending on used software packages, perform recovery of important data and configuration files according to the documentation. This depends on the software and distribution that is in use.

    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
    Source installations

    As the user running Foreman and in the source directory, execute:

    RAILS_ENV=production bundle exec rails c
    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.

    Some of required packages may not be available in older RHEL versions. You can get them from Jan Pazdziora’s copr yum repo at http://copr.fedoraproject.org/coprs/adelton/identity_demo/ .

    foreman-installer --foreman-ipa-authentication=true --foreman-configure-ipa-repo=true

    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:

    foreman-installer --foreman-ipa-authentication=true --foreman-pam-service=<pam_service_name>

    For more information about HBAC configuration see section below.

    5.7.2 HBAC configuration

    We suppose that the Foreman machine is FreeIPA-enrolled and HTTP/<the-foreman-fqdn> service has been created on FreeIPA server.

    At first we create HBAC (host-based access control) service and rule on the FreeIPA server. In the following examples, we will use the PAM service name foreman-prod.

    On the FreeIPA server, we define the HBAC service and rule and link them together:

    ipa hbacsvc-add foreman-prod
    ipa hbacrule-add allow_foreman_prod
    ipa hbacrule-add-service allow_foreman_prod --hbacsvcs=foreman-prod

    Then we add user we wish to have access to the service foreman-prod, and the hostname of our Foreman server:

    ipa hbacrule-add-user allow_foreman_prod --user=<username>
    ipa hbacrule-add-host allow_foreman_prod --hosts=<the-foreman-fqdn>

    Alternatively, host groups and user groups could be added to the allow_foreman_prod rule.

    At any point of the configuration, we can check the status of the rule:

    ipa hbacrule-find foreman-prod
    ipa hbactest --user=<username> --host=<the-foreman-fqdn> --service=foreman-prod

    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:

    setsebool -P allow_httpd_mod_auth_pam on
    setsebool -P httpd_dbus_sssd on

    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:

    wget -O /etc/yum.repos.d/adelton-identity_demo.repo \
      https://copr.fedoraproject.org/coprs/adelton/identity_demo/repo/epel-6/adelton-identity_demo-epel-6.repo

    Get the keytab for the service and set correct permissions (we assume the FreeIPA server is ipa.example.com, adjust to match your setup):

    kinit admin
    ipa-getkeytab -s $(awk '/^server =/ {print $3}' /etc/ipa/default.conf) -k /etc/http.keytab -p HTTP/$( hostname )
    chown apache /etc/http.keytab
    chmod 600 /etc/http.keytab

    Install mod_auth_kerb and mod_authnz_pam:

    yum install -y mod_auth_kerb mod_authnz_pam

    Configure the module to be used by Apache (we assume the realm is EXAMPLE.COM, adjust to match your setup):

    # add to /etc/httpd/conf.d/auth_kerb.conf
    LoadModule auth_kerb_module modules/mod_auth_kerb.so
    LoadModule authnz_pam_module modules/mod_authnz_pam.so
    <Location /users/extlogin>
      AuthType Kerberos
      AuthName "Kerberos Login"
      KrbMethodNegotiate On
      KrbMethodK5Passwd Off
      KrbAuthRealms EXAMPLE.COM
      Krb5KeyTab /etc/http.keytab
      KrbLocalUserMapping On
      # require valid-user
      require pam-account foreman-prod
      ErrorDocument 401 '<html><meta http-equiv="refresh" content="0; URL=/users/login"><body>Kerberos authentication did not pass.</body></html>'
      # The following is needed as a workaround for https://bugzilla.redhat.com/show_bug.cgi?id=1020087
      ErrorDocument 500 '<html><meta http-equiv="refresh" content="0; URL=/users/login"><body>Kerberos authentication did not pass.</body></html>'
    </Location>

    We tell Foreman that it is OK to trust the authentication done by Apache by adding to /etc/foreman/settings.yaml or under Administer > Settings > General:

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

    LoadModule intercept_form_submit_module modules/mod_intercept_form_submit.so
    LoadModule authnz_pam_module modules/mod_authnz_pam.so
    <Location /users/login>
      InterceptFormPAMService foreman-prod
      InterceptFormLogin login[login]
      InterceptFormPassword login[password]
    </Location>

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

    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:

    yum install -y sssd-dbus mod_lookup_identity

    Amend the configuration of sssd in /etc/sssd/sssd.conf:

    # /etc/sssd/sssd.conf, the [domain/...] section, add:
    ldap_user_extra_attrs = email:mail, firstname:givenname, lastname:sn
    
    # /etc/sssd/sssd.conf, the [sssd] section, amend the services line to include ifp:
    services = nss, pam, ssh, ifp
    
    # /etc/sssd/sssd.conf, add new [ifp] section:
    [ifp]
    allowed_uids = apache, root
    user_attributes = +email, +firstname, +lastname

    Configure Apache to retrieve these attributes, for example in /etc/httpd/conf.d/lookup_identity.conf:

    LoadModule lookup_identity_module modules/mod_lookup_identity.so
    <LocationMatch ^/users/(ext)?login$>
      LookupUserAttr email REMOTE_USER_EMAIL " "
      LookupUserAttr firstname REMOTE_USER_FIRSTNAME
      LookupUserAttr lastname REMOTE_USER_LASTNAME
      LookupUserGroupsIter REMOTE_USER_GROUP
    </LocationMatch>

    Restart both sssd and Apache:

    service sssd restart
    service httpd restart

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

    # in /etc/httpd/conf.d/auth_kerb.conf
    <Location /users/extlogin>
      AuthType Kerberos
      ...
      KrbLocalUserMapping Off
    </Location>

    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:

    # in /etc/httpd/conf.d/intercept_form_submit.conf
    <Location /users/login>
      ...
      InterceptFormLoginRealms EXAMPLE.COM
    </Location>

    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.

    6. Plugins

    Plugins are tools to extend and modify the functionality of Foreman. The core of Foreman is designed to be lean, to maximize flexibility and minimize code bloat. Plugins offer custom functions and features so that each user can tailor their environment to their specific needs. Foreman plugins are implemented as rail engines that are packaged as gems and thus easily installed into Foreman.

    6.1 Install a Plugin

    Foreman plugins are implemented as gems in Ruby on Rails. See below for the different installation methods, which depend on your platform.

    RPM installations

    A limited number of plugins are available fully packaged from our yum repositories for ease of use. The number of these is increasing, so check the wiki to see if a package is available yet. If it’s a useful or popular plugin and not yet packaged, please file a feature request in the packaging project. The repos are available at yum.theforeman.org/plugins. Separate repos are available for each Foreman release, containing plugins that are compatible with that particular version. Packages are not currently GPG signed.

    Configure the repo by creating /etc/yum.repos.d/foreman_plugins.repo:

    [foreman-plugins]
    name=Foreman plugins
    baseurl=http://yum.theforeman.org/plugins/1.6/el6/x86_64/
    enabled=1
    gpgcheck=0
    

    Find the package for the plugin: <pre>yum search rubygem-foreman</pre> Install the package, e.g. <pre>yum install ruby193-rubygem-foreman_discovery</pre> Restart Foreman with service foreman restart

    Some plugins (e.g. foreman_column_view) may also require configuration in /usr/share/foreman/config/settings.plugins.d/, check for any .example files.

    Debian installations

    A limited number of plugins are available fully packaged from our deb repositories for ease of use. The number of these is increasing, so check the list of plugins to see if a Debian package is available yet. If it’s a useful or popular plugin and not yet packaged, please file a feature request in the packaging project.

    The repo is available at http://deb.theforeman.org plugins <component>. Separate repos are available for each Foreman release, containing plugins that are compatible with that particular version. They are signed with the Foreman APT key.

    1. Add a source line like this: deb http://deb.theforeman.org/ plugins 1.6 to Apt
    2. Find the package for the plugin: apt-cache search ruby-foreman
    3. Install the package, e.g. apt-get install ruby-foreman-discovery
    4. Restart Foreman: touch ~foreman/tmp/restart.txt or service apache2 restart

    Some plugins (e.g. foreman_column_view) may also require configuration in /usr/share/foreman/config/settings.plugins.d/, check for any .example files.

    Advanced: installing from gems

    Not recommended, as it’s possible for the ‘gem’ command to try and install newer versions of Rails which can cause problems. Do note the install without dependencies below to avoid this problem. Ensure the plugin you want is available from rubygems.org as a gem. Plugins that aren’t published (just git repos) can’t be installed with this method without being built as a gem.

    If on EL6, run <pre>scl enable ruby193 bash</pre> first for an SCL-enabled shell (not needed on Fedora) Install without dependencies: <pre>gem install –ignore-dependencies foreman_column_view</pre> If you need other dependencies (see the rubygems.org page), check the yum repo above (e.g. deface, nokogiri) or install the same way with ‘gem’ Add to the bundler.d/Gemfile.local.rb file as detailed below.

    Restart Foreman with service foreman restart

    If you hit problems, uninstall the added gems with <pre>gem uninstall -v VERSION GEM</pre>

    Debian package or “from source” installations

    It is recommended to use ~foreman/bundler.d/Gemfile.local.rb so that it is not overwritten by future upgrades. If it’s published on rubygems.org, just add the name and the latest released version will be downloaded. Add to bundler.d/Gemfile.local.rb:

    gem 'foreman_sample_plugin'

    Or bundler can install the plugin from a git repository. Add to bundler.d/Gemfile.local.rb:

    gem 'foreman_sample_plugin', :git => "https://github.com/example/foreman_sample_plugin.git"

    Next, as a Foreman user (not root), run the following command:

    $ bundle update foreman_sample_plugin

    Then restart Foreman with touch ~foreman/tmp/restart.txt

    6.2 Plugin List

    An up-to-date plugin list is kept in the wiki

    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.

    Known issues

    • Currently only unencrypted connections are possible, even if you connect to Foreman via HTTPS.
    • 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. Same goes for Chrome, to fix it, go to chrome://flags/ and enable Allow insecure WebSocket from https origin

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

    7.2 Getting Help

    Please check the Troubleshooting wiki page for solutions to the most common problems. Otherwise, there are two primary methods of getting support for the Foreman: IRC and mailing lists.

    IRC

    We work on the libera.chat servers. You can get general support in #theforeman, while development chat takes place in #theforeman-dev.

    Mailing lists

    Mailing lists are available via Google Groups. Much like IRC, we have a general users (support, Q/A, etc) lists and a development list:

    Foreman 3.13.0 has been released! Follow the quick start to install it.

    Foreman 3.12.1 has been released! Follow the quick start to install it.