vitabaks / postgresql_cluster

PostgreSQL High-Availability Cluster (based on "Patroni" and DCS "etcd" or "consul"). Automating with Ansible.
MIT License
1.27k stars 340 forks source link

Using IP address instead of hostname in Ansible AWX/Tower #question #612

Open silverbullet0201 opened 1 month ago

silverbullet0201 commented 1 month ago

Current situation: I use ansible tower (a.k.a. AWX) to manage our infrastructure Names of our hosts are human-readable names like pg-node-01, pg-node-02, ...

When I run deploy_pgcluster.yaml playbook it fails in Enable and start etcd service task because in the etcd settings like ETCD_LISTEN_CLIENT_URLS and ETCD_ADVERTISE_CLIENT_URLS hostname (value from inventory_hostname) is used instead of host's IP address


My question is next: Can we make playbook roles to use IP-address of the hostname (from ansible_host variable from inventory for example) instead of inventory hostname (inventory_hostname variable is in use currently)

Maybe there's option like adding variable ansible_host to inventory and replacing {{ inventory_hostname }} to {{ ansible_host | default(inventory_hostname) }} in ./roles/etcd/templates/etcd.conf.j2 (or in any other place that required)


There's some example: IP-address is used instead of hostname (etcd service is running and working)

ETCD_LISTEN_CLIENT_URLS="http://1.2.3.4:2379,http://127.0.0.1:2379"
ETCD_ADVERTISE_CLIENT_URLS="http://1.2.3.4:2379"
# ...

hostname is used instead of IP-address (etcd service is stopping just after start)

ETCD_LISTEN_CLIENT_URLS="http://pg-node-01:2379,http://127.0.0.1:2379"
ETCD_ADVERTISE_CLIENT_URLS="http://pg-node-01:2379"
# ...
vitabaks commented 1 month ago

Yes, it must be done. It is not the first request on the topic inventory_hostname.

Currently, it is required to specify IP addresses.