1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Don't clear start at task flag until all hosts are advanced

Clearing the flag after the first host was advanced caused all other
hosts to not advance at all.

Fixes #13864
This commit is contained in:
James Cammarata 2016-01-18 22:47:42 -05:00
parent d09c9f526b
commit 1f7492171e

View file

@ -137,30 +137,35 @@ class PlayIterator:
self._blocks.append(new_block) self._blocks.append(new_block)
self._host_states = {} self._host_states = {}
start_at_matched = False
for host in inventory.get_hosts(self._play.hosts): for host in inventory.get_hosts(self._play.hosts):
self._host_states[host.name] = HostState(blocks=self._blocks) self._host_states[host.name] = HostState(blocks=self._blocks)
# if the host's name is in the variable manager's fact cache, then set # if the host's name is in the variable manager's fact cache, then set
# its _gathered_facts flag to true for smart gathering tests later # its _gathered_facts flag to true for smart gathering tests later
if host.name in variable_manager._fact_cache: if host.name in variable_manager._fact_cache:
host._gathered_facts = True host._gathered_facts = True
# if we're looking to start at a specific task, iterate through # if we're looking to start at a specific task, iterate through
# the tasks for this host until we find the specified task # the tasks for this host until we find the specified task
if play_context.start_at_task is not None and not start_at_done: if play_context.start_at_task is not None and not start_at_done:
while True: while True:
(s, task) = self.get_next_task_for_host(host, peek=True) (s, task) = self.get_next_task_for_host(host, peek=True)
if s.run_state == self.ITERATING_COMPLETE: if s.run_state == self.ITERATING_COMPLETE:
break break
if task.name == play_context.start_at_task or fnmatch.fnmatch(task.name, play_context.start_at_task) or \ if task.name == play_context.start_at_task or fnmatch.fnmatch(task.name, play_context.start_at_task) or \
task.get_name() == play_context.start_at_task or fnmatch.fnmatch(task.get_name(), play_context.start_at_task): task.get_name() == play_context.start_at_task or fnmatch.fnmatch(task.get_name(), play_context.start_at_task):
# we have our match, so clear the start_at_task field on the start_at_matched = True
# play context to flag that we've started at a task (and future break
# plays won't try to advance) else:
play_context.start_at_task = None self.get_next_task_for_host(host)
break
else: # finally, reset the host's state to ITERATING_SETUP
self.get_next_task_for_host(host) self._host_states[host.name].run_state = self.ITERATING_SETUP
# finally, reset the host's state to ITERATING_SETUP
self._host_states[host.name].run_state = self.ITERATING_SETUP if start_at_matched:
# we have our match, so clear the start_at_task field on the
# play context to flag that we've started at a task (and future
# plays won't try to advance)
play_context.start_at_task = None
# Extend the play handlers list to include the handlers defined in roles # Extend the play handlers list to include the handlers defined in roles
self._play.handlers.extend(play.compile_roles_handlers()) self._play.handlers.extend(play.compile_roles_handlers())