From c9b125d21a7a0e4ca5cb0ec1597504f14ef22198 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Wed, 8 Jun 2016 14:14:02 -0500 Subject: [PATCH] Fix hostvars lookup of locahost based on 5f1bbb4 (cherry picked from commit b51d0dd69be25cec3fa35c736d2f9337377e0103) --- lib/ansible/vars/hostvars.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/ansible/vars/hostvars.py b/lib/ansible/vars/hostvars.py index c4010447b7c..faf471fd783 100644 --- a/lib/ansible/vars/hostvars.py +++ b/lib/ansible/vars/hostvars.py @@ -62,7 +62,11 @@ class HostVars(collections.Mapping): self._inventory = inventory def _find_host(self, host_name): - return self._inventory.get_host(host_name) + if host_name in C.LOCALHOST: + host = self._inventory.localhost + else: + host = self._inventory.get_host(host_name) + return host def __getitem__(self, host_name): host = self._find_host(host_name)