mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Add Jinja2 filter 'skipped' to test for a registered variable from a skipped task
This commit is contained in:
@@ -44,6 +44,13 @@ def failed(*a, **kw):
|
||||
def success(*a, **kw):
|
||||
return not failed(*a, **kw)
|
||||
|
||||
def skipped(*a, **kw):
|
||||
item = a[0]
|
||||
if type(item) != dict:
|
||||
raise errors.AnsibleError("|skipped expects a dictionary")
|
||||
skipped = item.get('skipped', False)
|
||||
return skipped
|
||||
|
||||
def mandatory(a):
|
||||
''' Make a variable mandatory '''
|
||||
if not a:
|
||||
@@ -88,6 +95,9 @@ class FilterModule(object):
|
||||
'failed' : failed,
|
||||
'success' : success,
|
||||
|
||||
# skip testing
|
||||
'skipped' : skipped,
|
||||
|
||||
# variable existence
|
||||
'mandatory': mandatory,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user