Avoid retrieving IP from a missing bridge

On hosts that do not have any containers (ie. computes) network bridges
are not needed and may introduce some unwanted overhead. This
configuration was possible until Mitaka, but broke with the
dynamic-address-fact.yml tasks in Newton.

This change checks if the bridge actually exists and otherwise uses the
IP configured in the inventory instead.

Change-Id: I23668429a19f00f520ac18c76254e83708778d5a
This commit is contained in:
Gaudenz Steinlin 2017-12-01 22:43:13 +01:00
parent 1ab7a86b39
commit ea32c3da76

View File

@ -29,7 +29,7 @@
{%- else -%} {%- else -%}
{%- set _bridge = 'no_bridge_defined' -%} {%- set _bridge = 'no_bridge_defined' -%}
{%- endif -%} {%- endif -%}
{%- if _bridge != 'no_bridge_defined' and hostvars[inventory_hostname]['ansible_' + _bridge]['ipv4'] is defined-%} {%- if _bridge != 'no_bridge_defined' and hostvars[inventory_hostname]['ansible_' + _bridge] is defined and hostvars[inventory_hostname]['ansible_' + _bridge]['ipv4'] is defined-%}
{{ hostvars[inventory_hostname]['ansible_' + _bridge]['ipv4']['address'] }} {{ hostvars[inventory_hostname]['ansible_' + _bridge]['ipv4']['address'] }}
{%- elif _network_data['address'] is defined -%} {%- elif _network_data['address'] is defined -%}
{{ _network_data['address'] }} {{ _network_data['address'] }}