mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #1385 from dhozac/raise-error-for-scripts-too
Raise error for missing hosts in inventory scripts as well
This commit is contained in:
commit
cde377bddb
1 changed files with 6 additions and 6 deletions
|
@ -266,8 +266,11 @@ class Inventory(object):
|
|||
|
||||
def _get_variables(self, hostname):
|
||||
|
||||
if self._is_script:
|
||||
host = self.get_host(hostname)
|
||||
if host is None:
|
||||
raise errors.AnsibleError("host not found: %s" % hostname)
|
||||
|
||||
if self._is_script:
|
||||
cmd = subprocess.Popen(
|
||||
[self.host_list,"--host",hostname],
|
||||
stdout=subprocess.PIPE,
|
||||
|
@ -283,10 +286,7 @@ 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)
|
||||
else:
|
||||
return host.get_variables()
|
||||
|
||||
def add_group(self, group):
|
||||
|
|
Loading…
Reference in a new issue