11.4. Storing and Maintaining Host Information
Red Hat Satellite 6 uses a combination of applications to gather information about managed hosts and to ensure that those hosts are maintained in the desired state. These applications include:
- Foreman: Provides for the provisioning and life cycle management of physical and virtual systems. Foreman automatically configures these systems using various methods, including kickstart and Puppet modules.
- Puppet: A client/server architecture for configuring hosts, consisting of the Puppet Master (server) and the Puppet Agent (client).
- Facter: Puppet's system inventory tool. Facter gathers basic information (facts) about hosts such as hardware details, network settings, OS type and version, IP addresses, MAC addresses, SSH keys, and more. These facts are then made available in Puppet manifests as variables.
The use of Puppet, Facter, and facts is discussed in more detail below.
11.4.1. The Puppet Architecture
Puppet usually runs in an agent/master (also known as a client/server) architecture, where a Puppet server controls important configuration information, and managed hosts (clients) request only their own configuration catalogs. Puppet configures hosts in two steps:
- It compiles a catalog
- It applies that catalog to the appropriate host
In the agent/master setup, the Puppet client sends facts gathered by Facter and other information to the Puppet Master. The Puppet Master compiles a catalog based on these facts, and then sends this catalog to the client. The client sends a report of all the changes it made, or would have made if the
--noop
parameter had been used, to the Puppet Master, which in turn sends the results to Foreman. This catalog describes the desired state for one specific host. It lists the resources to manage on that host, including any dependencies between those resources. The agent applies the catalog to the host.
This communication between master and agent occurs every 30 minutes by default. You can specify a different value in the
/etc/puppet/puppet.conf
file using the runinterval
parameter. You can also run puppet agent apply
to initiate communication manually.
11.4.2. Using Facter and Facts
Facter is Puppet's system inventory tool, and includes a large number of built-in facts. You can run Facter at the command line on a local host to display fact names and values. You can extend Facter with custom facts, and then use these to expose site-specific details of your hosts to your Puppet manifests. You can also use the facts provided by Facter to inform conditional expressions in Puppet.
Puppet determines a system state based on resources; for example, you can tell Puppet that the
httpd
service should always be running and puppet knows how to handle that. If you are managing different operating systems, you can use the osfamily
fact to create conditional expressions to tell Puppet which service to watch or which package to install. You can use the operatingsystemmajrelease
and versioncmp
parameters to create conditional expressions based on different versions of the same operating system. See Example 11.1, “Using Conditional Expressions with Facts” for an example of using conditional expressions.
Example 11.1. Using Conditional Expressions with Facts
if $:: osfamily == 'RedHat' { if $::operatingsystemmajrelease == '6' { $ntp_service_name = 'ntpd' } elseif versioncmp($::operatingsystemmajrelease, '7') >= 0 { $ntp_service_name = 'chrony' } }
Note
This example uses the expression "versioncmp($::operatingsystemmajrelease, '7') >= 0" to test for version 7 or later of Red Hat Enterprise Linux. Do not use the expression "$::operatingsystemmajrelease >= '7'" to perform this test. See https://docs.puppetlabs.com/references/latest/function.html#versioncmp for more information about this and other Puppet functions.
Puppet also sets other special variables that behave a lot like facts. See Special Variables Added by Puppet[1] and Core Facts[2] for more information.
11.4.2.1. Displaying Facts for a Particular Host
Puppet can access Facter's built-in core facts as well as any custom or external facts present in your Puppet modules. You can view available facts from the command line ( ). You can browse the list of facts or use the Search box to search for specific facts. For example, type "
facter -p
) and also from the web UI ( facts.
" to display a list of available facts.
Note
The list of available facts is very long. The UI only displays 20 facts at a time. The list of facts gradually filters as you enter more details. For example, type "facts.e" to display all facts that begin with the letter "e."
Procedure 11.12. To View Facts for a Particular Host:
- On the main menu, click
and then click the name of the host that you want to inspect. - In the Details pane, click to display all known facts about the host.
Note
- For any fact listed on this page, you can clickto display a chart of the distribution of this fact name over all managed hosts.
- You can bookmark a search to make it easier to use in the future. When you have refined your search, click the drop-down arrow next to thebutton, and click . Bookmarked searches appear in the drop-down list, and also under
on the main menu.
11.4.2.2. Searching for Hosts based on Facts
You can use Facter information to search for specific hosts. This means that you can search for all hosts that match specific fact criteria, such as
facts.architecture = x86_64
.
Procedure 11.13. To Search for Hosts Based on Facts:
- On the main menu, click
to display the Fact Values page. - In the Search field, start typing the name of the fact that you want to filter by. You can search by specific name, name/value pairs, and so on.
- Clickto retrieve the list of matching hosts.