From 5a0f5f1254f8a94194d389d1993f5a0e41a44255 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Thu, 8 Oct 2015 09:26:20 -0400 Subject: [PATCH] Load vars for localhost when created implicitly Fixes #12666 --- lib/ansible/inventory/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/ansible/inventory/__init__.py b/lib/ansible/inventory/__init__.py index 438ab798e7f..a91d71c2ce4 100644 --- a/lib/ansible/inventory/__init__.py +++ b/lib/ansible/inventory/__init__.py @@ -421,9 +421,11 @@ class Inventory(object): def _create_implicit_localhost(self, pattern): new_host = Host(pattern) - new_host.set_variable("ansible_python_interpreter", sys.executable) + new_host.address = "127.0.0.1" + new_host.vars = self.get_host_vars(new_host) new_host.set_variable("ansible_connection", "local") - new_host.address = '127.0.0.1' + if "ansible_python_interpreter" not in new_host.vars: + new_host.set_variable("ansible_python_interpreter", sys.executable) self.get_group("ungrouped").add_host(new_host) return new_host