mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
Make adding tags to a playbook work as shorthand to tagging all tasks in the play.
This commit is contained in:
parent
cf313cde96
commit
611e5b0c90
2 changed files with 32 additions and 4 deletions
|
@ -29,7 +29,7 @@ class Play(object):
|
|||
'hosts', 'name', 'vars', 'vars_prompt', 'vars_files',
|
||||
'handlers', 'remote_user', 'remote_port',
|
||||
'sudo', 'sudo_user', 'transport', 'playbook',
|
||||
'_ds', '_handlers', '_tasks'
|
||||
'tags', '_ds', '_handlers', '_tasks'
|
||||
]
|
||||
|
||||
# *************************************************
|
||||
|
@ -62,9 +62,17 @@ class Play(object):
|
|||
self.sudo = ds.get('sudo', self.playbook.sudo)
|
||||
self.sudo_user = ds.get('sudo_user', self.playbook.sudo_user)
|
||||
self.transport = ds.get('connection', self.playbook.transport)
|
||||
self.tags = ds.get('tags', None)
|
||||
self._tasks = self._load_tasks(self._ds, 'tasks')
|
||||
self._handlers = self._load_tasks(self._ds, 'handlers')
|
||||
|
||||
if self.tags is None:
|
||||
self.tags = []
|
||||
elif type(self.tags) in [ str, unicode ]:
|
||||
self.tags = [ self.tags ]
|
||||
elif type(self.tags) != list:
|
||||
self.tags = []
|
||||
|
||||
if self.sudo_user != 'root':
|
||||
self.sudo = True
|
||||
|
||||
|
@ -99,6 +107,11 @@ class Play(object):
|
|||
mv = task_vars.copy()
|
||||
mv['item'] = item
|
||||
results.append(Task(self,y,module_vars=mv))
|
||||
|
||||
for x in results:
|
||||
if self.tags is not None:
|
||||
x.tags.extend(self.tags)
|
||||
|
||||
return results
|
||||
|
||||
# *************************************************
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue