1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Merge pull request #3375 from jhoekx/mandatory-filter

Add a mandatory jinja2 filter for use in templates.
This commit is contained in:
Michael DeHaan 2013-06-30 14:16:17 -07:00
commit 146455fd0a

View file

@ -43,6 +43,12 @@ def failed(*a, **kw):
def success(*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):
''' Ansible core jinja2 filters '''
@ -70,5 +76,7 @@ class FilterModule(object):
'failed' : failed,
'success' : success,
# variable existence
'mandatory': mandatory,
}