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

inventory and indentation #329

Merged
merged 2 commits into from
May 8, 2012
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
20 changes: 10 additions & 10 deletions lib/ansible/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,23 @@ def get_hosts(self, pattern="all"):
hosts = {}
patterns = pattern.replace(";",":").split(":")

for group in self.get_groups():
for host in group.get_hosts():
for pat in patterns:
if group.name == pat or pat == 'all' or self._match(host.name, pat):
if not self._restriction:
hosts[host.name] = host
if self._restriction and host.name in self._restriction:
hosts[host.name] = host
for (groupname, group) in self.get_groups().items():
for host in group.get_hosts():
for pat in patterns:
if group.name == pat or pat == 'all' or self._match(host.name, pat):
if not self._restriction:
hosts[host.name] = host
if self._restriction and host.name in self._restriction:
hosts[host.name] = host
return sorted(hosts.values(), key=lambda x: x.name)

def get_groups(self):
return self.groups

def get_host(self, hostname):
for group in self.groups:
for host in group.get_hosts():
if hostname == host.name:
for host in group.get_hosts():
if hostname == host.name:
return host
return None

Expand Down