freeipa / ansible-freeipa

Ansible roles and modules for FreeIPA
GNU General Public License v3.0
495 stars 232 forks source link

ipaserver: Use ansible_host instead of group name #1209

Open rjeffman opened 8 months ago

rjeffman commented 8 months ago

Deployment of any node fails when hosts defined in groups do not represent the hostname, for example, when using ansible_host.

For example, the following inventory YAML file would fail deployment:

---
all:
  children:
    ipaserver:
      hosts:
        ipa_server:
          ansible_host: "{{ ipaserver_hostname }}"
          ansible_user: root
      vars:
        ipaserver_setup_ca: true
        ipaserver_setup_dns: true
        ipaserver_no_forwarders: true
        ipaserver_auto_reverse: true
        ipaserver_allow_zone_overlap: true
        ipaserver_setup_adtrust: true
        ipaserver_netbios_name: IPA 
        ipaserver_random_serial_numbers: true
        ipaserver_no_hbac_allow: false
  vars:
    ipaserver_hostname: server.lin.ipa.test

By maping the inventory name to the actual ansible_host the inventory file can act as a template, and the node names can use ansible_host to set the actual host.

The changes affect only ipaserver and ipaclient roles, as ipareplica uses ipaclient for the host setup, before promoting host to replica.