From 75b6f616190857db6b816096ce39bdaf2c16822a Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Thu, 4 Feb 2016 17:15:54 -0500 Subject: [PATCH] Fix the way we re-add variables from PlayContext to the variable dict * If the internal value is None, do not add the variable * Make sure all aliases for a given variable name are set (if they're not already set in the dictionary) Fixes #14310 --- lib/ansible/playbook/play_context.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/ansible/playbook/play_context.py b/lib/ansible/playbook/play_context.py index 1804a032c62..f7b38e9e79d 100644 --- a/lib/ansible/playbook/play_context.py +++ b/lib/ansible/playbook/play_context.py @@ -524,11 +524,9 @@ class PlayContext(Base): In case users need to access from the play, this is a legacy from runner. ''' - # TODO: should we be setting the more generic values here rather than - # the more specific _ssh_ ones? - for special_var in RESET_VARS: - - if special_var not in variables: - for prop, varnames in MAGIC_VARIABLE_MAPPING.items(): - if special_var in varnames: - variables[special_var] = getattr(self, prop) + for prop, var_list in MAGIC_VARIABLE_MAPPING.items(): + var_val = getattr(self, prop, None) + if var_val is not None: + for var_opt in var_list: + if var_opt not in variables: + variables[var_opt] = var_val