Skip to content

Commit

Permalink
ipareplica: Use hostvars data instead of inventory group name
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rjeffman committed Dec 2, 2024
1 parent 93b98f6 commit c62eb0a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions roles/ipareplica/tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c62eb0a

Please sign in to comment.