mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-18 22:31:06 -07:00
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:
parent
e3882ad6f6
commit
f3d5ebb355
9 changed files with 21 additions and 22 deletions
|
@ -102,11 +102,11 @@ This method is used by Ansible to make a quick determination if the inventory so
|
|||
valid = False
|
||||
if super(InventoryModule, self).verify_file(path):
|
||||
# base class verifies that file exists and is readable by current user
|
||||
if path.endswith(('.vbox.yaml', '.vbox.yml')):
|
||||
if path.endswith(('virtualbox.yaml', 'virtualbox.yml', 'vbox.yaml', 'vbox.yml')):
|
||||
valid = True
|
||||
return valid
|
||||
|
||||
In this case, from the :ref:`virtualbox inventory plugin <virtualbox_inventory>`, we screen for specific file name patterns to avoid attempting to consume any valid yaml file. You can add any type of condition here, but the most common one is 'extension matching'
|
||||
In this case, from the :ref:`virtualbox inventory plugin <virtualbox_inventory>`, we screen for specific file name patterns to avoid attempting to consume any valid yaml file. You can add any type of condition here, but the most common one is 'extension matching'. If you implement extension matching for YAML configuration files the path suffix <plugin_name>.<yml|yaml> should be accepted. All valid extensions should be documented in the plugin description.
|
||||
|
||||
Another example that actually does not use a 'file' but the inventory source string itself,
|
||||
from the :ref:`host list <host_list_inventory>` plugin:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue