Fix the physical_host_addr vars lookup

The inventory lookup to determine the map of physical_host ->
ansible_host vars was never locating ansible_host, and instead
always defaulted to physical_host's inventory_hostname.

This fixes the lookup so the inventory_hostname will only be used
as a fallback if ansible_host is not set on the physical_host.

Change-Id: Ibbadbaf2a6a5b7323ee6587da3773b8459fa2eb6
This commit is contained in:
Logan V 2017-07-05 09:01:01 -05:00
parent ca87421e46
commit 6c6753bbed
1 changed files with 3 additions and 2 deletions

View File

@ -120,8 +120,9 @@ class StrategyModule(LINEAR.StrategyModule):
physical_hosts = groups.get('hosts', groups.get('all', {}))
physical_host_addrs = {}
for physical_host in physical_hosts:
physical_host_vars = self._inventory.get_host_variables(physical_host)
physical_host_addr = physical_host_vars.get('ansible_host', physical_host)
physical_host_vars = self._inventory.get_host(physical_host).vars
physical_host_addr = physical_host_vars.get('ansible_host',
physical_host)
physical_host_addrs[physical_host] = physical_host_addr
host.set_variable('physical_host_addrs', physical_host_addrs)