#48 inventory: Use list of ignored inventory extensions from environment if present
Merged 6 years ago by stefw. Opened 6 years ago by merlinm.

@@ -68,8 +68,14 @@

  

      inventory_dir = os.environ.get(

          "TEST_DYNAMIC_INVENTORY_DIRECTORY", "/usr/share/ansible/inventory")

-     inventory_ignore_extensions = (

-         "~", ".orig", ".bak", ".ini", ".cfg", ".retry", ".pyc", ".pyo")

+ 

+     ignore_ext_string = os.environ.get(

+         "ANSIBLE_INVENTORY_IGNORE", "~, .orig, .bak, .ini, .cfg, .retry, .pyc, .pyo")

+     ignore_ext_list = []

+     for s in ignore_ext_string.split(','):

+         if s.strip():

+             ignore_ext_list.append(s.strip())

+     inventory_ignore_extensions = tuple(ignore_ext_list)

  

      merged = Inventory()

  

A small improvement to allow an environment variable override of ignored file extensions conforming with ansible's inventory conventions.

Thanks to @cevich for the idea!

This code is very hard to read. I suggest reformatting it, even if we have to make it less fancy.

I'd also note that the bool() is likely not needed

1 new commit added

  • Rewrite ignored inventory extension code to be less fancy.
6 years ago

I have tested this with the sed tests (which fail in a containter) ... but the merge-inventory-script works for that case.

Pull-Request has been merged by stefw

6 years ago
Metadata