Skip to content

Latest commit

 

History

History
131 lines (82 loc) · 3.96 KB

File metadata and controls

131 lines (82 loc) · 3.96 KB

Nested host groups

You can create a hierarchy of host groups so that child host groups inherit and override settings from parent 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.

{Project} 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.

Example 1. Nested host group hierarchy

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 {client-os} {client-os-major}.{client-os-minor} operating system setting.

Webservers

This host group applies the linux-system-roles.selinux Ansible role.

webserver1.example.com

Hosts use the following settings:

  • {client-os} {client-os-major}.{client-os-minor} defined by host group Base

  • linux-system-roles.selinux defined by host group Webservers

webserver2.example.com

Storage

This host group applies the linux-system-roles.postfix Ansible role.

storage1.example.com

Hosts use the following settings:

  • {client-os} {client-os-major}.{client-os-minor} defined by host group Base

  • linux-system-roles.postfix defined by host group Storage

storage2.example.com

[No host group]

custom.example.com

No settings inherited from host groups.

Example 2. Nested host group settings

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:

  • The {client-os} {client-os-major}.{client-os-minor} operating system

  • The linux-system-roles.selinux Ansible role

Webservers

This host group applies these settings:

  • The {client-os} {client-os-major}.{client-os-minor-bumped} operating system

  • No Ansible role

webserver1.example.com

Hosts use the following settings:

  • The {client-os} {client-os-major}.{client-os-minor-bumped} operating system from host group Webservers

  • The linux-system-roles.selinux Ansible role from host group Base

webserver2.example.com

Storage

This host group applies these settings:

  • No operating system

  • The linux-system-roles.postfix Ansible role

storage1.example.com

Hosts use the following settings:

  • The {client-os} {client-os-major}.{client-os-minor} operating system from host group Base

  • The linux-system-roles.postfix Ansible role from host group Storage

storage2.example.com

[No nested host group]

custom.example.com

Host uses the following settings:

  • The {client-os} {client-os-major}.{client-os-minor} operating system from host group Base

  • The linux-system-roles.selinux Ansible role from host group Base