summaryrefslogtreecommitdiff
path: root/lib/ansible/plugins/test
diff options
context:
space:
mode:
authorBrian Coca <brian.coca+git@gmail.com>2017-07-05 13:50:32 -0400
committerBrian Coca <bcoca@users.noreply.github.com>2017-07-05 21:44:00 -0400
commit2a041d10d26d5746132061da4b874f33cb73ffb0 (patch)
treebc14f44e037fc57af979327ec9869de768bc270d /lib/ansible/plugins/test
parentfba76444e0d8fa596f3a1fea049f892b252d271e (diff)
downloadansible-2a041d10d26d5746132061da4b874f33cb73ffb0.tar.gz
better backwards compat handling of status
restored 'rc' inspection but only when failed is not specified removed redundant changed from basic.py as task_executor already adds removed redundant filters, they are tests added aliases to tests removed from filters fixed test to new rc handling
Diffstat (limited to 'lib/ansible/plugins/test')
-rw-r--r--lib/ansible/plugins/test/core.py49
1 files changed, 23 insertions, 26 deletions
diff --git a/lib/ansible/plugins/test/core.py b/lib/ansible/plugins/test/core.py
index 7440b2197f..6d869c35d0 100644
--- a/lib/ansible/plugins/test/core.py
+++ b/lib/ansible/plugins/test/core.py
@@ -27,50 +27,43 @@ from distutils.version import LooseVersion, StrictVersion
from ansible import errors
-def failed(*a, **kw):
+def failed(result):
''' Test if task result yields failed '''
- item = a[0]
- if not isinstance(item, MutableMapping):
+ if not isinstance(result, MutableMapping):
raise errors.AnsibleFilterError("|failed expects a dictionary")
- rc = item.get('rc', 0)
- failed = item.get('failed', False)
- if rc != 0 or failed:
- return True
- else:
- return False
+ return result.get('failed', False)
-def success(*a, **kw):
+def success(result):
''' Test if task result yields success '''
- return not failed(*a, **kw)
+ return not failed(result)
-def changed(*a, **kw):
+def changed(result):
''' Test if task result yields changed '''
- item = a[0]
- if not isinstance(item, MutableMapping):
+ if not isinstance(result, MutableMapping):
raise errors.AnsibleFilterError("|changed expects a dictionary")
- if 'changed' not in item:
+ if 'changed' not in result:
changed = False
if (
- 'results' in item and # some modules return a 'results' key
- isinstance(item['results'], MutableSequence) and
- isinstance(item['results'][0], MutableMapping)
+ 'results' in result and # some modules return a 'results' key
+ isinstance(result['results'], MutableSequence) and
+ isinstance(result['results'][0], MutableMapping)
):
- for result in item['results']:
- changed = changed or result.get('changed', False)
+ for res in result['results']:
+ if res.get('changed', False):
+ changed = True
+ break
else:
- changed = item.get('changed', False)
+ changed = result.get('changed', False)
return changed
-def skipped(*a, **kw):
+def skipped(result):
''' Test if task result yields skipped '''
- item = a[0]
- if not isinstance(item, MutableMapping):
+ if not isinstance(result, MutableMapping):
raise errors.AnsibleFilterError("|skipped expects a dictionary")
- skipped = item.get('skipped', False)
- return skipped
+ return result.get('skipped', False)
def regex(value='', pattern='', ignorecase=False, multiline=False, match_type='search'):
@@ -133,13 +126,17 @@ class TestModule(object):
return {
# failure testing
'failed': failed,
+ 'failure': failed,
'succeeded': success,
+ 'success': success,
# changed testing
'changed': changed,
+ 'change': changed,
# skip testing
'skipped': skipped,
+ 'skip': skipped,
# regex
'match': match,