Implement a |changed filter plugin

pull/4437/head
Serge van Ginderachter 11 years ago
parent 16947041d1
commit e5d45311f9

@ -34,6 +34,7 @@ def to_nice_json(*a, **kw):
return json.dumps(*a, indent=4, sort_keys=True, **kw)
def failed(*a, **kw):
''' Test if task result yields failed '''
item = a[0]
if type(item) != dict:
raise errors.AnsibleFilterError("|failed expects a dictionary")
@ -45,9 +46,18 @@ def failed(*a, **kw):
return False
def success(*a, **kw):
''' Test if task result yields success '''
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")
return item.get('changed', False)
def skipped(*a, **kw):
''' Test if task result yields skipped '''
item = a[0]
if type(item) != dict:
raise errors.AnsibleFilterError("|skipped expects a dictionary")
@ -106,6 +116,9 @@ class FilterModule(object):
'failed' : failed,
'success' : success,
# changed testing
'changed' : changed,
# skip testing
'skipped' : skipped,

Loading…
Cancel
Save