From 20bf5f130d67b5f75f925d9084c39d7f4882de28 Mon Sep 17 00:00:00 2001 From: Timothy Appnel Date: Wed, 8 May 2013 14:11:40 -0400 Subject: [PATCH] Adds fuzzy matching of localhost to 127.0.0.1 host entries and vice versa. --- lib/ansible/inventory/__init__.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/ansible/inventory/__init__.py b/lib/ansible/inventory/__init__.py index d5dd3527b9..2cdf6b974a 100644 --- a/lib/ansible/inventory/__init__.py +++ b/lib/ansible/inventory/__init__.py @@ -246,10 +246,15 @@ class Inventory(object): return self._hosts_cache[hostname] def _get_host(self, hostname): - for group in self.groups: - for host in group.get_hosts(): - if hostname == host.name: + if hostname in ['localhost','127.0.0.1']: + for host in self.get_group('all').get_hosts(): + if host.name in ['localhost', '127.0.0.1']: return host + else: + for group in self.groups: + for host in group.get_hosts(): + if hostname == host.name: + return host return None def get_group(self, groupname):