ansible / awx

AWX provides a web-based user interface, REST API, and task engine built on top of Ansible. It is one of the upstream projects for Red Hat Ansible Automation Platform.
Other
14.06k stars 3.42k forks source link

Allow Vault Credentials for Project SCM Type Inventories to process inventory plugin parameters #14966

Open azrdev opened 8 months ago

azrdev commented 8 months ago

Please confirm the following

Feature type

Enhancement to Existing Feature

Feature Summary

"Inventory Source" objects can have a number of Credential types attached, but not "vault" ones. For custom inventory plugins which need secrets one does not want to record as plaintext into the plugin-config.yml (in git), this requires 1. support from the inventory plugin and 2. a Custom Credential Type -- This could be much easier if we could add the secrets to the plugin config as vaulted variables -- and have the "Vault Credential" attached to the inventory source to decode those upon inventory sync.

Select the relevant components

Steps to reproduce

The hoops an inventory currently has to jump through can be seen in this PR: https://github.com/stdevel/ansible-collection-uyuni/pull/41/ (diff and comment https://github.com/stdevel/ansible-collection-uyuni/pull/41/#issuecomment-1983166880 )

Current results

Cannot select vault Credentials on inventory source.

Sugested feature result

Can select vault Credentials on inventory source.

Additional information

gendergap commented 8 months ago

Maybe this is the same as #14680.

PulsatingQuasar commented 4 months ago

Hi, we have run into this issue to.

I see a lot of people asking for this so why is this not implemented yet? Since this works in basic Ansible, why not in AWX? The vault credential should be allowed on an Inventory source.

BartOpitz commented 4 months ago

+1 from me - we need login/password in inventory plugin configuration and encrypt password with ansible vault. Normally, ansible-inventory can prompt for that vault secret, but there is no option in AWX to assign a vault credential with inventory sync job. This is weird, as ansible-inventory seems to use exact same mechanism (and even command line parameters / environment variables) for vault handling as ansible-playbook does. In my opinion enabling the possibility to use vaults with ansible-inventory should not be a big deal.

And to clarify - I do not mean here that ansible-inventory decrypts inventory group_vars or host_vars - it is very OK that they are imported as encrypted and are decrypted when the actual job template runs and uses them. I just need to be able to decrypt inventory plugin configuration.

Currently use a workaround described somewhere that uses environment variables and custom credentials, but this requires me to create 2 secrets for a vault that is used both in inventory and in playbooks... This is a bit cumbersome.

ktoulliou commented 2 months ago

+1 from me too When I use the dynamic inventory microsoft.ad.ldap.yml (see here: https://docs.ansible.com/ansible/latest/collections/microsoft/ad/ldap_inventory.html), it is impossible for me to enter any ansible-vault key from the AWX UI. In my microsoft.ad.ldap.yml, I'm looking to encrypt the AD service account name and password that I'm using to search all host Active Directory (in specific OU).

Why does it work in CLI (ansible-inventory or ansible-playbook) but it is not possible from the AWX UI?

BartOpitz commented 1 month ago

For this type of issues I have found even better solution - create Custom Credential Type for all credential-related parameters with environment based injector. This will inject environment variables like MICROSOFT_AD_LDAP_CERTIFICATE_KEY and by that parametrize the inventory plugin. Also good practice for all who write inventory plugins is to fall back to environment variables on all credential related vars. That way you can create Custom Credential, and this CAN be attached to inventory sync job. That even saves you from hardcoding vault encrypted credentials in code at all - everything stays in AWX.

There are however still use cases, where such Vault type credential is needed for inventory sync job.