1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

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:
James Cammarata 2015-08-14 00:33:36 -04:00
parent 4dba30ccd0
commit 4714cbeec8

View file

@ -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: