Merge "Allow creating /etc/hosts without Ansible facts"
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Allow creating ``/etc/hosts`` on all hosts when Ansible facts are not
|
||||
gathered for all hosts. The IP address for a host in ``/etc/hosts``
|
||||
may be hard-coded by setting ``etc_hosts_api_address`` in the inventory
|
||||
for each host, and when there are no facts available for a host,
|
||||
the FQDN and short hostname are generated from the Ansible
|
||||
magic-variables ``inventory_hostname`` and ``inventory_hostname_short``.
|
@@ -30,8 +30,17 @@
|
||||
{% for host in groups['baremetal'] %}
|
||||
{% set api_interface = hostvars[host]['api_interface'] | replace('-', '_') %}
|
||||
{% if host not in groups['bifrost'] or api_interface in hostvars[host].ansible_facts %}
|
||||
{% set hostnames = [hostvars[host].ansible_facts.nodename, hostvars[host].ansible_facts.hostname] %}
|
||||
{{ 'api' | kolla_address(host) }} {{ hostnames | unique | join(' ') }}
|
||||
{% set hostnames =
|
||||
[
|
||||
hostvars[host].ansible_facts.nodename
|
||||
if hostvars[host].ansible_facts.nodename is defined
|
||||
else hostvars[host].inventory_hostname,
|
||||
hostvars[host].ansible_facts.hostname
|
||||
if hostvars[host].ansible_facts.hostname is defined
|
||||
else hostvars[host].inventory_hostname_short
|
||||
]
|
||||
%}
|
||||
{{ 'api' | kolla_address(host, override_var="etc_hosts_api_address") }} {{ hostnames | unique | join(' ') }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
become: true
|
||||
|
Reference in New Issue
Block a user