provider-ansible
provider-ansible copied to clipboard
Support custom inventory filename through `AnsibleRun` CRD
What problem are you facing?
I am attempting to use the ansible provider in crossplane as an execution engine for an existing ansible setup. This setup makes use of the gcp_compute ansible plugin https://docs.ansible.com/ansible/latest/collections/google/cloud/gcp_compute_inventory.html
However, no matter what configuration I try (inline, executable, or sourced from secret), I cannot get ansible in the provider to accept the inventory as a gcp plugin and run it correctly. It always gives the error
[WARNING]: * Failed to parse
/ansibleDir/733c9dbc-1b0b-4b44-ae41-e935f962b9a9/hosts with yaml plugin: Plugin
configuration YAML file, not YAML inventory
Turns out this is because ansible inventory plugins enforce a fixed structure on inventory filenames, and each plugin defines what the inventory files must be named (on disk) for the plugin to accept them.
For example the docs in gcp state
Uses a YAML configuration file that ends with gcp_compute.(yml|yaml) or gcp.(yml|yaml).
How could Crossplane help solve your problem?
Expand the AnsibleRun
CRD to support inventoryFilename
either on inlineInventory
or all inventory sources. Instead of hardcoding hosts
at https://github.com/crossplane-contrib/provider-ansible/blob/main/pkg/runnerutil/runnerutil.go#L30
If we can specify the filename the provider loads the inlineInventory
into, we should be able to leverage any and all inventory plugins