mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 05:10:22 -07:00
Implement play_hosts magic variable (and ansible_current_hosts)
Fixes #8073
This commit is contained in:
parent
cb5f630f33
commit
7490044bbe
3 changed files with 22 additions and 0 deletions
|
@ -227,6 +227,15 @@ class VariableManager:
|
|||
|
||||
if self._inventory is not None:
|
||||
all_vars['inventory_dir'] = self._inventory.basedir()
|
||||
if play:
|
||||
# add the list of hosts in the play, as adjusted for limit/filters
|
||||
# FIXME: play_hosts should be deprecated in favor of ansible_play_hosts,
|
||||
# however this would take work in the templating engine, so for now
|
||||
# we'll add both so we can give users something transitional to use
|
||||
host_list = [x.name for x in self._inventory.get_hosts()]
|
||||
all_vars['play_hosts'] = host_list
|
||||
all_vars['ansible_play_hosts'] = host_list
|
||||
|
||||
|
||||
# the 'omit' value alows params to be left out if the variable they are based on is undefined
|
||||
all_vars['omit'] = self._omit_token
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue