-
Notifications
You must be signed in to change notification settings - Fork 898
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ansible_runner] Add VaultCredential #19002
[ansible_runner] Add VaultCredential #19002
Conversation
So just a quick update, needed a patch to get this to work: diff --git a/app/models/manageiq/providers/embedded_ansible/automation_manager/configuration_script.rb b/app/models/manageiq/providers/embedded_ansible/automation_manager/configuration_script.rb
index be691cb..d3ef787 100644
--- a/app/models/manageiq/providers/embedded_ansible/automation_manager/configuration_script.rb
+++ b/app/models/manageiq/providers/embedded_ansible/automation_manager/configuration_script.rb
@@ -51,7 +51,7 @@ class ManageIQ::Providers::EmbeddedAnsible::AutomationManager::ConfigurationScri
end
def collect_credentials(options)
- options.values_at(
+ options.symbolize_keys.values_at(
:credential,
:cloud_credential,
:network_credential, But using this playbook: Everything worked as expected. Will make a PR for the above patch tomorrow (err... later this morning...). |
@NickLaMuro I'm not sure why you would need that patch ... That should be a |
Yup, @carbonin was right. After a out of band chat, we determined it was a combination of misleading debugging and incorrectly adding the vault credential (and didn't have a password). Going to clean up the PR description, but I think this is mostly ready to be merged after. |
Actually, I am quickly going to change the code to use an environment variable instead (per carboni's suggestion). Back in a bit. |
NOTE: The `--vault-password-file` is used instead of populating the `env/passwords` file here in case multiple credentials were used at the same time. This differs from how `awx` does things: https://github.com/ansible/awx/blob/1242ee2b/awx/main/tasks.py#L1554 Where as passwords expect file yaml file is used, but there is also contextual awareness of all of the passwords being added at the time of writing the file, where in the current case of MIQ, this is done for each credential type, so we don't have the context available at when writing the files.
8de08a2
to
62dd90c
Compare
Checked commit NickLaMuro@62dd90c with ruby 2.4.6, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0 |
Adds
Ansible::Runner::VaultCredential
.NOTE: The
--vault-password-file
is used instead of populating theenv/passwords
file here in case multiple credentials were used at the same time. This differs from howawx
does things:https://github.com/ansible/awx/blob/1242ee2b/awx/main/tasks.py#L1554
Where the
env/passwords
file (/usr/bin/expect
style) is used, but there is also contextual awareness of all of the passwords being added inawx
at the time of writing the file allowing this to work without adding conflicts. In the current case of MIQ, this is done for each credential type but overall scope of the play is missing, so we don't have the context available at when writing the files to ensure there aren't conflicts.Steps for Testing/QA
Still working on wiring things up in MIQ to provide a way of testing this (this is much easier to test than with cloud credentials), so will update this section and most likely remove the[WIP]
label once I do.Using the following playbook repo:
https://github.com/NickLaMuro/ansible-tower-samples
EmbeddedAnsible
Automation -> Ansible -> Repositories
, add the above repo's master branchAutomation -> Ansible -> Credentials
, add a vault credential with a password of "vault"hello_world_vault_encrypted.yml
playbook