community.general.incus imposes a constraint on the inventory file name:
its filename must end in
incus.ymlorincus.yaml.
Why?
community.general.incus imposes a constraint on the inventory file name:
its filename must end in
incus.ymlorincus.yaml.
Why?
The incus inventory plugin’s verify_file only accepts paths ending in incus.yml or incus.yaml, so that plugin skips inventory.development.yml. The Ansible developer guide describes verify_file as a quick check of whether an inventory source is usable by the plugin. It adds that plugins screen for specific file name patterns to avoid attempting to consume any valid YAML file. For YAML configuration files, the guide says a suffix of the plugin name plus yml or yaml should be accepted.
Assisted-by: AI.
While this AI generated answer answers the obvious “why” part, the more interesting “why” part isn’t answered: where does this condition come from, which appears in most inventory plugins? It has been there since I got interested in inventory plugins (first when reviewing them, later when maintaining/creating them). Maybe it’s just cargo cult, though I guess the reason is more likely that originally this was the only way for Ansible to figure out which inventory plugin can handle which files. (Now there’s the plugin key, which all inventory plugins I’m aware of require to be present and set to a plugin-specific value, which usually is its FQCN.)
Maybe someone who has been around for longer knows where the conditions on the filenames come from?
Until the addition of the auto inventory plugin, there was no plugin key to link an inventory file directly to an inventory plugin.
As such, the verify_file method of an inventory plugin was the only mechanism that could allow a plugin to reject or utilize an inventory file based on a configuration that included multiple inventories, usually in a directory like -i inventory/, such as:
INVENTORY_ENABLED: ['host_list', 'script', 'openstack', 'yaml', 'ini']
That would result in:
host_list plugin if the provided inventory was not a file, and contained a , in the stringscript plugin if the inventory was executable or contained a shebangopenstack plugin if it ended in openstack.yaml, openstack.yml, clouds.yaml, clouds.ymlyaml if the plugin ended with .yaml/.ymlini as the last caseOnce auto was added, the above example I provided could be:
INVENTORY_ENABLED: ['host_list', 'script', 'auto', 'yaml', 'ini']
And then in the whatever.openstack.yaml you added plugin: openstack it would use that plugin key instead of the file ending in openstack.yaml.
However, the ability to use the plugin key requires the use of the auto inventory plugin, and as this is configurable, it cannot be expected to always be enabled.
As a result, we’ve fallen into a category where the filename must match in this manner regardless of the auto plugin. Both to support older inventory files, and to support not having auto enabled.
Thanks for tracing this back to the history of the auto plugin. The filename rule makes more sense now as a way to keep older inventory files working even when auto is not enabled.