|
|
|
|
@ -32,6 +32,12 @@ from ansible.template import Templar
|
|
|
|
|
from ansible.template.safe_eval import safe_eval
|
|
|
|
|
from ansible.module_utils._text import to_native
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
from __main__ import display
|
|
|
|
|
except ImportError:
|
|
|
|
|
from ansible.utils.display import Display
|
|
|
|
|
display = Display()
|
|
|
|
|
|
|
|
|
|
DEFINED_REGEX = re.compile(r'(hostvars\[.+\]|[\w_]+)\s+(not\s+is|is|is\s+not)\s+(defined|undefined)')
|
|
|
|
|
LOOKUP_REGEX = re.compile(r'lookup\s*\(')
|
|
|
|
|
VALID_VAR_REGEX = re.compile("^[_A-Za-z][_a-zA-Z0-9]*$")
|
|
|
|
|
@ -132,6 +138,11 @@ class Conditional:
|
|
|
|
|
if conditional in all_vars and VALID_VAR_REGEX.match(conditional):
|
|
|
|
|
conditional = all_vars[conditional]
|
|
|
|
|
|
|
|
|
|
if templar._clean_data(conditional) != conditional:
|
|
|
|
|
display.warning('when statements should not include jinja2 '
|
|
|
|
|
'templating delimiters such as {{ }} or {%% %%}. '
|
|
|
|
|
'Found: %s' % conditional)
|
|
|
|
|
|
|
|
|
|
# make sure the templar is using the variables specified with this method
|
|
|
|
|
templar.set_available_variables(variables=all_vars)
|
|
|
|
|
|
|
|
|
|
|