add more consistent extension matching for inventory plugins (#46786)

* Add consistent extension matching for inventory plugins that support YAML configuration files

* Document extension matching expectations
This commit is contained in:
Sloane Hertel
2018-10-11 12:06:52 -04:00
committed by AlanCoding
parent 79166209ee
commit 5dc9ca222f

View File

@@ -16,7 +16,7 @@ DOCUMENTATION = '''
description: description:
- Reads inventories from Ansible Tower. - Reads inventories from Ansible Tower.
- Supports reading configuration from both YAML config file and environment variables. - Supports reading configuration from both YAML config file and environment variables.
- If reading from the YAML file, the file name must end with tower_inventory.(yml|yaml), - If reading from the YAML file, the file name must end with tower.(yml|yaml) or tower_inventory.(yml|yaml),
the path in the command would be /path/to/tower_inventory.(yml|yaml). If some arguments in the config file the path in the command would be /path/to/tower_inventory.(yml|yaml). If some arguments in the config file
are missing, this plugin will try to fill in missing arguments by reading from environment variables. are missing, this plugin will try to fill in missing arguments by reading from environment variables.
- If reading configurations from environment variables, the path in the command must be @tower_inventory. - If reading configurations from environment variables, the path in the command must be @tower_inventory.
@@ -143,7 +143,7 @@ class InventoryModule(BaseInventoryPlugin):
self.no_config_file_supplied = True self.no_config_file_supplied = True
return True return True
elif super(InventoryModule, self).verify_file(path): elif super(InventoryModule, self).verify_file(path):
return path.endswith('tower_inventory.yml') or path.endswith('tower_inventory.yaml') return path.endswith(('tower_inventory.yml', 'tower_inventory.yaml', 'tower.yml', 'tower.yaml'))
else: else:
return False return False