Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds fuzzy matching of localhost to 127.0.0.1 host entries and vice versa #2872

Merged
merged 1 commit into from
May 11, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 8 additions & 3 deletions lib/ansible/inventory/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,15 @@ def get_host(self, hostname):
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):
Expand Down