Chapter 101. Managing IdM servers by using Ansible
You can use Red Hat Ansible Engine to manage the servers in your Identity Management (IdM) topology. You can use the server module in the ansible-freeipa package to check the presence or absence of a server in the IdM topology. You can also hide any replica or make a replica visible.
The section contains the following topics:
- Checking that an IdM server is present by using Ansible
- Ensuring that an IdM server is absent from an IdM topology by using Ansible
- Ensuring the absence of an IdM server despite hosting a last IdM server role
- Ensuring that an IdM server is absent but not necessarily disconnected from other IdM servers
- Ensuring that an existing IdM server is hidden using an Ansible playbook
- Ensuring that an existing IdM server is visible using an Ansible playbook
- Ensuring that an existing IdM server has an IdM DNS location assigned
- Ensuring that an existing IdM server has no IdM DNS location assigned
101.1. Checking that an IdM server is present by using Ansible Copy linkLink copied to clipboard!
You can use the ipaserver ansible-freeipa module in an Ansible playbook to verify that an Identity Management (IdM) server exists.
The ipaserver Ansible module does not install the IdM server.
Prerequisites
On the control node:
- You are using Ansible version 2.13 or later.
-
You have installed the
ansible-freeipapackage. - 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.
The target node, that is the node on which the
ansible-freeipamodule is executed, is part of the IdM domain as an IdM client, server or replica.-
The
SSHconnection from the control node to the IdM server defined in the inventory file is working correctly.
-
The
Procedure
Navigate to your ~/MyPlaybooks/ directory:
cd ~/MyPlaybooks/
$ cd ~/MyPlaybooks/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy the
server-present.ymlAnsible playbook file located in the/usr/share/doc/ansible-freeipa/playbooks/server/directory:cp /usr/share/doc/ansible-freeipa/playbooks/server/server-present.yml server-present-copy.yml
$ cp /usr/share/doc/ansible-freeipa/playbooks/server/server-present.yml server-present-copy.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
Open the
server-present-copy.ymlfile for editing. Adapt the file by setting the following variables in the
ipaservertask section and save the file:-
Set the
ipaadmin_passwordvariable to the password of the IdMadmin. -
Set the
namevariable to theFQDNof the server. TheFQDNof the example server is server123.idm.example.com.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Set the
Run the Ansible playbook and specify the playbook file and the inventory file:
ansible-playbook --vault-password-file=password_file -v -i inventory server-present-copy.yml
$ ansible-playbook --vault-password-file=password_file -v -i inventory server-present-copy.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
101.2. Ensuring that an IdM server is absent from an IdM topology by using Ansible Copy linkLink copied to clipboard!
Use an Ansible playbook to ensure an Identity Management (IdM) server does not exist in an IdM topology, even as a host.
In contrast to the ansible-freeipa ipaserver role, the ipaserver module used in this playbook does not uninstall IdM services from the server.
Prerequisites
On the control node:
- You are using Ansible version 2.13 or later.
-
You have installed the
ansible-freeipapackage. - 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.
The target node, that is the node on which the
ansible-freeipamodule is executed, is part of the IdM domain as an IdM client, server or replica.-
The
SSHconnection from the control node to the IdM server defined in the inventory file is working correctly.
-
The
Procedure
Navigate to your ~/MyPlaybooks/ directory:
cd ~/MyPlaybooks/
$ cd ~/MyPlaybooks/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy the
server-absent.ymlAnsible playbook file located in the/usr/share/doc/ansible-freeipa/playbooks/server/directory:cp /usr/share/doc/ansible-freeipa/playbooks/server/server-absent.yml server-absent-copy.yml
$ cp /usr/share/doc/ansible-freeipa/playbooks/server/server-absent.yml server-absent-copy.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
Open the
server-absent-copy.ymlfile for editing. Adapt the file by setting the following variables in the
ipaservertask section and save the file:-
Set the
ipaadmin_passwordvariable to the password of the IdMadmin. -
Set the
namevariable to theFQDNof the server. TheFQDNof the example server is server123.idm.example.com. -
Ensure that the
statevariable is set toabsent.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Set the
Run the Ansible playbook and specify the playbook file and the inventory file:
ansible-playbook --vault-password-file=password_file -v -i inventory server-absent-copy.yml
$ ansible-playbook --vault-password-file=password_file -v -i inventory server-absent-copy.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Make sure all name server (NS) DNS records pointing to server123.idm.example.com are deleted from your DNS zones. This applies regardless of whether you use integrated DNS managed by IdM or external DNS.
101.3. Ensuring the absence of an IdM server despite hosting a last IdM server role Copy linkLink copied to clipboard!
You can use Ansible to ensure that an Identity Management (IdM) server is absent even if the last IdM service instance is running on the server. A certificate authority (CA), key recovery authority (KRA), or DNS server are all examples of IdM services.
If you remove the last server that serves as a CA, KRA, or DNS server, you disrupt IdM functionality seriously. You can manually check which services are running on which IdM servers with the ipa service-find command. The principal name of a CA server is dogtag/server_name/REALM_NAME.
In contrast to the ansible-freeipa ipaserver role, the ipaserver module used in this playbook does not uninstall IdM services from the server.
Prerequisites
On the control node:
- You are using Ansible version 2.13 or later.
-
You have installed the
ansible-freeipapackage. - 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.
The target node, that is the node on which the
ansible-freeipamodule is executed, is part of the IdM domain as an IdM client, server or replica.-
The
SSHconnection from the control node to the IdM server defined in the inventory file is working correctly.
-
The
Procedure
Navigate to your ~/MyPlaybooks/ directory:
cd ~/MyPlaybooks/
$ cd ~/MyPlaybooks/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy the
server-absent-ignore-last-of-role.ymlAnsible playbook file located in the/usr/share/doc/ansible-freeipa/playbooks/server/directory:cp /usr/share/doc/ansible-freeipa/playbooks/server/server-absent-ignore-last-of-role.yml server-absent-ignore-last-of-role-copy.yml
$ cp /usr/share/doc/ansible-freeipa/playbooks/server/server-absent-ignore-last-of-role.yml server-absent-ignore-last-of-role-copy.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
Open the
server-absent-ignore-last-of-role-copy.ymlfile for editing. Adapt the file by setting the following variables in the
ipaservertask section and save the file:-
Set the
ipaadmin_passwordvariable to the password of the IdMadmin. -
Set the
namevariable to theFQDNof the server. TheFQDNof the example server is server123.idm.example.com. -
Ensure that the
ignore_last_of_rolevariable is set totrue. -
Set the
statevariable toabsent.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Set the
Run the Ansible playbook and specify the playbook file and the inventory file:
ansible-playbook --vault-password-file=password_file -v -i inventory server-absent-ignore-last-of-role-copy.yml
$ ansible-playbook --vault-password-file=password_file -v -i inventory server-absent-ignore-last-of-role-copy.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Make sure all name server (NS) DNS records that point to server123.idm.example.com are deleted from your DNS zones. This applies regardless of whether you use integrated DNS managed by IdM or external DNS.
101.4. Ensuring that an IdM server is absent but not necessarily disconnected from other IdM servers Copy linkLink copied to clipboard!
If you are removing an Identity Management (IdM) server from the topology, you can keep its replication agreements intact with an Ansible playbook. The playbook also ensures that the IdM server does not exist in IdM, even as a host.
Ignoring a server’s replication agreements when removing it is only recommended when the other servers are dysfunctional servers that you are planning to remove anyway. Removing a server that serves as a central point in the topology can split your topology into two disconnected clusters.
You can remove a dysfunctional server from the topology with the ipa server-del command.
If you remove the last server that serves as a certificate authority (CA), key recovery authority (KRA), or DNS server, you seriously disrupt the Identity Management (IdM) functionality. To prevent this problem, the playbook makes sure these services are running on another server in the domain before it uninstalls a server that serves as a CA, KRA, or DNS server.
In contrast to the ansible-freeipa ipaserver role, the ipaserver module used in this playbook does not uninstall IdM services from the server.
Prerequisites
On the control node:
- You are using Ansible version 2.13 or later.
-
You have installed the
ansible-freeipapackage. - 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.
The target node, that is the node on which the
ansible-freeipamodule is executed, is part of the IdM domain as an IdM client, server or replica.-
The
SSHconnection from the control node to the IdM server defined in the inventory file is working correctly.
-
The
Procedure
Navigate to your ~/MyPlaybooks/ directory:
cd ~/MyPlaybooks/
$ cd ~/MyPlaybooks/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy the
server-absent-ignore_topology_disconnect.ymlAnsible playbook file located in the/usr/share/doc/ansible-freeipa/playbooks/server/directory:cp /usr/share/doc/ansible-freeipa/playbooks/server/server-absent-ignore_topology_disconnect.yml server-absent-ignore_topology_disconnect-copy.yml
$ cp /usr/share/doc/ansible-freeipa/playbooks/server/server-absent-ignore_topology_disconnect.yml server-absent-ignore_topology_disconnect-copy.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
Open the
server-absent-ignore_topology_disconnect-copy.ymlfile for editing. Adapt the file by setting the following variables in the
ipaservertask section and save the file:-
Set the
ipaadmin_passwordvariable to the password of the IdMadmin. -
Set the
namevariable to theFQDNof the server. TheFQDNof the example server is server123.idm.example.com. -
Ensure that the
ignore_topology_disconnectvariable is set totrue. -
Ensure that the
statevariable is set toabsent.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Set the
Run the Ansible playbook and specify the playbook file and the inventory file:
ansible-playbook --vault-password-file=password_file -v -i inventory server-absent-ignore_topology_disconnect-copy.yml
$ ansible-playbook --vault-password-file=password_file -v -i inventory server-absent-ignore_topology_disconnect-copy.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Optional: Make sure all name server (NS) DNS records pointing to server123.idm.example.com are deleted from your DNS zones. This applies regardless of whether you use integrated DNS managed by IdM or external DNS.
101.6. Ensuring that an existing IdM server is visible by using an Ansible playbook Copy linkLink copied to clipboard!
Use the ipaserver ansible-freeipa module in an Ansible playbook to ensure that an existing Identity Management (IdM) server is visible. Note that this playbook does not install the IdM server.
Prerequisites
On the control node:
- You are using Ansible version 2.13 or later.
-
You have installed the
ansible-freeipapackage. - 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.
The target node, that is the node on which the
ansible-freeipamodule is executed, is part of the IdM domain as an IdM client, server or replica.-
The
SSHconnection from the control node to the IdM server defined in the inventory file is working correctly.
-
The
Procedure
Navigate to your ~/MyPlaybooks/ directory:
cd ~/MyPlaybooks/
$ cd ~/MyPlaybooks/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy the
server-not-hidden.ymlAnsible playbook file located in the/usr/share/doc/ansible-freeipa/playbooks/server/directory:cp /usr/share/doc/ansible-freeipa/playbooks/server/server-not-hidden.yml server-not-hidden-copy.yml
$ cp /usr/share/doc/ansible-freeipa/playbooks/server/server-not-hidden.yml server-not-hidden-copy.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
Open the
server-not-hidden-copy.ymlfile for editing. Adapt the file by setting the following variables in the
ipaservertask section and save the file:-
Set the
ipaadmin_passwordvariable to the password of the IdMadmin. -
Set the
namevariable to theFQDNof the server. TheFQDNof the example server is server123.idm.example.com. -
Ensure that the
hiddenvariable is set tono.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Set the
Run the Ansible playbook and specify the playbook file and the inventory file:
ansible-playbook --vault-password-file=password_file -v -i inventory server-not-hidden-copy.yml
$ ansible-playbook --vault-password-file=password_file -v -i inventory server-not-hidden-copy.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
101.7. Ensuring that an existing IdM server has an IdM DNS location assigned Copy linkLink copied to clipboard!
Use the ipaserver ansible-freeipa module in an Ansible playbook to ensure that an existing Identity Management (IdM) server is assigned a specific IdM DNS location.
Note that the ipaserver Ansible module does not install the IdM server.
Prerequisites
-
You know the IdM
adminpassword. - The IdM DNS location exists. The example location is germany.
-
You have
rootaccess to the server. The example server is server123.idm.example.com. You have configured your Ansible control node to meet the following requirements:
- You are using Ansible version 2.13 or later.
-
You have installed the
ansible-freeipapackage. - 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.
The target node, that is the node on which the
ansible-freeipamodule is executed, is part of the IdM domain as an IdM client, server or replica.-
The
SSHconnection from the control node to the IdM server defined in the inventory file is working correctly.
-
The
Procedure
Navigate to your ~/MyPlaybooks/ directory:
cd ~/MyPlaybooks/
$ cd ~/MyPlaybooks/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy the
server-location.ymlAnsible playbook file located in the/usr/share/doc/ansible-freeipa/playbooks/server/directory:cp /usr/share/doc/ansible-freeipa/playbooks/server/server-location.yml server-location-copy.yml
$ cp /usr/share/doc/ansible-freeipa/playbooks/server/server-location.yml server-location-copy.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
Open the
server-location-copy.ymlfile for editing. Adapt the file by setting the following variables in the
ipaservertask section and save the file:-
Set the
ipaadmin_passwordvariable to the password of the IdMadmin. -
Set the
namevariable to server123.idm.example.com. -
Set the
locationvariable to germany.
This is the modified Ansible playbook file for the current example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Set the
Run the Ansible playbook and specify the playbook file and the inventory file:
ansible-playbook --vault-password-file=password_file -v -i inventory server-location-copy.yml
$ ansible-playbook --vault-password-file=password_file -v -i inventory server-location-copy.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Connect to server123.idm.example.com as
rootusingSSH:ssh root@server123.idm.example.com
ssh root@server123.idm.example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow Restart the
namedservice on the server for the updates to take effect immediately:[root@server123.idm.example.com ~]# systemctl restart named
[root@server123.idm.example.com ~]# systemctl restart namedCopy to Clipboard Copied! Toggle word wrap Toggle overflow
101.8. Ensuring that an existing IdM server has no IdM DNS location assigned Copy linkLink copied to clipboard!
Use the ipaserver ansible-freeipa module in an Ansible playbook to ensure that an existing Identity Management (IdM) server has no IdM DNS location assigned to it. Do not assign a DNS location to servers that change geographical location frequently. Note that the playbook does not install the IdM server.
Prerequisites
-
You know the IdM
adminpassword. -
You have
rootaccess to the server. The example server is server123.idm.example.com. You have configured your Ansible control node to meet the following requirements:
- You are using Ansible version 2.13 or later.
-
You have installed the
ansible-freeipapackage. - 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.
The target node, that is the node on which the
ansible-freeipamodule is executed, is part of the IdM domain as an IdM client, server or replica.-
The
SSHconnection from the control node to the IdM server defined in the inventory file is working correctly.
-
The
Procedure
Navigate to your ~/MyPlaybooks/ directory:
cd ~/MyPlaybooks/
$ cd ~/MyPlaybooks/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy the
server-no-location.ymlAnsible playbook file located in the/usr/share/doc/ansible-freeipa/playbooks/server/directory:cp /usr/share/doc/ansible-freeipa/playbooks/server/server-no-location.yml server-no-location-copy.yml
$ cp /usr/share/doc/ansible-freeipa/playbooks/server/server-no-location.yml server-no-location-copy.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow -
Open the
server-no-location-copy.ymlfile for editing. Adapt the file by setting the following variables in the
ipaservertask section and save the file:-
Set the
ipaadmin_passwordvariable to the password of the IdMadmin. -
Set the
namevariable to server123.idm.example.com. -
Ensure that the
locationvariable is set to ””.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Set the
Run the Ansible playbook and specify the playbook file and the inventory file:
ansible-playbook --vault-password-file=password_file -v -i inventory server-no-location-copy.yml
$ ansible-playbook --vault-password-file=password_file -v -i inventory server-no-location-copy.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Connect to server123.idm.example.com as
rootusingSSH:ssh root@server123.idm.example.com
ssh root@server123.idm.example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow Restart the
namedservice on the server for the updates to take effect immediately:[root@server123.idm.example.com ~]# systemctl restart named
[root@server123.idm.example.com ~]# systemctl restart namedCopy to Clipboard Copied! Toggle word wrap Toggle overflow