From e2a8ce0a29bb81cea8fedb1f09ab4f7ce90995a5 Mon Sep 17 00:00:00 2001 From: Rafael Guterres Jeffman Date: Wed, 7 Feb 2024 18:08:41 -0300 Subject: [PATCH] ipaclient: Use hostvars data instead of inventory group name When using 'ansible_host' to override the target node name in an Ansible inventory, the deployment role fails as it is not able to resolve the server name, since the inventory name does not match the actual hostname. By retrieving the 'ansible_host' from 'hostvars' a user is allowed to change the actual hostname as a varible, being able to use the inventory as a template. --- roles/ipaclient/tasks/install.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/ipaclient/tasks/install.yml b/roles/ipaclient/tasks/install.yml index b5eb71658a..9fbb9f2066 100644 --- a/roles/ipaclient/tasks/install.yml +++ b/roles/ipaclient/tasks/install.yml @@ -9,12 +9,12 @@ - name: Install - Set ipaclient_servers ansible.builtin.set_fact: - ipaclient_servers: "{{ groups['ipaservers'] | list }}" + ipaclient_servers: "{{ groups['ipaservers'] | map('extract', hostvars) | map(attribute='ansible_host') }}" when: groups.ipaservers is defined and ipaclient_servers is not defined - name: Install - Set ipaclient_servers from cluster inventory ansible.builtin.set_fact: - ipaclient_servers: "{{ groups['ipaserver'] | list }}" + ipaclient_servers: "{{ groups['ipaserver'] | map('extract', hostvars) | map(attribute='ansible_host') }}" when: ipaclient_no_dns_lookup | bool and groups.ipaserver is defined and ipaclient_servers is not defined