summaryrefslogtreecommitdiff
path: root/lib/ansible/playbook/task.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ansible/playbook/task.py')
-rw-r--r--lib/ansible/playbook/task.py23
1 files changed, 9 insertions, 14 deletions
diff --git a/lib/ansible/playbook/task.py b/lib/ansible/playbook/task.py
index fa1114ad..a1a1162b 100644
--- a/lib/ansible/playbook/task.py
+++ b/lib/ansible/playbook/task.py
@@ -21,19 +21,17 @@ __metaclass__ = type
from ansible import constants as C
from ansible.errors import AnsibleError, AnsibleParserError, AnsibleUndefinedVariable, AnsibleAssertionError
-from ansible.module_utils.common.text.converters import to_native
+from ansible.module_utils._text 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 NonInheritableFieldAttribute
+from ansible.playbook.attribute import FieldAttribute, 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
@@ -45,7 +43,7 @@ __all__ = ['Task']
display = Display()
-class Task(Base, Conditional, Taggable, CollectionSearch, Notifiable, Delegatable):
+class Task(Base, Conditional, Taggable, CollectionSearch):
"""
A task is a language feature that represents a call to a module, with given arguments and other parameters.
@@ -74,12 +72,15 @@ class Task(Base, Conditional, Taggable, CollectionSearch, Notifiable, Delegatabl
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(isa='list')
+ loop = NonInheritableFieldAttribute()
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 is set in TaskExecutor
+ retries = NonInheritableFieldAttribute(isa='int', default=3)
until = NonInheritableFieldAttribute(isa='list', default=list)
# deprecated, used to be loop and loop_args but loop has been repurposed
@@ -137,7 +138,7 @@ class Task(Base, Conditional, Taggable, CollectionSearch, Notifiable, Delegatabl
def __repr__(self):
''' returns a human readable representation of the task '''
- if self.action in C._ACTION_META:
+ if self.get_name() in C._ACTION_META:
return "TASK: meta (%s)" % self.args['_raw_params']
else:
return "TASK: %s" % self.get_name()
@@ -532,9 +533,3 @@ class Task(Base, Conditional, Taggable, CollectionSearch, Notifiable, Delegatabl
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