Do not keep empty blocks after tag filtering (#69987) (#69999)

This prevents PlayIterator having to go through empty blocks
that were created in filter_tagged_tasks. This should
be a performance improvement for playbooks that mostly skip
tasks with tags.

ci_complete

(cherry picked from commit ac20466375)
pull/69860/head
Martin Krizek 5 years ago committed by GitHub
parent 94df27233f
commit 2cba0dc75c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- Do not keep empty blocks in PlayIterator after skipping tasks with tags.

@ -371,7 +371,9 @@ class Block(Base, Conditional, CollectionSearch, Taggable):
tmp_list = [] tmp_list = []
for task in target: for task in target:
if isinstance(task, Block): if isinstance(task, Block):
tmp_list.append(evaluate_block(task)) filtered_block = evaluate_block(task)
if filtered_block.has_tasks():
tmp_list.append(filtered_block)
elif (task.action == 'meta' or elif (task.action == 'meta' or
(task.action == 'include' and task.evaluate_tags([], self._play.skip_tags, all_vars=all_vars)) or (task.action == 'include' and task.evaluate_tags([], self._play.skip_tags, all_vars=all_vars)) or
task.evaluate_tags(self._play.only_tags, self._play.skip_tags, all_vars=all_vars)): task.evaluate_tags(self._play.only_tags, self._play.skip_tags, all_vars=all_vars)):

Loading…
Cancel
Save