now missing hosts file gives nice message and no traceback
Signed-off-by: Brian Coca <briancoca+dev@gmail.com>
This commit is contained in:
parent
e564de3983
commit
ca5f52b825
1 changed files with 12 additions and 9 deletions
|
@ -80,17 +80,20 @@ class Inventory(object):
|
||||||
all.add_host(Host(tokens[0], tokens[1]))
|
all.add_host(Host(tokens[0], tokens[1]))
|
||||||
else:
|
else:
|
||||||
all.add_host(Host(x))
|
all.add_host(Host(x))
|
||||||
elif utils.is_executable(host_list):
|
elif os.path.exists(host_list):
|
||||||
self._is_script = True
|
if utils.is_executable(host_list):
|
||||||
self.parser = InventoryScript(filename=host_list)
|
self._is_script = True
|
||||||
self.groups = self.parser.groups.values()
|
self.parser = InventoryScript(filename=host_list)
|
||||||
else:
|
|
||||||
data = file(host_list).read()
|
|
||||||
if not data.startswith("---"):
|
|
||||||
self.parser = InventoryParser(filename=host_list)
|
|
||||||
self.groups = self.parser.groups.values()
|
self.groups = self.parser.groups.values()
|
||||||
else:
|
else:
|
||||||
raise errors.AnsibleError("YAML inventory support is deprecated in 0.6 and removed in 0.7, see the migration script in examples/scripts in the git checkout")
|
data = file(host_list).read()
|
||||||
|
if not data.startswith("---"):
|
||||||
|
self.parser = InventoryParser(filename=host_list)
|
||||||
|
self.groups = self.parser.groups.values()
|
||||||
|
else:
|
||||||
|
raise errors.AnsibleError("YAML inventory support is deprecated in 0.6 and removed in 0.7, see the migration script in examples/scripts in the git checkout")
|
||||||
|
else:
|
||||||
|
raise errors.AnsibleError("No valid hosts inventory file found")
|
||||||
|
|
||||||
def _match(self, str, pattern_str):
|
def _match(self, str, pattern_str):
|
||||||
if pattern_str.startswith('~'):
|
if pattern_str.startswith('~'):
|
||||||
|
|
Loading…
Reference in a new issue