mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-31 17:11:23 -07:00
Create state in PlayIterator for unknown hosts rather than raise errors
Since we now use the PlayIterator to carry forward failures from previous play executions, in the event that some hosts which had previously failed are not in the current inventory we now create a stub state instead of raising an error.
This commit is contained in:
parent
f76befdb9a
commit
fa368934bd
1 changed files with 7 additions and 4 deletions
|
@ -216,10 +216,13 @@ class PlayIterator:
|
||||||
self._play.handlers.extend(play.compile_roles_handlers())
|
self._play.handlers.extend(play.compile_roles_handlers())
|
||||||
|
|
||||||
def get_host_state(self, host):
|
def get_host_state(self, host):
|
||||||
try:
|
# Since we're using the PlayIterator to carry forward failed hosts,
|
||||||
return self._host_states[host.name].copy()
|
# in the event that a previous host was not in the current inventory
|
||||||
except KeyError:
|
# we create a stub state for it now
|
||||||
raise AnsibleError("invalid host (%s) specified for playbook iteration" % host)
|
if host.name not in self._host_states:
|
||||||
|
self._host_states[host.name] = HostState(blocks=[])
|
||||||
|
|
||||||
|
return self._host_states[host.name].copy()
|
||||||
|
|
||||||
def get_next_task_for_host(self, host, peek=False):
|
def get_next_task_for_host(self, host, peek=False):
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue