diff options
Diffstat (limited to 'lib/ansible/playbook/task.py')
-rw-r--r-- | lib/ansible/playbook/task.py | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/lib/ansible/playbook/task.py b/lib/ansible/playbook/task.py index a1a1162b..fa1114ad 100644 --- a/lib/ansible/playbook/task.py +++ b/lib/ansible/playbook/task.py @@ -21,17 +21,19 @@ __metaclass__ = type from ansible import constants as C from ansible.errors import AnsibleError, AnsibleParserError, AnsibleUndefinedVariable, AnsibleAssertionError -from ansible.module_utils._text import to_native +from ansible.module_utils.common.text.converters import to_native from ansible.module_utils.six import string_types from ansible.parsing.mod_args import ModuleArgsParser from ansible.parsing.yaml.objects import AnsibleBaseYAMLObject, AnsibleMapping from ansible.plugins.loader import lookup_loader -from ansible.playbook.attribute import FieldAttribute, NonInheritableFieldAttribute +from ansible.playbook.attribute import NonInheritableFieldAttribute from ansible.playbook.base import Base from ansible.playbook.block import Block from ansible.playbook.collectionsearch import CollectionSearch from ansible.playbook.conditional import Conditional +from ansible.playbook.delegatable import Delegatable from ansible.playbook.loop_control import LoopControl +from ansible.playbook.notifiable import Notifiable from ansible.playbook.role import Role from ansible.playbook.taggable import Taggable from ansible.utils.collection_loader import AnsibleCollectionConfig @@ -43,7 +45,7 @@ __all__ = ['Task'] display = Display() -class Task(Base, Conditional, Taggable, CollectionSearch): +class Task(Base, Conditional, Taggable, CollectionSearch, Notifiable, Delegatable): """ A task is a language feature that represents a call to a module, with given arguments and other parameters. @@ -72,15 +74,12 @@ class Task(Base, Conditional, Taggable, CollectionSearch): async_val = NonInheritableFieldAttribute(isa='int', default=0, alias='async') changed_when = NonInheritableFieldAttribute(isa='list', default=list) delay = NonInheritableFieldAttribute(isa='int', default=5) - delegate_to = FieldAttribute(isa='string') - delegate_facts = FieldAttribute(isa='bool') failed_when = NonInheritableFieldAttribute(isa='list', default=list) - loop = NonInheritableFieldAttribute() + loop = NonInheritableFieldAttribute(isa='list') loop_control = NonInheritableFieldAttribute(isa='class', class_type=LoopControl, default=LoopControl) - notify = FieldAttribute(isa='list') poll = NonInheritableFieldAttribute(isa='int', default=C.DEFAULT_POLL_INTERVAL) register = NonInheritableFieldAttribute(isa='string', static=True) - retries = NonInheritableFieldAttribute(isa='int', default=3) + retries = NonInheritableFieldAttribute(isa='int') # default is set in TaskExecutor until = NonInheritableFieldAttribute(isa='list', default=list) # deprecated, used to be loop and loop_args but loop has been repurposed @@ -138,7 +137,7 @@ class Task(Base, Conditional, Taggable, CollectionSearch): def __repr__(self): ''' returns a human readable representation of the task ''' - if self.get_name() in C._ACTION_META: + if self.action in C._ACTION_META: return "TASK: meta (%s)" % self.args['_raw_params'] else: return "TASK: %s" % self.get_name() @@ -533,3 +532,9 @@ class Task(Base, Conditional, Taggable, CollectionSearch): return self._parent return self._parent.get_first_parent_include() return None + + def get_play(self): + parent = self._parent + while not isinstance(parent, Block): + parent = parent._parent + return parent._play |