Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Chapter 19. Managing host groups using Ansible playbooks
To learn more about host groups in Identity Management (IdM) and using Ansible to perform operations involving host groups in Identity Management (IdM), see the following:
- Host groups in IdM
- Ensuring the presence of IdM host groups
- Ensuring the presence of hosts in IdM host groups
- Nesting IdM host groups
- Ensuring the presence of member managers in IdM host groups
- Ensuring the absence of hosts from IdM host groups
- Ensuring the absence of nested host groups from IdM host groups
- Ensuring the absence of member managers from IdM host groups
19.1. Host groups in IdM Link kopierenLink in die Zwischenablage kopiert!
IdM host groups can be used to centralize control over important management tasks, particularly access control.
- Definition of host groups
- A host group is an entity that contains a set of IdM hosts with common access control rules and other characteristics. For example, you can define host groups based on company departments, physical locations, or access control requirements.
A host group in IdM can include:
- IdM servers and clients
Other IdM host groups
- Host groups created by default
-
By default, the IdM server creates the host group
ipaservers
for all IdM server hosts. - Direct and indirect group members
- Group attributes in IdM apply to both direct and indirect members: when host group B is a member of host group A, all members of host group B are considered indirect members of host group A.
19.2. Ensuring the presence of IdM host groups using Ansible playbooks Link kopierenLink in die Zwischenablage kopiert!
Follow this procedure to ensure the presence of a host group named databases in Identity Management (IdM) using Ansible playbooks.
Without Ansible, host group entries are created in IdM using the ipa hostgroup-add
command. The result of adding a host group to IdM is the state of the host group being present in IdM. Because of the Ansible reliance on idempotence, to add a host group to IdM using Ansible, you must create a playbook in which you define the state of the host group as present: state: present.
Prerequisites
You have configured your Ansible control node to meet the following requirements:
- You are using Ansible version 2.15 or later.
-
You have installed the
freeipa.ansible_freeipa
collection. - The example assumes that in the ~/MyPlaybooks/ directory, you have created an Ansible inventory file with the fully-qualified domain name (FQDN) of the IdM server.
-
The example assumes that the secret.yml Ansible vault stores your
ipaadmin_password
and that you have access to a file that stores the password protecting the secret.yml file.
-
The target node, that is the node on which the
freeipa.ansible_freeipa
module is executed, is part of the IdM domain as an IdM client, server or replica.
Procedure
Create an Ansible playbook file with the necessary host group information. To simplify the procedure, you can copy and modify the example in the
/usr/share/ansible/collections/ansible_collections/freeipa/ansible_freeipa/playbooks/user/ensure-hostgroup-is-present.yml
file.Copy to Clipboard Copied! Toggle word wrap Toggle overflow In the playbook, state: present signifies a request to add the host group to IdM unless it already exists there.
Run the playbook:
ansible-playbook --vault-password-file=password_file -v -i path_to_inventory_directory/inventory.file path_to_playbooks_directory/ensure-hostgroup-is-present.yml
$ ansible-playbook --vault-password-file=password_file -v -i path_to_inventory_directory/inventory.file path_to_playbooks_directory/ensure-hostgroup-is-present.yml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Log into
ipaserver
asadmin
:ssh admin@server.idm.example.com
$ ssh admin@server.idm.example.com Password: [admin@server /]$
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Request a Kerberos ticket for
admin
:kinit admin
$ kinit admin Password for admin@IDM.EXAMPLE.COM:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Display information about the host group whose presence in IdM you wanted to ensure:
ipa hostgroup-show databases
$ ipa hostgroup-show databases Host-group: databases
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
The databases host group exists in IdM.
19.3. Ensuring the presence of hosts in IdM host groups using Ansible playbooks Link kopierenLink in die Zwischenablage kopiert!
Follow this procedure to ensure the presence of hosts in host groups in Identity Management (IdM) using Ansible playbooks.
Prerequisites
You have configured your Ansible control node to meet the following requirements:
- You are using Ansible version 2.15 or later.
-
You have installed the
freeipa.ansible_freeipa
collection. - The example assumes that in the ~/MyPlaybooks/ directory, you have created an Ansible inventory file with the fully-qualified domain name (FQDN) of the IdM server.
-
The example assumes that the secret.yml Ansible vault stores your
ipaadmin_password
and that you have access to a file that stores the password protecting the secret.yml file.
-
The target node, that is the node on which the
freeipa.ansible_freeipa
module is executed, is part of the IdM domain as an IdM client, server or replica. - The hosts you want to reference in your Ansible playbook exist in IdM. For details, see Ensuring the presence of an IdM host entry using Ansible playbooks.
- The host groups you reference from the Ansible playbook file have been added to IdM. For details, see Ensuring the presence of IdM host groups using Ansible playbooks.
Procedure
Create an Ansible playbook file with the necessary host information:
-
Specify the name of the host group using the
name
variable of thefreeipa.ansible_freeipa.ipahostgroup
module. -
Specify the name of the host with the
host
variable of thefreeipa.ansible_freeipa.ipahostgroup
module.
To simplify the procedure, you can copy and modify the examples in the
/usr/share/ansible/collections/ansible_collections/freeipa/ansible_freeipa/playbooks/hostgroup/ensure-hosts-and-hostgroups-are-present-in-hostgroup.yml
file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow This playbook adds the db.idm.example.com host to the databases host group. The
action: member
line indicates that when the playbook is run, no attempt is made to add the databases group itself. Instead, only an attempt is made to add db.idm.example.com to databases.-
Specify the name of the host group using the
Run the playbook:
ansible-playbook --vault-password-file=password_file -v -i path_to_inventory_directory/inventory.file path_to_playbooks_directory/ensure-hosts-or-hostgroups-are-present-in-hostgroup.yml
$ ansible-playbook --vault-password-file=password_file -v -i path_to_inventory_directory/inventory.file path_to_playbooks_directory/ensure-hosts-or-hostgroups-are-present-in-hostgroup.yml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Log into
ipaserver
asadmin
:ssh admin@server.idm.example.com
$ ssh admin@server.idm.example.com Password: [admin@server /]$
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Request a Kerberos ticket for
admin
:kinit admin
$ kinit admin Password for admin@IDM.EXAMPLE.COM:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Display information about a host group to see which hosts are present in it:
ipa hostgroup-show databases
$ ipa hostgroup-show databases Host-group: databases Member hosts: db.idm.example.com
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
The db.idm.example.com host is present as a member of the databases host group.
19.4. Nesting IdM host groups using Ansible playbooks Link kopierenLink in die Zwischenablage kopiert!
Follow this procedure to ensure the presence of nested host groups in Identity Management (IdM) host groups using Ansible playbooks.
Prerequisites
You have configured your Ansible control node to meet the following requirements:
- You are using Ansible version 2.15 or later.
-
You have installed the
freeipa.ansible_freeipa
collection. - The example assumes that in the ~/MyPlaybooks/ directory, you have created an Ansible inventory file with the fully-qualified domain name (FQDN) of the IdM server.
-
The example assumes that the secret.yml Ansible vault stores your
ipaadmin_password
and that you have access to a file that stores the password protecting the secret.yml file.
-
The target node, that is the node on which the
freeipa.ansible_freeipa
module is executed, is part of the IdM domain as an IdM client, server or replica. - The host groups you reference from the Ansible playbook file exist in IdM. For details, see Ensuring the presence of IdM host groups using Ansible playbooks.
Procedure
Create an Ansible playbook file with the necessary host group information:
-
To ensure that a nested host group A exists in a host group B: in the Ansible playbook, specify, among the variables of the
freeipa.ansible_freeipa.ipahostgroup
task, the name of the host group B using thename
variable. -
Specify the name of the nested hostgroup A with the
hostgroup
variable.
To simplify this step, you can copy and modify the examples in the
/usr/share/ansible/collections/ansible_collections/freeipa/ansible_freeipa/playbooks/hostgroup/ensure-hosts-and-hostgroups-are-present-in-hostgroup.yml
file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow This Ansible playbook ensures the presence of the myqsl-server and oracle-server host groups in the databases host group. The
action: member
line indicates that when the playbook is run, no attempt is made to add the databases group itself to IdM.-
To ensure that a nested host group A exists in a host group B: in the Ansible playbook, specify, among the variables of the
Run the playbook:
ansible-playbook --vault-password-file=password_file -v -i path_to_inventory_directory/inventory.file path_to_playbooks_directory/ensure-hosts-or-hostgroups-are-present-in-hostgroup.yml
$ ansible-playbook --vault-password-file=password_file -v -i path_to_inventory_directory/inventory.file path_to_playbooks_directory/ensure-hosts-or-hostgroups-are-present-in-hostgroup.yml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Log into
ipaserver
asadmin
:ssh admin@server.idm.example.com
$ ssh admin@server.idm.example.com Password: [admin@server /]$
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Request a Kerberos ticket for
admin
:kinit admin
$ kinit admin Password for admin@IDM.EXAMPLE.COM:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Display information about the host group in which nested host groups are present:
ipa hostgroup-show databases
$ ipa hostgroup-show databases Host-group: databases Member hosts: db.idm.example.com Member host-groups: mysql-server, oracle-server
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
The mysql-server and oracle-server host groups exist in the databases host group.
19.5. Ensuring the presence of member managers in IDM host groups using Ansible Playbooks Link kopierenLink in die Zwischenablage kopiert!
The following procedure describes ensuring the presence of member managers in IdM hosts and host groups using an Ansible playbook.
Prerequisites
On the control node:
- You are using Ansible version 2.15 or later.
-
You have installed the
freeipa.ansible_freeipa
collection. - The example assumes that in the ~/MyPlaybooks/ directory, you have created an Ansible inventory file with the fully-qualified domain name (FQDN) of the IdM server.
-
The example assumes that the secret.yml Ansible vault stores your
ipaadmin_password
and that you have access to a file that stores the password protecting the secret.yml file.
-
The target node, that is the node on which the
freeipa.ansible_freeipa
module is executed, is part of the IdM domain as an IdM client, server or replica. - You must have the name of the host or host group you are adding as member managers and the name of the host group you want them to manage.
Procedure
Create an Ansible playbook file with the necessary host and host group member management information:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the playbook:
ansible-playbook --vault-password-file=password_file -v -i path_to_inventory_directory/inventory.file path_to_playbooks_directory/add-member-managers-host-groups.yml
$ ansible-playbook --vault-password-file=password_file -v -i path_to_inventory_directory/inventory.file path_to_playbooks_directory/add-member-managers-host-groups.yml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
You can verify if the group_name group contains example_member and project_admins as member managers by using the ipa group-show
command:
Log into
ipaserver
as administrator:ssh admin@server.idm.example.com
$ ssh admin@server.idm.example.com Password: [admin@server /]$
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Display information about testhostgroup:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
19.6. Ensuring the absence of hosts from IdM host groups using Ansible playbooks Link kopierenLink in die Zwischenablage kopiert!
Follow this procedure to ensure the absence of hosts from host groups in Identity Management (IdM) using Ansible playbooks.
Prerequisites
You have configured your Ansible control node to meet the following requirements:
- You are using Ansible version 2.15 or later.
-
You have installed the
freeipa.ansible_freeipa
collection. - The example assumes that in the ~/MyPlaybooks/ directory, you have created an Ansible inventory file with the fully-qualified domain name (FQDN) of the IdM server.
-
The example assumes that the secret.yml Ansible vault stores your
ipaadmin_password
and that you have access to a file that stores the password protecting the secret.yml file.
-
The target node, that is the node on which the
freeipa.ansible_freeipa
module is executed, is part of the IdM domain as an IdM client, server or replica. - The hosts you want to reference in your Ansible playbook exist in IdM. For details, see Ensuring the presence of an IdM host entry using Ansible playbooks.
- The host groups you reference from the Ansible playbook file exist in IdM. For details, see Ensuring the presence of IdM host groups using Ansible playbooks.
Procedure
Create an Ansible playbook file with the necessary host and host group information:
-
Specify the name of the host group using the
name
variable of thefreeipa.ansible_freeipa.ipahostgroup
module. -
Specify the name of the host whose absence from the host group you want to ensure using the
host
variable of thefreeipa.ansible_freeipa.ipahostgroup
module.
To simplify the procedure, you can copy and modify the examples in the
/usr/share/ansible/collections/ansible_collections/freeipa/ansible_freeipa/playbooks/hostgroup/ensure-hosts-and-hostgroups-are-absent-in-hostgroup.yml
file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow This playbook ensures the absence of the db.idm.example.com host from the databases host group. The action: member line indicates that when the playbook is run, no attempt is made to remove the databases group itself.
-
Specify the name of the host group using the
Run the playbook:
ansible-playbook --vault-password-file=password_file -v -i path_to_inventory_directory/inventory.file path_to_playbooks_directory/ensure-hosts-or-hostgroups-are-absent-in-hostgroup.yml
$ ansible-playbook --vault-password-file=password_file -v -i path_to_inventory_directory/inventory.file path_to_playbooks_directory/ensure-hosts-or-hostgroups-are-absent-in-hostgroup.yml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Log into
ipaserver
asadmin
:ssh admin@server.idm.example.com
$ ssh admin@server.idm.example.com Password: [admin@server /]$
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Request a Kerberos ticket for
admin
:kinit admin
$ kinit admin Password for admin@IDM.EXAMPLE.COM:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Display information about the host group and the hosts it contains:
ipa hostgroup-show databases
$ ipa hostgroup-show databases Host-group: databases Member host-groups: mysql-server, oracle-server
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
The db.idm.example.com host does not exist in the databases host group.
19.7. Ensuring the absence of nested host groups from IdM host groups using Ansible playbooks Link kopierenLink in die Zwischenablage kopiert!
Follow this procedure to ensure the absence of nested host groups from outer host groups in Identity Management (IdM) using Ansible playbooks.
Prerequisites
You have configured your Ansible control node to meet the following requirements:
- You are using Ansible version 2.15 or later.
-
You have installed the
freeipa.ansible_freeipa
collection. - The example assumes that in the ~/MyPlaybooks/ directory, you have created an Ansible inventory file with the fully-qualified domain name (FQDN) of the IdM server.
-
The example assumes that the secret.yml Ansible vault stores your
ipaadmin_password
and that you have access to a file that stores the password protecting the secret.yml file.
-
The target node, that is the node on which the
freeipa.ansible_freeipa
module is executed, is part of the IdM domain as an IdM client, server or replica. - The host groups you reference from the Ansible playbook file exist in IdM. For details, see Ensuring the presence of IdM host groups using Ansible playbooks.
Procedure
Create an Ansible playbook file with the necessary host group information:
-
Specify, among the
freeipa.ansible_freeipa.ipahostgroup
variables, the name of the outer host group using thename
variable. -
Specify the name of the nested hostgroup with the
hostgroup
variable.
To simplify this step, you can copy and modify the examples in the
/usr/share/ansible/collections/ansible_collections/freeipa/ansible_freeipa/playbooks/hostgroup/ensure-hosts-and-hostgroups-are-absent-in-hostgroup.yml
file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow This playbook makes sure that the mysql-server and oracle-server host groups are absent from the databases host group. The
action: member
line indicates that when the playbook is run, no attempt is made to ensure the databases group itself is deleted from IdM.-
Specify, among the
Run the playbook:
ansible-playbook --vault-password-file=password_file -v -i path_to_inventory_directory/inventory.file path_to_playbooks_directory/ensure-hosts-or-hostgroups-are-absent-in-hostgroup.yml
$ ansible-playbook --vault-password-file=password_file -v -i path_to_inventory_directory/inventory.file path_to_playbooks_directory/ensure-hosts-or-hostgroups-are-absent-in-hostgroup.yml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Log into
ipaserver
as admin:ssh admin@server.idm.example.com
$ ssh admin@server.idm.example.com Password: [admin@server /]$
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Request a Kerberos ticket for admin:
kinit admin
$ kinit admin Password for admin@IDM.EXAMPLE.COM:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Display information about the host group from which nested host groups should be absent:
ipa hostgroup-show databases
$ ipa hostgroup-show databases Host-group: databases
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
The output confirms that the mysql-server and oracle-server nested host groups are absent from the outer databases host group.
19.8. Ensuring the absence of IdM host groups using Ansible playbooks Link kopierenLink in die Zwischenablage kopiert!
Follow this procedure to ensure the absence of host groups in Identity Management (IdM) using Ansible playbooks.
Without Ansible, host group entries are removed from IdM using the ipa hostgroup-del
command. The result of removing a host group from IdM is the state of the host group being absent from IdM. Because of the Ansible reliance on idempotence, to remove a host group from IdM using Ansible, you must create a playbook in which you define the state of the host group as absent: state: absent.
Prerequisites
You have configured your Ansible control node to meet the following requirements:
- You are using Ansible version 2.15 or later.
-
You have installed the
freeipa.ansible_freeipa
collection. - The example assumes that in the ~/MyPlaybooks/ directory, you have created an Ansible inventory file with the fully-qualified domain name (FQDN) of the IdM server.
-
The example assumes that the secret.yml Ansible vault stores your
ipaadmin_password
and that you have access to a file that stores the password protecting the secret.yml file.
-
The target node, that is the node on which the
freeipa.ansible_freeipa
module is executed, is part of the IdM domain as an IdM client, server or replica.
Procedure
Create an Ansible playbook file with the necessary host group information. To simplify this step, you can copy and modify the example in the
/usr/share/ansible/collections/ansible_collections/freeipa/ansible_freeipa/playbooks/user/ensure-hostgroup-is-absent.yml
file.Copy to Clipboard Copied! Toggle word wrap Toggle overflow This playbook ensures the absence of the databases host group from IdM. The
state: absent
means a request to delete the host group from IdM unless it is already deleted.Run the playbook:
ansible-playbook --vault-password-file=password_file -v -i path_to_inventory_directory/inventory.file path_to_playbooks_directory/ensure-hostgroup-is-absent.yml
$ ansible-playbook --vault-password-file=password_file -v -i path_to_inventory_directory/inventory.file path_to_playbooks_directory/ensure-hostgroup-is-absent.yml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Log into
ipaserver
asadmin
:ssh admin@server.idm.example.com
$ ssh admin@server.idm.example.com Password: [admin@server /]$
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Request a Kerberos ticket for
admin
:kinit admin
$ kinit admin Password for admin@IDM.EXAMPLE.COM:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Display information about the host group whose absence you ensured:
ipa hostgroup-show databases
$ ipa hostgroup-show databases ipa: ERROR: databases: host group not found
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
The databases host group does not exist in IdM.
19.9. Ensuring the absence of member managers from IdM host groups using Ansible playbooks Link kopierenLink in die Zwischenablage kopiert!
The following procedure describes ensuring the absence of member managers in IdM hosts and host groups using an Ansible playbook.
Prerequisites
On the control node:
- You are using Ansible version 2.15 or later.
-
You have installed the
freeipa.ansible_freeipa
collection. - The example assumes that in the ~/MyPlaybooks/ directory, you have created an Ansible inventory file with the fully-qualified domain name (FQDN) of the IdM server.
-
The example assumes that the secret.yml Ansible vault stores your
ipaadmin_password
and that you have access to a file that stores the password protecting the secret.yml file.
-
The target node, that is the node on which the
freeipa.ansible_freeipa
module is executed, is part of the IdM domain as an IdM client, server or replica. - You must have the name of the user or user group you are removing as member managers and the name of the host group they are managing.
Procedure
Create an Ansible playbook file with the necessary host and host group member management information:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the playbook:
ansible-playbook --vault-password-file=password_file -v -i path_to_inventory_directory/inventory.file path_to_playbooks_directory/ensure-member-managers-host-groups-are-absent.yml
$ ansible-playbook --vault-password-file=password_file -v -i path_to_inventory_directory/inventory.file path_to_playbooks_directory/ensure-member-managers-host-groups-are-absent.yml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
You can verify if the group_name group does not contain example_member or project_admins as member managers by using the ipa group-show
command:
Log into
ipaserver
as administrator:ssh admin@server.idm.example.com
$ ssh admin@server.idm.example.com Password: [admin@server /]$
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Display information about testhostgroup:
ipaserver]$ ipa hostgroup-show group_name Host-group: group_name Member hosts: server.idm.example.com Member host-groups: testhostgroup2
ipaserver]$ ipa hostgroup-show group_name Host-group: group_name Member hosts: server.idm.example.com Member host-groups: testhostgroup2
Copy to Clipboard Copied! Toggle word wrap Toggle overflow