Add a mandatory jinja2 filter for use in templates.
This commit is contained in:
parent
467f612ef6
commit
a37f55d32e
1 changed files with 8 additions and 0 deletions
|
@ -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,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue