diff options
author | Daniel Hokka Zakrisson <daniel@hozac.com> | 2012-10-19 16:26:12 +0200 |
---|---|---|
committer | Daniel Hokka Zakrisson <daniel@hozac.com> | 2012-10-19 16:26:12 +0200 |
commit | c8245f3440f83a7da511827776be6713682845f1 (patch) | |
tree | 5c42ed80c2d70532b2025a429f547c0e67b9e2c2 | |
parent | 23831668c12df02b8b68fa68501fe98f99ddabda (diff) | |
download | ansible-c8245f3440f83a7da511827776be6713682845f1.tar.gz |
Raise error for missing hosts in inventory scripts as well
-rw-r--r-- | lib/ansible/inventory/__init__.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/ansible/inventory/__init__.py b/lib/ansible/inventory/__init__.py index 104e61bdd0..0b1335b0f2 100644 --- a/lib/ansible/inventory/__init__.py +++ b/lib/ansible/inventory/__init__.py @@ -266,8 +266,11 @@ class Inventory(object): def _get_variables(self, hostname): + host = self.get_host(hostname) + if host is None: + raise errors.AnsibleError("host not found: %s" % hostname) + if self._is_script: - host = self.get_host(hostname) cmd = subprocess.Popen( [self.host_list,"--host",hostname], stdout=subprocess.PIPE, @@ -283,11 +286,8 @@ class Inventory(object): results['group_names'] = sorted(groups) return results - - host = self.get_host(hostname) - if host is None: - raise errors.AnsibleError("host not found: %s" % hostname) - return host.get_variables() + else: + return host.get_variables() def add_group(self, group): self.groups.append(group) |