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
c5d5ed17
Commit
c5d5ed17
authored
Mar 22, 2015
by
Brian Coca
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added tag resolution mirroring updated v1
parent
49ba9d4b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
17 deletions
+42
-17
v2/ansible/playbook/taggable.py
+42
-17
No files found.
v2/ansible/playbook/taggable.py
View file @
c5d5ed17
...
...
@@ -24,6 +24,8 @@ from ansible.playbook.attribute import FieldAttribute
from
ansible.template
import
Templar
class
Taggable
:
untagged
=
set
([
'untagged'
])
_tags
=
FieldAttribute
(
isa
=
'list'
,
default
=
[])
def
__init__
(
self
):
...
...
@@ -38,22 +40,45 @@ class Taggable:
raise
AnsibleError
(
'tags must be specified as a list'
,
obj
=
ds
)
def
evaluate_tags
(
self
,
only_tags
,
skip_tags
,
all_vars
):
templar
=
Templar
(
loader
=
self
.
_loader
,
variables
=
all_vars
)
tags
=
templar
.
template
(
self
.
tags
)
if
not
isinstance
(
tags
,
list
):
tags
=
set
([
tags
])
else
:
tags
=
set
(
tags
)
#print("%s tags are: %s, only_tags=%s, skip_tags=%s" % (self, my_tags, only_tags, skip_tags))
if
skip_tags
:
skipped_tags
=
tags
.
intersection
(
skip_tags
)
if
len
(
skipped_tags
)
>
0
:
return
False
matched_tags
=
tags
.
intersection
(
only_tags
)
#print("matched tags are: %s" % matched_tags)
if
len
(
matched_tags
)
>
0
or
'all'
in
only_tags
:
return
True
''' this checks if the current item should be executed depending on tag options '''
should_run
=
True
if
self
.
tags
:
templar
=
Templar
(
loader
=
self
.
_loader
,
variables
=
all_vars
)
tags
=
templar
.
template
(
self
.
tags
)
if
not
isinstance
(
tags
,
list
):
if
tags
.
find
(
','
)
!=
-
1
:
tags
=
set
(
tags
.
split
(
','
))
else
:
tags
=
set
([
tags
])
else
:
tags
=
set
(
tags
)
else
:
return
False
# this makes intersection work for untagged
tags
=
self
.
__class__
.
untagged
if
only_tags
:
should_run
=
False
if
'always'
in
tags
or
'all'
in
only_tags
:
should_run
=
True
elif
tags
.
intersection
(
only_tags
):
should_run
=
True
elif
'tagged'
in
only_tags
and
tags
!=
self
.
__class__
.
untagged
:
should_run
=
True
if
should_run
and
skip_tags
:
# Check for tags that we need to skip
if
'all'
in
skip_tags
:
if
'always'
not
in
tags
or
'always'
in
skip_tags
:
should_run
=
False
elif
tags
.
intersection
(
skip_tags
):
should_run
=
False
elif
'tagged'
in
skip_tags
and
tags
!=
self
.
__class__
.
untagged
:
should_run
=
False
return
should_run
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