Commit 1f0be375 by James Cammarata

Merge pull request #7412 from bellkev/fix_skip_dir_inventory_extensions

Fix skip dir inventory extensions
parents d44ed533 92bd755b
...@@ -36,13 +36,12 @@ class InventoryDirectory(object): ...@@ -36,13 +36,12 @@ class InventoryDirectory(object):
self.parsers = [] self.parsers = []
self.hosts = {} self.hosts = {}
self.groups = {} self.groups = {}
for i in self.names: for i in self.names:
# Skip files that end with certain extensions or characters # Skip files that end with certain extensions or characters
for ext in ("~", ".orig", ".bak", ".ini", ".retry", ".pyc", ".pyo"): if any(i.endswith(ext) for ext in ("~", ".orig", ".bak", ".ini", ".retry", ".pyc", ".pyo")):
if i.endswith(ext): continue
continue
# Skip hidden files # Skip hidden files
if i.startswith('.') and not i.startswith('./'): if i.startswith('.') and not i.startswith('./'):
continue continue
......
...@@ -439,3 +439,7 @@ class TestInventory(unittest.TestCase): ...@@ -439,3 +439,7 @@ class TestInventory(unittest.TestCase):
actual_host_names = [host.name for host in group_greek] actual_host_names = [host.name for host in group_greek]
print "greek : %s " % actual_host_names print "greek : %s " % actual_host_names
assert actual_host_names == ['zeus', 'morpheus'] assert actual_host_names == ['zeus', 'morpheus']
def test_dir_inventory_skip_extension(self):
inventory = self.dir_inventory()
assert 'skipme' not in [h.name for h in inventory.get_hosts()]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment