diff options
author | James Cammarata <jimi@sngx.net> | 2016-06-06 02:38:37 -0500 |
---|---|---|
committer | James Cammarata <jimi@sngx.net> | 2016-06-06 02:38:37 -0500 |
commit | e431e30cb47b4996046bb4dd78259d5ee9e255e9 (patch) | |
tree | 152d1c3b0659564c6505d492ebf020d92cb32ff3 | |
parent | 6e48b32ab638ee56cfe35c82e217ef0465a209c6 (diff) | |
download | ansible-issue_16117.tar.gz |
Make sure we add host/group vars files when parsing inventoryissue_16117
Also fixes a bug where add_host was not adding the vars files
Fixes #16117
-rw-r--r-- | lib/ansible/inventory/__init__.py | 4 | ||||
-rw-r--r-- | lib/ansible/plugins/strategy/__init__.py | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/lib/ansible/inventory/__init__.py b/lib/ansible/inventory/__init__.py index b306bf255b..303a1fcb44 100644 --- a/lib/ansible/inventory/__init__.py +++ b/lib/ansible/inventory/__init__.py @@ -148,10 +148,12 @@ class Inventory(object): for g in self.groups: group = self.groups[g] group.vars = combine_vars(group.vars, self.get_group_variables(group.name)) + self.get_group_vars(group) # set host vars from host_vars/ files and vars plugins for host in self.get_hosts(): host.vars = combine_vars(host.vars, self.get_host_variables(host.name)) + self.get_host_vars(host) def _match(self, str, pattern_str): try: @@ -703,7 +705,7 @@ class Inventory(object): found_host_vars = self._find_host_vars_files(self._playbook_basedir) if found_host_vars: - self._host_vars_files = self._find_host_vars_files(self._playbook_basedir) + self._host_vars_files.union(found_host_vars) # get host vars from host_vars/ files for host in self.get_hosts(): self.get_host_vars(host) diff --git a/lib/ansible/plugins/strategy/__init__.py b/lib/ansible/plugins/strategy/__init__.py index c93626a7ed..bb1cede6f3 100644 --- a/lib/ansible/plugins/strategy/__init__.py +++ b/lib/ansible/plugins/strategy/__init__.py @@ -425,6 +425,7 @@ class StrategyBase: if not new_host: new_host = Host(name=host_name) self._inventory._hosts_cache[host_name] = new_host + self._inventory.get_host_vars(new_host) allgroup = self._inventory.get_group('all') allgroup.add_host(new_host) @@ -438,6 +439,7 @@ class StrategyBase: if not self._inventory.get_group(group_name): new_group = Group(group_name) self._inventory.add_group(new_group) + self._inventory.get_group_vars(new_group) new_group.vars = self._inventory.get_group_variables(group_name) else: new_group = self._inventory.get_group(group_name) |