From 57106662dbcffec50677d4802980c3d934258b8b Mon Sep 17 00:00:00 2001 From: Denver Janke Date: Wed, 8 Nov 2017 14:10:00 +1000 Subject: [PATCH] Get (potentially) new composite host vars from inventory (#32606) * Get new composite host vars from inventory * Remove spaces from blank line --- lib/ansible/plugins/inventory/constructed.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/ansible/plugins/inventory/constructed.py b/lib/ansible/plugins/inventory/constructed.py index ce7a53db44..ba1a3d461e 100644 --- a/lib/ansible/plugins/inventory/constructed.py +++ b/lib/ansible/plugins/inventory/constructed.py @@ -116,6 +116,11 @@ class InventoryModule(BaseInventoryPlugin): # create composite vars self._set_composite_vars(data.get('compose'), hostvars, host, strict=strict) + # refetch host vars in case new ones have been created above + hostvars = inventory.hosts[host].get_vars() + if host in self._cache: # adds facts if cache is active + hostvars = combine_vars(hostvars, self._cache[host]) + # constructed groups based on conditionals self._add_host_to_composed_groups(data.get('groups'), hostvars, host, strict=strict)