Make mandatory filter error message more verbose (#44139)

...by adding the undefined variable/attribute name, if available.
This commit is contained in:
stoned 2018-08-17 21:11:43 +02:00 committed by Sam Doran
parent 9abe66845f
commit e5f4987a8f

View file

@ -299,7 +299,11 @@ def mandatory(a):
''' Make a variable mandatory '''
if isinstance(a, Undefined):
raise AnsibleFilterError('Mandatory variable not defined.')
if a._undefined_name is not None:
name = "'%s' " % to_text(a._undefined_name)
else:
name = ''
raise AnsibleFilterError("Mandatory variable %snot defined." % name)
return a