From 6c6753bbede974a4f787f0e574e693ac0414371c Mon Sep 17 00:00:00 2001 From: Logan V Date: Wed, 5 Jul 2017 09:01:01 -0500 Subject: [PATCH] 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 --- strategy/linear.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/strategy/linear.py b/strategy/linear.py index 3452761..f43c04d 100644 --- a/strategy/linear.py +++ b/strategy/linear.py @@ -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)