Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
611e5b0c
Commit
611e5b0c
authored
Jul 12, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make adding tags to a playbook work as shorthand to tagging all tasks in the play.
parent
cf313cde
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
4 deletions
+32
-4
examples/playbooks/tags.yml
+18
-3
lib/ansible/playbook/play.py
+14
-1
No files found.
examples/playbooks/tags.yml
View file @
611e5b0c
...
@@ -6,14 +6,27 @@
...
@@ -6,14 +6,27 @@
# try this with:
# try this with:
# --tags foo
# --tags foo
# --tags bar
# --tags bar
# --tags extra
#
#
#
note the include syntax to tag all tasks included below
#
the value of a 'tags:' element can be a string or list
#
it is a short hand over adding "tag:" to each task entry
#
of tag names. Variables are not usable in tag names.
-
name
:
example play one
-
name
:
example play one
hosts
:
all
hosts
:
all
user
:
root
user
:
root
# any tags applied to the play are shorthand to applying
# the tag to all tasks in it. Here, each task is given
# the tag extra
tags
:
-
extra
tasks
:
tasks
:
# this task will run if you don't specify any tags,
# if you specify 'foo' or if you specify 'extra'
-
name
:
hi
-
name
:
hi
tags
:
foo
tags
:
foo
action
:
shell echo "first task ran"
action
:
shell echo "first task ran"
...
@@ -23,7 +36,9 @@
...
@@ -23,7 +36,9 @@
user
:
root
user
:
root
tasks
:
tasks
:
-
name
:
hi
-
name
:
hi
tags
:
bar
tags
:
-
bar
action
:
shell echo "second task ran"
action
:
shell echo "second task ran"
-
include
:
tasks/base.yml tags=base
-
include
:
tasks/base.yml tags=base
lib/ansible/playbook/play.py
View file @
611e5b0c
...
@@ -29,7 +29,7 @@ class Play(object):
...
@@ -29,7 +29,7 @@ class Play(object):
'hosts'
,
'name'
,
'vars'
,
'vars_prompt'
,
'vars_files'
,
'hosts'
,
'name'
,
'vars'
,
'vars_prompt'
,
'vars_files'
,
'handlers'
,
'remote_user'
,
'remote_port'
,
'handlers'
,
'remote_user'
,
'remote_port'
,
'sudo'
,
'sudo_user'
,
'transport'
,
'playbook'
,
'sudo'
,
'sudo_user'
,
'transport'
,
'playbook'
,
'_ds'
,
'_handlers'
,
'_tasks'
'
tags'
,
'
_ds'
,
'_handlers'
,
'_tasks'
]
]
# *************************************************
# *************************************************
...
@@ -62,9 +62,17 @@ class Play(object):
...
@@ -62,9 +62,17 @@ class Play(object):
self
.
sudo
=
ds
.
get
(
'sudo'
,
self
.
playbook
.
sudo
)
self
.
sudo
=
ds
.
get
(
'sudo'
,
self
.
playbook
.
sudo
)
self
.
sudo_user
=
ds
.
get
(
'sudo_user'
,
self
.
playbook
.
sudo_user
)
self
.
sudo_user
=
ds
.
get
(
'sudo_user'
,
self
.
playbook
.
sudo_user
)
self
.
transport
=
ds
.
get
(
'connection'
,
self
.
playbook
.
transport
)
self
.
transport
=
ds
.
get
(
'connection'
,
self
.
playbook
.
transport
)
self
.
tags
=
ds
.
get
(
'tags'
,
None
)
self
.
_tasks
=
self
.
_load_tasks
(
self
.
_ds
,
'tasks'
)
self
.
_tasks
=
self
.
_load_tasks
(
self
.
_ds
,
'tasks'
)
self
.
_handlers
=
self
.
_load_tasks
(
self
.
_ds
,
'handlers'
)
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'
:
if
self
.
sudo_user
!=
'root'
:
self
.
sudo
=
True
self
.
sudo
=
True
...
@@ -99,6 +107,11 @@ class Play(object):
...
@@ -99,6 +107,11 @@ class Play(object):
mv
=
task_vars
.
copy
()
mv
=
task_vars
.
copy
()
mv
[
'item'
]
=
item
mv
[
'item'
]
=
item
results
.
append
(
Task
(
self
,
y
,
module_vars
=
mv
))
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
return
results
# *************************************************
# *************************************************
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment