diff options
Diffstat (limited to 'lib/ansible/playbook/task.py')
-rw-r--r-- | lib/ansible/playbook/task.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/ansible/playbook/task.py b/lib/ansible/playbook/task.py index 4836abd2f5..7fd480c895 100644 --- a/lib/ansible/playbook/task.py +++ b/lib/ansible/playbook/task.py @@ -148,7 +148,7 @@ class Task(Base, Conditional, Taggable, CollectionSearch): def __repr__(self): ''' returns a human readable representation of the task ''' - if self.get_name() == 'meta': + if self.get_name() in C._ACTION_META: return "TASK: meta (%s)" % self.args['_raw_params'] else: return "TASK: %s" % self.get_name() @@ -223,7 +223,7 @@ class Task(Base, Conditional, Taggable, CollectionSearch): # the command/shell/script modules used to support the `cmd` arg, # which corresponds to what we now call _raw_params, so move that # value over to _raw_params (assuming it is empty) - if action in ('command', 'shell', 'script'): + if action in C._ACTION_HAS_CMD: if 'cmd' in args: if args.get('_raw_params', '') != '': raise AnsibleError("The 'cmd' argument cannot be used when other raw parameters are specified." @@ -255,7 +255,7 @@ class Task(Base, Conditional, Taggable, CollectionSearch): # pre-2.0 syntax allowed variables for include statements at the top level of the task, # so we move those into the 'vars' dictionary here, and show a deprecation message # as we will remove this at some point in the future. - if action in ('include',) and k not in self._valid_attrs and k not in self.DEPRECATED_ATTRIBUTES: + if action in C._ACTION_INCLUDE and k not in self._valid_attrs and k not in self.DEPRECATED_ATTRIBUTES: display.deprecated("Specifying include variables at the top-level of the task is deprecated." " Please see:\nhttps://docs.ansible.com/ansible/playbooks_roles.html#task-include-files-and-encouraging-reuse\n\n" " for currently supported syntax regarding included files and variables", version="2.12") @@ -318,7 +318,7 @@ class Task(Base, Conditional, Taggable, CollectionSearch): env[k] = templar.template(v, convert_bare=False) except AnsibleUndefinedVariable as e: error = to_native(e) - if self.action in ('setup', 'gather_facts') and 'ansible_facts.env' in error or 'ansible_env' in error: + if self.action in C._ACTION_FACT_GATHERING and 'ansible_facts.env' in error or 'ansible_env' in error: # ignore as fact gathering is required for 'env' facts return raise @@ -385,7 +385,7 @@ class Task(Base, Conditional, Taggable, CollectionSearch): all_vars = dict() if self._parent: all_vars.update(self._parent.get_include_params()) - if self.action in ('include', 'include_tasks', 'include_role'): + if self.action in C._ACTION_ALL_INCLUDES: all_vars.update(self.vars) return all_vars |