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
1 changed files with 1 additions and 1 deletions

View File

@ -29,7 +29,7 @@
{%- else -%}
{%- set _bridge = 'no_bridge_defined' -%}
{%- 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'] }}
{%- elif _network_data['address'] is defined -%}
{{ _network_data['address'] }}