Raise error for missing hosts in inventory scripts as well
parent
5a08da98a3
commit
b8021f12e0
|
@ -266,8 +266,11 @@ class Inventory(object):
|
||||||
|
|
||||||
def _get_variables(self, hostname):
|
def _get_variables(self, hostname):
|
||||||
|
|
||||||
if self._is_script:
|
|
||||||
host = self.get_host(hostname)
|
host = self.get_host(hostname)
|
||||||
|
if host is None:
|
||||||
|
raise errors.AnsibleError("host not found: %s" % hostname)
|
||||||
|
|
||||||
|
if self._is_script:
|
||||||
cmd = subprocess.Popen(
|
cmd = subprocess.Popen(
|
||||||
[self.host_list,"--host",hostname],
|
[self.host_list,"--host",hostname],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
|
@ -283,10 +286,7 @@ class Inventory(object):
|
||||||
results['group_names'] = sorted(groups)
|
results['group_names'] = sorted(groups)
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
else:
|
||||||
host = self.get_host(hostname)
|
|
||||||
if host is None:
|
|
||||||
raise errors.AnsibleError("host not found: %s" % hostname)
|
|
||||||
return host.get_variables()
|
return host.get_variables()
|
||||||
|
|
||||||
def add_group(self, group):
|
def add_group(self, group):
|
||||||
|
|
Loading…
Reference in New Issue