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

fix incorrect environment processing

it was assumed it could only be a dict or string (it starts out as a list)
also a 2nd assumption that bare vars only would appear in one of the dict keys.

removed deprecation warnings from here as they should be signaled in the bare conversion itself.
This commit is contained in:
Brian Coca 2016-02-01 18:54:09 -05:00
parent 6a62ad6c4b
commit 28cf4bc00b

View file

@ -244,11 +244,21 @@ class Task(Base, Conditional, Taggable, Become):
if value is None: if value is None:
return dict() return dict()
for env_item in value: elif isinstance(value, list):
if isinstance(env_item, (string_types, AnsibleUnicode)) and env_item in templar._available_variables.keys(): if len(value) == 1:
display.deprecated("Using bare variables for environment is deprecated." return templar.template(value[0], convert_bare=True)
" Update your playbooks so that the environment value uses the full variable syntax ('{{foo}}')") else:
break env = []
for env_item in value:
if isinstance(env_item, (string_types, AnsibleUnicode)) and env_item in templar._available_variables.keys():
env[env_item] = templar.template(env_item, convert_bare=True)
elif isinstance(value, dict):
env = dict()
for env_item in value:
if isinstance(env_item, (string_types, AnsibleUnicode)) and env_item in templar._available_variables.keys():
env[env_item] = templar.template(value[env_item], convert_bare=True)
# at this point it should be a simple string
return templar.template(value, convert_bare=True) return templar.template(value, convert_bare=True)
def _post_validate_changed_when(self, attr, value, templar): def _post_validate_changed_when(self, attr, value, templar):