Skip to content

Commit

Permalink
Create state in PlayIterator for unknown hosts rather than raise errors
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jimi-c committed Jun 7, 2016
1 parent f76befd commit fa36893
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/ansible/executor/play_iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,13 @@ def __init__(self, inventory, play, play_context, variable_manager, all_vars, st
self._play.handlers.extend(play.compile_roles_handlers())

def get_host_state(self, host):
try:
return self._host_states[host.name].copy()
except KeyError:
raise AnsibleError("invalid host (%s) specified for playbook iteration" % host)
# Since we're using the PlayIterator to carry forward failed hosts,
# in the event that a previous host was not in the current inventory
# we create a stub state for it now
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):

Expand Down

0 comments on commit fa36893

Please sign in to comment.