mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
Check that AnsibleUndefinedVariable doesn't occur when an unused variable references an undefined variable (#35571)
* Check that AnsibleUndefinedVariable doesn't occur * AnsibleUndefinedVariable exc.: don't modify type
This commit is contained in:
parent
c37b997abc
commit
d608eb9530
3 changed files with 15 additions and 1 deletions
|
@ -23,7 +23,7 @@ from collections import Mapping
|
|||
|
||||
from jinja2.utils import missing
|
||||
|
||||
from ansible.errors import AnsibleError
|
||||
from ansible.errors import AnsibleError, AnsibleUndefinedVariable
|
||||
from ansible.module_utils.six import iteritems
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
|
@ -105,6 +105,8 @@ class AnsibleJ2Vars(Mapping):
|
|||
value = None
|
||||
try:
|
||||
value = self._templar.template(variable)
|
||||
except AnsibleUndefinedVariable:
|
||||
raise
|
||||
except Exception as e:
|
||||
msg = getattr(e, 'message') or to_native(e)
|
||||
raise AnsibleError("An unhandled exception occurred while templating '%s'. "
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue