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
a9225d0c
Commit
a9225d0c
authored
Oct 10, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4437 from sergevanginderachter/changed_filter
Implement a |changed filter plugin
parents
16947041
c4d20094
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
1 deletions
+23
-1
lib/ansible/runner/filter_plugins/core.py
+23
-1
No files found.
lib/ansible/runner/filter_plugins/core.py
View file @
a9225d0c
...
@@ -34,7 +34,8 @@ def to_nice_json(*a, **kw):
...
@@ -34,7 +34,8 @@ def to_nice_json(*a, **kw):
return
json
.
dumps
(
*
a
,
indent
=
4
,
sort_keys
=
True
,
**
kw
)
return
json
.
dumps
(
*
a
,
indent
=
4
,
sort_keys
=
True
,
**
kw
)
def
failed
(
*
a
,
**
kw
):
def
failed
(
*
a
,
**
kw
):
item
=
a
[
0
]
''' Test if task result yields failed '''
item
=
a
[
0
]
if
type
(
item
)
!=
dict
:
if
type
(
item
)
!=
dict
:
raise
errors
.
AnsibleFilterError
(
"|failed expects a dictionary"
)
raise
errors
.
AnsibleFilterError
(
"|failed expects a dictionary"
)
rc
=
item
.
get
(
'rc'
,
0
)
rc
=
item
.
get
(
'rc'
,
0
)
...
@@ -45,9 +46,27 @@ def failed(*a, **kw):
...
@@ -45,9 +46,27 @@ def failed(*a, **kw):
return
False
return
False
def
success
(
*
a
,
**
kw
):
def
success
(
*
a
,
**
kw
):
''' Test if task result yields success '''
return
not
failed
(
*
a
,
**
kw
)
return
not
failed
(
*
a
,
**
kw
)
def
changed
(
*
a
,
**
kw
):
''' Test if task result yields changed '''
item
=
a
[
0
]
if
type
(
item
)
!=
dict
:
raise
errors
.
AnsibleFilterError
(
"|changed expects a dictionary"
)
if
not
'changed'
in
item
:
changed
=
False
if
(
'results'
in
item
# some modules return a 'results' key
and
type
(
item
[
'results'
])
==
list
and
type
(
item
[
'results'
][
0
])
==
dict
):
for
result
in
item
[
'results'
]:
changed
=
changed
or
result
.
get
(
'changed'
,
False
)
else
:
changed
=
item
.
get
(
'changed'
,
False
)
return
changed
def
skipped
(
*
a
,
**
kw
):
def
skipped
(
*
a
,
**
kw
):
''' Test if task result yields skipped '''
item
=
a
[
0
]
item
=
a
[
0
]
if
type
(
item
)
!=
dict
:
if
type
(
item
)
!=
dict
:
raise
errors
.
AnsibleFilterError
(
"|skipped expects a dictionary"
)
raise
errors
.
AnsibleFilterError
(
"|skipped expects a dictionary"
)
...
@@ -106,6 +125,9 @@ class FilterModule(object):
...
@@ -106,6 +125,9 @@ class FilterModule(object):
'failed'
:
failed
,
'failed'
:
failed
,
'success'
:
success
,
'success'
:
success
,
# changed testing
'changed'
:
changed
,
# skip testing
# skip testing
'skipped'
:
skipped
,
'skipped'
:
skipped
,
...
...
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