From 6340d58cd1f50f77e309408dd79c34176d116efc Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 7 Feb 2018 18:21:55 -0500 Subject: [PATCH] add 'never' tag (#34104) * add 'never' tag skips a task unless a tag on the task is explicitly targeted * never also affects untagged, clearer layout --- lib/ansible/playbook/taggable.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/ansible/playbook/taggable.py b/lib/ansible/playbook/taggable.py index b21638263ff..91b0191d2b0 100644 --- a/lib/ansible/playbook/taggable.py +++ b/lib/ansible/playbook/taggable.py @@ -50,8 +50,6 @@ class Taggable: def evaluate_tags(self, only_tags, skip_tags, all_vars): ''' this checks if the current item should be executed depending on tag options ''' - should_run = True - if self.tags: templar = Templar(loader=self._loader, variables=all_vars) tags = templar.template(self.tags) @@ -67,16 +65,19 @@ class Taggable: # this makes isdisjoint work for untagged tags = self.untagged - if only_tags: - - should_run = False + should_run = True # default, tasks to run - if 'always' in tags or 'all' in only_tags: + if only_tags: + if 'always' in tags: + should_run = True + elif ('all' in only_tags and 'never' not in tags): should_run = True elif not tags.isdisjoint(only_tags): should_run = True - elif 'tagged' in only_tags and tags != self.untagged: + elif 'tagged' in only_tags and tags != self.untagged and 'never' not in tags: should_run = True + else: + should_run = False if should_run and skip_tags: