restore play_hosts variables to not show removed
Also adds ansible_play_hosts_all with original list of hosts the play targeted
(cherry picked from commit 5dd195b52f
)
This commit is contained in:
parent
caba50c778
commit
9499ed5360
4 changed files with 10 additions and 6 deletions
|
@ -502,6 +502,7 @@ class PlayIterator:
|
||||||
s = self._set_failed_state(s)
|
s = self._set_failed_state(s)
|
||||||
display.debug("^ failed state is now: %s" % s)
|
display.debug("^ failed state is now: %s" % s)
|
||||||
self._host_states[host.name] = s
|
self._host_states[host.name] = s
|
||||||
|
self._play._removed_hosts.append(host.name)
|
||||||
|
|
||||||
def get_failed_hosts(self):
|
def get_failed_hosts(self):
|
||||||
return dict((host, True) for (host, state) in iteritems(self._host_states) if self._check_failed_state(state))
|
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__()
|
super(Play, self).__init__()
|
||||||
|
|
||||||
self._included_path = None
|
self._included_path = None
|
||||||
|
self._removed_hosts = []
|
||||||
self.ROLE_CACHE = {}
|
self.ROLE_CACHE = {}
|
||||||
|
|
||||||
def __repr__(self):
|
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)
|
self._tqm.send_callback('v2_runner_on_failed', task_result, ignore_errors=original_task.ignore_errors)
|
||||||
elif task_result.is_unreachable():
|
elif task_result.is_unreachable():
|
||||||
self._tqm._unreachable_hosts[original_host.name] = True
|
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._stats.increment('dark', original_host.name)
|
||||||
self._tqm.send_callback('v2_runner_on_unreachable', task_result)
|
self._tqm.send_callback('v2_runner_on_unreachable', task_result)
|
||||||
elif task_result.is_skipped():
|
elif task_result.is_skipped():
|
||||||
|
|
|
@ -410,12 +410,13 @@ class VariableManager:
|
||||||
variables['inventory_file'] = self._inventory.src()
|
variables['inventory_file'] = self._inventory.src()
|
||||||
if play:
|
if play:
|
||||||
# add the list of hosts in the play, as adjusted for limit/filters
|
# 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,
|
variables['ansible_play_hosts_all'] = [x.name for x in self._inventory.get_hosts(pattern=play.hosts or 'all', ignore_restrictions=True)]
|
||||||
# however this would take work in the templating engine, so for now
|
variables['ansible_play_hosts'] = [x for x in variables['ansible_play_hosts_all'] if x not in play._removed_hosts]
|
||||||
# we'll add both so we can give users something transitional to use
|
variables['ansible_play_batch'] = [x.name for x in self._inventory.get_hosts() if x.name not in play._removed_hosts]
|
||||||
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()]
|
#DEPRECATED: play_hosts should be deprecated in favor of ansible_play_batch,
|
||||||
variables['ansible_play_hosts'] = [x.name for x in self._inventory.get_hosts(pattern=play.hosts or 'all', ignore_restrictions=True)]
|
# 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
|
# the 'omit' value alows params to be left out if the variable they are based on is undefined
|
||||||
variables['omit'] = self._omit_token
|
variables['omit'] = self._omit_token
|
||||||
|
|
Loading…
Reference in a new issue