Override post validation of environment to allow bare variables
Also prints a deprecated warning if a bare variable is detected, so that we can remove this in a future version. Fixes #11912
This commit is contained in:
parent
4dba30ccd0
commit
4714cbeec8
1 changed files with 14 additions and 1 deletions
|
@ -19,11 +19,13 @@
|
|||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from six import string_types
|
||||
|
||||
from ansible.errors import AnsibleError
|
||||
|
||||
from ansible.parsing.mod_args import ModuleArgsParser
|
||||
from ansible.parsing.splitter import parse_kv
|
||||
from ansible.parsing.yaml.objects import AnsibleBaseYAMLObject, AnsibleMapping
|
||||
from ansible.parsing.yaml.objects import AnsibleBaseYAMLObject, AnsibleMapping, AnsibleUnicode
|
||||
|
||||
from ansible.plugins import module_loader, lookup_loader
|
||||
|
||||
|
@ -211,6 +213,17 @@ class Task(Base, Conditional, Taggable, Become):
|
|||
'''
|
||||
return value
|
||||
|
||||
def _post_validate_environment(self, attr, value, templar):
|
||||
'''
|
||||
Override post validation of vars on the play, as we don't want to
|
||||
template these too early.
|
||||
'''
|
||||
for env_item in value:
|
||||
if isinstance(env_item, (string_types, AnsibleUnicode)) and env_item in templar._available_variables.keys():
|
||||
self._display.deprecated("Using bare variables for environment is deprecated. Update your playbooks so that the environment value uses the full variable syntax ('{{foo}}')")
|
||||
break
|
||||
return templar.template(value, convert_bare=True)
|
||||
|
||||
def get_vars(self):
|
||||
all_vars = dict()
|
||||
if self._block:
|
||||
|
|
Loading…
Reference in a new issue