Commit 57372906 by James Cammarata

Pull host/group vars when adding hosts/groups

Fixes #12582
parent aa3687d7
...@@ -677,7 +677,7 @@ class Inventory(object): ...@@ -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
......
...@@ -327,6 +327,7 @@ class StrategyBase: ...@@ -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: ...@@ -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')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment