mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #7412 from bellkev/fix_skip_dir_inventory_extensions
Fix skip dir inventory extensions
This commit is contained in:
commit
1f0be3753d
3 changed files with 9 additions and 4 deletions
|
@ -40,8 +40,7 @@ class InventoryDirectory(object):
|
|||
for i in self.names:
|
||||
|
||||
# Skip files that end with certain extensions or characters
|
||||
for ext in ("~", ".orig", ".bak", ".ini", ".retry", ".pyc", ".pyo"):
|
||||
if i.endswith(ext):
|
||||
if any(i.endswith(ext) for ext in ("~", ".orig", ".bak", ".ini", ".retry", ".pyc", ".pyo")):
|
||||
continue
|
||||
# Skip hidden files
|
||||
if i.startswith('.') and not i.startswith('./'):
|
||||
|
|
|
@ -439,3 +439,7 @@ class TestInventory(unittest.TestCase):
|
|||
actual_host_names = [host.name for host in group_greek]
|
||||
print "greek : %s " % actual_host_names
|
||||
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()]
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
[skip]
|
||||
skipme
|
Loading…
Reference in a new issue