mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00: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:
@@ -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'. "
|
||||
|
||||
Reference in New Issue
Block a user