Pull host/group vars when adding hosts/groups

Fixes #12582
This commit is contained in:
James Cammarata 2015-10-02 02:47:09 -04:00
parent aa3687d736
commit 57372906aa
2 changed files with 3 additions and 1 deletions

View file

@ -677,7 +677,7 @@ class Inventory(object):
# this can happen from particular API usages, particularly if not run # this can happen from particular API usages, particularly if not run
# from /usr/bin/ansible-playbook # from /usr/bin/ansible-playbook
if basedir is None: if basedir in ('', None):
basedir = './' basedir = './'
scan_pass = scan_pass + 1 scan_pass = scan_pass + 1

View file

@ -327,6 +327,7 @@ class StrategyBase:
# Set/update the vars for this host # Set/update the vars for this host
# FIXME: probably should have a set vars method for the host? # FIXME: probably should have a set vars method for the host?
new_vars = host_info.get('host_vars', dict()) 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_host.vars.update(new_vars)
new_groups = host_info.get('groups', []) new_groups = host_info.get('groups', [])
@ -379,6 +380,7 @@ class StrategyBase:
# create the new group and add it to inventory # create the new group and add it to inventory
new_group = Group(name=group_name) new_group = Group(name=group_name)
self._inventory.add_group(new_group) self._inventory.add_group(new_group)
new_group.vars = self._inventory.get_group_vars(new_group)
# and add the group to the proper hierarchy # and add the group to the proper hierarchy
allgroup = self._inventory.get_group('all') allgroup = self._inventory.get_group('all')