Skip to content

Instantly share code, notes, and snippets.

@sivel
Created February 4, 2016 21:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sivel/3bea3e5c76321d903483 to your computer and use it in GitHub Desktop.
Save sivel/3bea3e5c76321d903483 to your computer and use it in GitHub Desktop.
diff --git a/lib/ansible/playbook/play_context.py b/lib/ansible/playbook/play_context.py
index 1804a03..3703062 100644
--- a/lib/ansible/playbook/play_context.py
+++ b/lib/ansible/playbook/play_context.py
@@ -80,6 +80,13 @@ MAGIC_VARIABLE_MAPPING = dict(
su_flags = ('ansible_su_flags',),
)
+MAGIC_VARIABLE_UNDEFINED = [
+ 'remote_addr',
+ 'remote_user',
+ 'port',
+ 'password'
+]
+
SU_PROMPT_LOCALIZATIONS = [
'Password',
'암호',
@@ -531,4 +538,6 @@ class PlayContext(Base):
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)
+ value = getattr(self, prop)
+ if prop in MAGIC_VARIABLE_UNDEFINED and value is not None:
+ variables[special_var] = getattr(self, prop)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment