Skip to content

Commit

Permalink
revert ocalhost getting 'all' vars (ansible#31425)
Browse files Browse the repository at this point in the history
back to previous implicit localhost behaviour

fixes ansible#31420
  • Loading branch information
bcoca authored Oct 6, 2017
1 parent e4c61ea commit a994235
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
3 changes: 0 additions & 3 deletions lib/ansible/inventory/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ def _create_implicit_localhost(self, pattern):
else:
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.implicit = True

Expand Down
2 changes: 1 addition & 1 deletion lib/ansible/inventory/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def get_magic_vars(self):
results['inventory_hostname_short'] = self.name.split('.')[0]
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):
return combine_vars(self.vars, self.get_magic_vars())
15 changes: 8 additions & 7 deletions lib/ansible/vars/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,14 +319,15 @@ def plugins_by_groups():
data[group] = combine_vars(data[group], _plugins_play(group))
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
for entry in C.VARIABLE_PRECEDENCE:
if entry in self._ALLOWED:
display.debug('Calling %s to load vars for %s' % (entry, host.name))
all_vars = combine_vars(all_vars, locals()[entry]())
else:
display.warning('Ignoring unknown variable precedence entry: %s' % (entry))
if not host.implicit:
for entry in C.VARIABLE_PRECEDENCE:
if entry in self._ALLOWED:
display.debug('Calling %s to load vars for %s' % (entry, host.name))
all_vars = combine_vars(all_vars, locals()[entry]())
else:
display.warning('Ignoring unknown variable precedence entry: %s' % (entry))

# host vars, from inventory, inventory adjacent and play adjacent via plugins
all_vars = combine_vars(all_vars, host.get_vars())
Expand Down

0 comments on commit a994235

Please sign in to comment.