Also displays a warning now, because users should not be using that variable
name as it causes a collision with the internal variable of the same name.
@ -46,6 +46,13 @@ from ansible.utils.vars import combine_vars
fromansible.vars.hostvarsimportHostVars
fromansible.vars.hostvarsimportHostVars
fromansible.vars.unsafe_proxyimportwrap_var
fromansible.vars.unsafe_proxyimportwrap_var
try:
from__main__importdisplay
display=display
exceptImportError:
fromansible.utils.displayimportDisplay
display=Display()
VARIABLE_CACHE=dict()
VARIABLE_CACHE=dict()
HOSTVARS_CACHE=dict()
HOSTVARS_CACHE=dict()
@ -320,6 +327,13 @@ class VariableManager:
all_vars=combine_vars(all_vars,self._extra_vars)
all_vars=combine_vars(all_vars,self._extra_vars)
all_vars=combine_vars(all_vars,magic_variables)
all_vars=combine_vars(all_vars,magic_variables)
# special case for the 'environment' magic variable, as someone
# may have set it as a variable and we don't want to stomp on it
iftaskand'environment'notinall_vars:
all_vars['environment']=task.environment
else:
display.warning("The variable 'environment' appears to be used already, which is also used internally for environment variables set on the task/block/play. You should use a different variable name to avoid conflicts with this internal variable")
# if we have a task and we're delegating to another host, figure out the
# if we have a task and we're delegating to another host, figure out the
# variables for that host now so we don't have to rely on hostvars later
# variables for that host now so we don't have to rely on hostvars later