mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 21:30:22 -07:00
Basic support for tagging tasks and selecting a subset of tasks to run with --tags.
This commit is contained in:
parent
fd7e96d33e
commit
83f23ef861
5 changed files with 71 additions and 8 deletions
|
@ -24,7 +24,8 @@ class Task(object):
|
|||
|
||||
__slots__ = [
|
||||
'name', 'action', 'only_if', 'async_seconds', 'async_poll_interval',
|
||||
'notify', 'module_name', 'module_args', 'module_vars', 'play', 'notified_by',
|
||||
'notify', 'module_name', 'module_args', 'module_vars',
|
||||
'play', 'notified_by', 'tags'
|
||||
]
|
||||
|
||||
def __init__(self, play, ds, module_vars=None):
|
||||
|
@ -38,6 +39,8 @@ class Task(object):
|
|||
self.play = play
|
||||
self.name = ds.get('name', None)
|
||||
self.action = ds.get('action', '')
|
||||
self.tags = [ 'all' ]
|
||||
|
||||
self.notified_by = []
|
||||
|
||||
if self.name is None:
|
||||
|
@ -67,4 +70,15 @@ class Task(object):
|
|||
if 'first_available_file' in ds:
|
||||
self.module_vars['first_available_file'] = ds.get('first_available_file')
|
||||
|
||||
# tags allow certain parts of a playbook to be run without
|
||||
# running the whole playbook
|
||||
apply_tags = ds.get('tags', None)
|
||||
if apply_tags is not None:
|
||||
if type(apply_tags) in [ str, unicode ]:
|
||||
self.tags.append(apply_tags)
|
||||
elif type(apply_tags) == list:
|
||||
self.tags.extend(apply_tags)
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue