Working with host groups
A host group acts as a template for common host settings. Instead of defining the settings individually for each host, use host groups to define common settings once and apply them to multiple hosts.
Host group settings and nested host groups
A host group can define many settings for hosts, such as lifecycle environment, content view, or Ansible roles that are available to the hosts.
When you change the settings of an existing host group, the new settings do not propagate to the hosts assigned to the host group. Only Puppet class settings get updated on hosts after you change them in the host group. |
You can create a hierarchy of host groups. Aim to have one base level host group that represents all hosts in your organization and provides general settings, and then nested groups that provide specific settings.
orcharhino applies host settings in the following order when nesting host groups:
-
Host settings take priority over host group settings.
-
Nested host group settings take priority over parent host group settings.
You create a top-level host group named Base and two nested host groups named Webserver and Storage.
The nested host groups are associated with multiple hosts.
You also create host custom.example.com
that is not associated with any host group.
You define the operating system on the top-level host group (Base) and Ansible roles on the nested host groups (Webservers and Storage).
Top-level host group | Nested host group | Hosts | Settings inherited from host groups |
---|---|---|---|
Base This host group applies the |
Webservers This host group applies the |
webserver1.example.com |
Hosts use the following settings:
|
webserver2.example.com |
|||
Storage This host group applies the |
storage1.example.com |
Hosts use the following settings:
|
|
storage2.example.com |
|||
[No host group] |
custom.example.com |
No settings inherited from host groups. |
You create a top-level host group named Base and two nested host groups named Webserver and Storage.
You also create host custom.example.com
that is associated with the top-level host group Base, but no nested host group.
You define different values for the operating system and Ansible role settings on the top-level host group (Base) and nested host groups (Webserver and Storage).
Top-level host group | Nested host group | Host | Settings inherited from host groups |
---|---|---|---|
Base This host group applies these settings:
|
Webservers This host group applies these settings:
|
webserver1.example.com |
Hosts use the following settings:
|
webserver2.example.com |
|||
Storage This host group applies these settings:
|
storage1.example.com |
Hosts use the following settings:
|
|
storage2.example.com |
|||
[No nested host group] |
custom.example.com |
Host uses the following settings:
|
Creating a host group
Create a host group to be able to apply host settings to multiple hosts.
To use the CLI instead of the orcharhino management UI, see the CLI procedure.
-
In the orcharhino management UI, navigate to Configure > Host Groups and click Create Host Group.
-
If you have an existing host group that you want to inherit attributes from, you can select a host group from the Parent list. If you do not, leave this field blank.
-
Enter a Name for the new host group.
-
Enter any further information that you want future hosts to inherit.
-
Click the Ansible Roles tab, and from the Ansible Roles list, select one or more roles that you want to add to the host. Use the arrow icon to manage the roles that you add or remove.
-
Click the additional tabs and add any details that you want to attribute to the host group.
Puppet fails to retrieve the Puppet CA certificate while registering a host with a host group associated with a Puppet environment created inside a
Production
environment.To create a suitable Puppet environment to be associated with a host group, manually create a directory:
$ mkdir /etc/puppetlabs/code/environments/example_environment
-
Click Submit to save the host group.
-
Create the host group with the
hammer hostgroup create
command. For example:$ hammer hostgroup create --name "Base" \ --architecture "My_Architecture" \ --content-source-id _My_Content_Source_ID_ \ --content-view "_My_Content_View_" \ --domain "_My_Domain_" \ --lifecycle-environment "_My_Lifecycle_Environment_" \ --locations "_My_Location_" \ --medium-id _My_Installation_Medium_ID_ \ --operatingsystem "_My_Operating_System_" \ --organizations "_My_Organization_" \ --partition-table "_My_Partition_Table_" \ --puppet-ca-proxy-id _My_Puppet_CA_Proxy_ID_ \ --puppet-environment "_My_Puppet_Environment_" \ --puppet-proxy-id _My_Puppet_Proxy_ID_ \ --root-pass "My_Password" \ --subnet "_My_Subnet_"
Creating a host group for each lifecycle environment
Use this procedure to create a host group for the Library lifecycle environment and add nested host groups for other lifecycle environments.
To create a host group for each lifecycle environment, run the following Bash script:
MAJOR="My_Major_OS_Version"
ARCH="My_Architecture"
ORG="My_Organization"
LOCATIONS="My_Location"
PTABLE_NAME="My_Partition_Table"
DOMAIN="My_Domain"
hammer --output csv --no-headers lifecycle-environment list --organization "${ORG}" | cut -d ',' -f 2 | while read LC_ENV; do
[[ ${LC_ENV} == "Library" ]] && continue
hammer hostgroup create --name "rhel-${MAJOR}server-${ARCH}-${LC_ENV}" \
--architecture "${ARCH}" \
--partition-table "${PTABLE_NAME}" \
--domain "${DOMAIN}" \
--organizations "${ORG}" \
--query-organization "${ORG}" \
--locations "${LOCATIONS}" \
--lifecycle-environment "${LC_ENV}"
done
Adding a host to a host group
You can add a host to a host group in the orcharhino management UI.
-
In the orcharhino management UI, navigate to Hosts > All Hosts.
-
Click the name of the host you want to modify.
-
Click Edit.
-
Select the host group from the Host Group list.
-
Click Submit.
-
The Details card under the Overview tab now shows the host group your host belongs to.
Changing the host group of a host
Use this procedure to change the Host Group of a host.
If you reprovision a host after changing the host group, the fresh values that the host inherits from the host group will be applied.
-
In the orcharhino management UI, navigate to Hosts > All Hosts.
-
Click the name of the host you want to modify.
-
Click Edit.
-
Select the new host group from the Host Group list.
-
Click Submit.
-
The Details card under the Overview tab now shows the host group your host belongs to.
The text and illustrations on this page are licensed by ATIX AG under a Creative Commons Attribution Share Alike 4.0 International ("CC BY-SA 4.0") license. This page also contains text from the official Foreman documentation which uses the same license ("CC BY-SA 4.0"). |