mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 14:22:46 +00:00
Add a mandatory jinja2 filter for use in templates.
This commit is contained in:
@@ -43,6 +43,12 @@ def failed(*a, **kw):
|
|||||||
def success(*a, **kw):
|
def success(*a, **kw):
|
||||||
return not failed(*a, **kw)
|
return not failed(*a, **kw)
|
||||||
|
|
||||||
|
def mandatory(a):
|
||||||
|
''' Make a variable mandatory '''
|
||||||
|
if not a:
|
||||||
|
raise errors.AnsibleError('Mandatory variable not defined.')
|
||||||
|
return a
|
||||||
|
|
||||||
class FilterModule(object):
|
class FilterModule(object):
|
||||||
''' Ansible core jinja2 filters '''
|
''' Ansible core jinja2 filters '''
|
||||||
|
|
||||||
@@ -70,5 +76,7 @@ class FilterModule(object):
|
|||||||
'failed' : failed,
|
'failed' : failed,
|
||||||
'success' : success,
|
'success' : success,
|
||||||
|
|
||||||
|
# variable existence
|
||||||
|
'mandatory': mandatory,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user