Pull host/group vars when adding hosts/groups

Fixes #12582
pull/12190/head^2
James Cammarata 9 years ago
parent aa3687d736
commit 57372906aa

@ -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

@ -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')

Loading…
Cancel
Save