From 28cf4bc00b263163cc1ed7844f9aef63c9e1893f Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Mon, 1 Feb 2016 18:54:09 -0500 Subject: [PATCH] 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. --- lib/ansible/playbook/task.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/ansible/playbook/task.py b/lib/ansible/playbook/task.py index 6bd3caaca5b..4328602f593 100644 --- a/lib/ansible/playbook/task.py +++ b/lib/ansible/playbook/task.py @@ -244,11 +244,21 @@ class Task(Base, Conditional, Taggable, Become): if value is None: return dict() - for env_item in value: - if isinstance(env_item, (string_types, AnsibleUnicode)) and env_item in templar._available_variables.keys(): - display.deprecated("Using bare variables for environment is deprecated." - " Update your playbooks so that the environment value uses the full variable syntax ('{{foo}}')") - break + elif isinstance(value, list): + if len(value) == 1: + return templar.template(value[0], convert_bare=True) + else: + 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) def _post_validate_changed_when(self, attr, value, templar):