diff options
author | James Cammarata <jimi@sngx.net> | 2016-07-06 14:40:11 -0500 |
---|---|---|
committer | James Cammarata <jimi@sngx.net> | 2016-07-06 14:57:38 -0500 |
commit | 930d0905074ccf6537d0ecf14259a7da6a9559fb (patch) | |
tree | bc69c4016937495d650db8b2db8ee7eb53b8dd9f /lib/ansible/playbook/role/__init__.py | |
parent | 729686a434094d23ecd3fe81c0443059db073817 (diff) | |
download | ansible-930d0905074ccf6537d0ecf14259a7da6a9559fb.tar.gz |
Fix the way handlers are compiled and found/notified
* Instead of rebuilding the handler list all over the place, we now
compile the handlers at the point the play is post-validated so that
the view of the play in the PlayIterator contains the definitive list
* Assign the dep_chain to the handlers as they're compiling, just as we
do for regular tasks
* Clean up the logic used to find a given handler, which is greatly
simplified by the above changes
Fixes #15418
Diffstat (limited to 'lib/ansible/playbook/role/__init__.py')
-rw-r--r-- | lib/ansible/playbook/role/__init__.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/ansible/playbook/role/__init__.py b/lib/ansible/playbook/role/__init__.py index 6793feb343..3f1908c754 100644 --- a/lib/ansible/playbook/role/__init__.py +++ b/lib/ansible/playbook/role/__init__.py @@ -301,12 +301,24 @@ class Role(Base, Become, Conditional, Taggable): def get_task_blocks(self): return self._task_blocks[:] - def get_handler_blocks(self): + def get_handler_blocks(self, play, dep_chain=None): block_list = [] + + # update the dependency chain here + if dep_chain is None: + dep_chain = [] + new_dep_chain = dep_chain + [self] + for dep in self.get_direct_dependencies(): - dep_blocks = dep.get_handler_blocks() + dep_blocks = dep.get_handler_blocks(play=play, dep_chain=new_dep_chain) block_list.extend(dep_blocks) - block_list.extend(self._handler_blocks) + + for task_block in self._handler_blocks: + new_task_block = task_block.copy() + new_task_block._dep_chain = new_dep_chain + new_task_block._play = play + block_list.append(new_task_block) + return block_list def has_run(self, host): |