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

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
This commit is contained in:
Martin Krizek 2020-06-10 19:12:11 +02:00 committed by GitHub
parent a5679d4dd1
commit ac20466375
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View file

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

View file

@ -371,7 +371,9 @@ class Block(Base, Conditional, CollectionSearch, Taggable):
tmp_list = []
for task in target:
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
(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)):