mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
restore play_hosts variables to not show removed
Also adds ansible_play_hosts_all with original list of hosts the play targeted
This commit is contained in:
parent
0b77942bbc
commit
5dd195b52f
4 changed files with 10 additions and 6 deletions
|
@ -503,6 +503,7 @@ class PlayIterator:
|
|||
s = self._set_failed_state(s)
|
||||
display.debug("^ failed state is now: %s" % s)
|
||||
self._host_states[host.name] = s
|
||||
self._play._removed_hosts.append(host.name)
|
||||
|
||||
def get_failed_hosts(self):
|
||||
return dict((host, True) for (host, state) in iteritems(self._host_states) if self._check_failed_state(state))
|
||||
|
|
|
@ -96,6 +96,7 @@ class Play(Base, Taggable, Become):
|
|||
super(Play, self).__init__()
|
||||
|
||||
self._included_path = None
|
||||
self._removed_hosts = []
|
||||
self.ROLE_CACHE = {}
|
||||
|
||||
def __repr__(self):
|
||||
|
|
|
@ -365,6 +365,7 @@ class StrategyBase:
|
|||
self._tqm.send_callback('v2_runner_on_failed', task_result, ignore_errors=original_task.ignore_errors)
|
||||
elif task_result.is_unreachable():
|
||||
self._tqm._unreachable_hosts[original_host.name] = True
|
||||
iterator._play._removed_hosts.append(original_host.name)
|
||||
self._tqm._stats.increment('dark', original_host.name)
|
||||
self._tqm.send_callback('v2_runner_on_unreachable', task_result)
|
||||
elif task_result.is_skipped():
|
||||
|
|
|
@ -410,12 +410,13 @@ class VariableManager:
|
|||
variables['inventory_file'] = self._inventory.src()
|
||||
if play:
|
||||
# add the list of hosts in the play, as adjusted for limit/filters
|
||||
# DEPRECATED: 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
|
||||
variables['play_hosts'] = [x.name for x in self._inventory.get_hosts()]
|
||||
variables['ansible_play_batch'] = [x.name for x in self._inventory.get_hosts()]
|
||||
variables['ansible_play_hosts'] = [x.name for x in self._inventory.get_hosts(pattern=play.hosts or 'all', ignore_restrictions=True)]
|
||||
variables['ansible_play_hosts_all'] = [x.name for x in self._inventory.get_hosts(pattern=play.hosts or 'all', ignore_restrictions=True)]
|
||||
variables['ansible_play_hosts'] = [x for x in variables['ansible_play_hosts_all'] if x not in play._removed_hosts]
|
||||
variables['ansible_play_batch'] = [x.name for x in self._inventory.get_hosts() if x.name not in play._removed_hosts]
|
||||
|
||||
#DEPRECATED: play_hosts should be deprecated in favor of ansible_play_batch,
|
||||
# however this would take work in the templating engine, so for now we'll add both
|
||||
variables['play_hosts'] = variables['ansible_play_batch']
|
||||
|
||||
# the 'omit' value alows params to be left out if the variable they are based on is undefined
|
||||
variables['omit'] = self._omit_token
|
||||
|
|
Loading…
Reference in a new issue