From c62eb0a266ea9c148c6ec31cd83e7d02b7237a48 Mon Sep 17 00:00:00 2001 From: Rafael Guterres Jeffman Date: Wed, 7 Feb 2024 18:09:06 -0300 Subject: [PATCH] ipareplica: Use hostvars data instead of inventory group name When using 'ansible_host' to override the target node name in an Ansible inventory, the ipareplica deployment role fails as it is not able to either correctly resolve the server name, or fail to join the host to the realm, since the inventory name may match the actual hostname. By retrieving the 'ansible_host' from 'hostvars' a user is allowed to change the actual hostname without affecting the Ansible node used. Such a setup is useful if one have a template inventory, or to setup nodes using containers. --- roles/ipareplica/tasks/install.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/ipareplica/tasks/install.yml b/roles/ipareplica/tasks/install.yml index 076842a384..3c975565eb 100644 --- a/roles/ipareplica/tasks/install.yml +++ b/roles/ipareplica/tasks/install.yml @@ -54,12 +54,12 @@ - name: Install - Set ipareplica_servers ansible.builtin.set_fact: - ipareplica_servers: "{{ groups['ipaservers'] | list }}" + ipareplica_servers: "{{ groups['ipaservers'] | map('extract', hostvars) | map(attribute='ansible_host') }}" when: groups.ipaservers is defined and ipareplica_servers is not defined - name: Install - Set ipareplica_servers from cluster inventory ansible.builtin.set_fact: - ipareplica_servers: "{{ groups['ipaserver'] | list }}" + ipareplica_servers: "{{ groups['ipaserver'] | map('extract', hostvars) | map(attribute='ansible_host') }}" when: ipareplica_servers is not defined and groups.ipaserver is defined - name: Install - Set default principal if no keytab is given