revert ocalhost getting 'all' vars (#31425)
back to previous implicit localhost behaviour
fixes #31420
(cherry picked from commit a9942353fe
)
This commit is contained in:
parent
4f4905c88a
commit
058ed81aa0
4 changed files with 10 additions and 11 deletions
|
@ -108,6 +108,7 @@ Ansible Changes By Release
|
||||||
* Fix for win_copy to copy a source file that has invalid windows characters in the filename, the dest still must be have valid windows characters (https://github.com/ansible/ansible/issues/31336#issuecomment-334649927)
|
* Fix for win_copy to copy a source file that has invalid windows characters in the filename, the dest still must be have valid windows characters (https://github.com/ansible/ansible/issues/31336#issuecomment-334649927)
|
||||||
* Fix systemd module to not run daemon-reload in check mode.
|
* Fix systemd module to not run daemon-reload in check mode.
|
||||||
* fixed some parsing and selection issues with inventory manager, fixed minor bugs in yaml and constructed plugins
|
* fixed some parsing and selection issues with inventory manager, fixed minor bugs in yaml and constructed plugins
|
||||||
|
* reverted implicit localhost getting vars from 'all' group
|
||||||
|
|
||||||
<a id="2.4"></a>
|
<a id="2.4"></a>
|
||||||
|
|
||||||
|
|
|
@ -79,9 +79,6 @@ class InventoryData(object):
|
||||||
else:
|
else:
|
||||||
new_host = Host(pattern)
|
new_host = Host(pattern)
|
||||||
|
|
||||||
# use 'all' vars but not part of all group
|
|
||||||
new_host.vars = self.groups['all'].get_vars()
|
|
||||||
|
|
||||||
new_host.address = "127.0.0.1"
|
new_host.address = "127.0.0.1"
|
||||||
new_host.implicit = True
|
new_host.implicit = True
|
||||||
|
|
||||||
|
|
|
@ -143,7 +143,7 @@ class Host:
|
||||||
results['inventory_hostname_short'] = self.name.split('.')[0]
|
results['inventory_hostname_short'] = self.name.split('.')[0]
|
||||||
results['group_names'] = sorted([g.name for g in self.get_groups() if g.name != 'all'])
|
results['group_names'] = sorted([g.name for g in self.get_groups() if g.name != 'all'])
|
||||||
|
|
||||||
return combine_vars(self.vars, results)
|
return results
|
||||||
|
|
||||||
def get_vars(self):
|
def get_vars(self):
|
||||||
return combine_vars(self.vars, self.get_magic_vars())
|
return combine_vars(self.vars, self.get_magic_vars())
|
||||||
|
|
|
@ -319,14 +319,15 @@ class VariableManager:
|
||||||
data[group] = combine_vars(data[group], _plugins_play(group))
|
data[group] = combine_vars(data[group], _plugins_play(group))
|
||||||
return data
|
return data
|
||||||
|
|
||||||
# Merge as per precedence config
|
# Merge groups as per precedence config, if not implicit localhost
|
||||||
# only allow to call the functions we want exposed
|
# only allow to call the functions we want exposed
|
||||||
for entry in C.VARIABLE_PRECEDENCE:
|
if not host.implicit:
|
||||||
if entry in self._ALLOWED:
|
for entry in C.VARIABLE_PRECEDENCE:
|
||||||
display.debug('Calling %s to load vars for %s' % (entry, host.name))
|
if entry in self._ALLOWED:
|
||||||
all_vars = combine_vars(all_vars, locals()[entry]())
|
display.debug('Calling %s to load vars for %s' % (entry, host.name))
|
||||||
else:
|
all_vars = combine_vars(all_vars, locals()[entry]())
|
||||||
display.warning('Ignoring unknown variable precedence entry: %s' % (entry))
|
else:
|
||||||
|
display.warning('Ignoring unknown variable precedence entry: %s' % (entry))
|
||||||
|
|
||||||
# host vars, from inventory, inventory adjacent and play adjacent via plugins
|
# host vars, from inventory, inventory adjacent and play adjacent via plugins
|
||||||
all_vars = combine_vars(all_vars, host.get_vars())
|
all_vars = combine_vars(all_vars, host.get_vars())
|
||||||
|
|
Loading…
Reference in a new issue