Hi,
Are there any generally accepted best practices regarding host aliases?
E.g. I have a bunch of similar environments (dev/stage/prod or different
customers with similar setups or whatever) where different machines play
the same roles. For example:
# inventory:
somehost1.example.com
somehost2.example.com
somehost3.example.com
[vpn_hub]
somehost1.example.com
[vpn_client]
somehost2.example.com
somehost3.example.com
# in a top level playbook
- hosts: vpn_hub
roles:
- vpn_hub
- hosts: vpn_client
roles:
- vpn_client
# in a playbook for the vpn_client role:
- name: generate vpn cert
delegate_to: groups.vpn_hub[0]
# in a template (for the vpn_client role too)
remote {{ groups.vpn_hub[0].ansible_default_ipv4.address }}
I want neither the machine to be called vpn_hub everywhere, nor to
hardcode somehost1.example.com in playbooks, but the groups.vpn_hub[0]
is ugly. Is there a better way?
Best regards,
Grzegorz Nosek