Merge pull request #3169 from Debilski/fix-duplicate-host-reads
Allow inventory to be read from a pipepull/4420/head
commit
aa340c1508
|
@ -90,12 +90,8 @@ class Inventory(object):
|
||||||
self.parser = InventoryScript(filename=host_list)
|
self.parser = InventoryScript(filename=host_list)
|
||||||
self.groups = self.parser.groups.values()
|
self.groups = self.parser.groups.values()
|
||||||
else:
|
else:
|
||||||
data = file(host_list).read()
|
|
||||||
if not data.startswith("---"):
|
|
||||||
self.parser = InventoryParser(filename=host_list)
|
self.parser = InventoryParser(filename=host_list)
|
||||||
self.groups = self.parser.groups.values()
|
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")
|
|
||||||
|
|
||||||
utils.plugins.vars_loader.add_directory(self.basedir(), with_subdir=True)
|
utils.plugins.vars_loader.add_directory(self.basedir(), with_subdir=True)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -33,7 +33,7 @@ class InventoryParser(object):
|
||||||
|
|
||||||
def __init__(self, filename=C.DEFAULT_HOST_LIST):
|
def __init__(self, filename=C.DEFAULT_HOST_LIST):
|
||||||
|
|
||||||
fh = open(filename)
|
with open(filename) as fh:
|
||||||
self.lines = fh.readlines()
|
self.lines = fh.readlines()
|
||||||
self.groups = {}
|
self.groups = {}
|
||||||
self.hosts = {}
|
self.hosts = {}
|
||||||
|
|
Loading…
Reference in New Issue