From 57372906aa937823b6c4e23c95f5c5baddd2d541 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Fri, 2 Oct 2015 02:47:09 -0400 Subject: [PATCH] Pull host/group vars when adding hosts/groups Fixes #12582 --- lib/ansible/inventory/__init__.py | 2 +- lib/ansible/plugins/strategy/__init__.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ansible/inventory/__init__.py b/lib/ansible/inventory/__init__.py index 3e33c4c8394..438ab798e7f 100644 --- a/lib/ansible/inventory/__init__.py +++ b/lib/ansible/inventory/__init__.py @@ -677,7 +677,7 @@ class Inventory(object): # this can happen from particular API usages, particularly if not run # from /usr/bin/ansible-playbook - if basedir is None: + if basedir in ('', None): basedir = './' scan_pass = scan_pass + 1 diff --git a/lib/ansible/plugins/strategy/__init__.py b/lib/ansible/plugins/strategy/__init__.py index 8067d25b46c..44727a1168d 100644 --- a/lib/ansible/plugins/strategy/__init__.py +++ b/lib/ansible/plugins/strategy/__init__.py @@ -327,6 +327,7 @@ class StrategyBase: # Set/update the vars for this host # FIXME: probably should have a set vars method for the host? new_vars = host_info.get('host_vars', dict()) + new_host.vars = self._inventory.get_host_vars(new_host) new_host.vars.update(new_vars) new_groups = host_info.get('groups', []) @@ -379,6 +380,7 @@ class StrategyBase: # create the new group and add it to inventory new_group = Group(name=group_name) self._inventory.add_group(new_group) + new_group.vars = self._inventory.get_group_vars(new_group) # and add the group to the proper hierarchy allgroup = self._inventory.get_group('all')