Fix bootstrap-servers with invalid api_interface
When bootstrapping a host for kolla-ansible the 'kolla-ansible bootstrap-servers' command can fail if for any of the hosts the 'api_interface' is invalid. This happen if the host does not have a network interface matching 'api_interface'. This is possible on a host running bifrost, as bifrost does not require the api_interface variable to be set. This change avoids adding a hosts entry for hosts in the bifrost group that do not have a valid api_interface. It also avoids modifying the hosts file on hosts in the bifrost group that do not have a valid api_interface. Change-Id: Ie111ef54130adf2556ce83c402cdbb5058ace4f6 Closes-bug: #1665364
This commit is contained in:
parent
a5dfa415a9
commit
64b09d6eb0
@ -21,11 +21,18 @@
|
|||||||
dest: /etc/hosts
|
dest: /etc/hosts
|
||||||
marker: "# {mark} ANSIBLE GENERATED HOSTS"
|
marker: "# {mark} ANSIBLE GENERATED HOSTS"
|
||||||
block: |
|
block: |
|
||||||
{% for host in groups['all'] %}
|
{% for host in groups['baremetal'] %}
|
||||||
{{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }} {{ hostvars[host]['ansible_hostname'] }}
|
{% set api_interface = hostvars[host]['api_interface'] %}
|
||||||
|
{% if host not in groups['bifrost'] or 'ansible_' + api_interface in hostvars[host] %}
|
||||||
|
{{ hostvars[host]['ansible_' + api_interface]['ipv4']['address'] }} {{ hostvars[host]['ansible_hostname'] }}
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
become: True
|
become: True
|
||||||
when: customize_etc_hosts | bool
|
when:
|
||||||
|
- customize_etc_hosts | bool
|
||||||
|
# Skip hosts in the bifrost group that do not have a valid api_interface.
|
||||||
|
- inventory_hostname not in groups['bifrost'] or
|
||||||
|
'ansible_' + hostvars[inventory_hostname]['api_interface'] in hostvars[inventory_hostname]
|
||||||
|
|
||||||
- name: Ensure sudo group is present
|
- name: Ensure sudo group is present
|
||||||
group: name=sudo state=present
|
group: name=sudo state=present
|
||||||
|
Loading…
Reference in New Issue
Block a user