From a743d4c81fc202633f68ebcc132bc9ae19030270 Mon Sep 17 00:00:00 2001 From: Logan V Date: Fri, 29 Jun 2018 23:44:37 -0500 Subject: [PATCH] Template the physical host address In the scenario where the fallback group 'all' is used to find the physical host address, there are typically containers present in this group with ansible_host settings like "{{ container_name }}". When this happens, you get physical_host_addrs lists like: aiotest1 127.0.0.1 test1 1.1.1.1 test-1-zbx1 {{ container_name }} test-1-cdns1 {{ container_name }} test-1-lb1 {{ container_name }} test-1-lb2 {{ container_name }} fatal: [aiotest1]: FAILED! => {"msg": "'container_name' is undefined"} To avoid this we need to run the physical_host_addr through a templar loaded with the physical_host_vars: aiotest1 127.0.0.1 test1 1.1.1.1 test-1-zbx1 test-1-zbx1 test-1-cdns1 test-1-cdns1 test-1-lb1 test-1-lb1 test-1-lb2 test-1-lb2 test-1-tpxy1 test-1-tpxy1 ok: [aiotest1] Change-Id: I7a4e89c579a3e688decaeb91b9035500129c7b16 --- strategy/linear.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/strategy/linear.py b/strategy/linear.py index 495c2b3a..4dcf40d9 100644 --- a/strategy/linear.py +++ b/strategy/linear.py @@ -135,8 +135,11 @@ class StrategyModule(LINEAR.StrategyModule): physical_host_vars = self._variable_manager.get_vars( host=self._inventory.get_host(physical_host) ) - physical_host_addr = physical_host_vars.get('ansible_host', - physical_host) + physical_host_templar = LINEAR.Templar(loader=self._loader, + variables=physical_host_vars) + physical_host_addr = physical_host_templar.template( + physical_host_vars.get('ansible_host', + physical_host)) physical_host_addrs[physical_host] = physical_host_addr task_vars['physical_host_addrs'] = physical_host_addrs