0

How can I pass the password of ansible-vault stored in an environment variable to the command

ansible-playbook play.yml -i hosts --ask-vault-pass

I can't pass a file or have an interactive shell to enter the password since the commands are run from a pipeline that does not support them.

I tried something like

echo $PASS | ansible-playbook play.yml -i hosts --ask-vault-pass

But that did not work.

I read the docs https://docs.ansible.com/ansible/latest/user_guide/vault.html but I couldn't find a solution there.

RPT
  • 728
  • 1
  • 10
  • 29

1 Answers1

2

There is a issue open in github for this environment variable ansible https://github.com/ansible/ansible/issues/45214

As a workaround you can use ANSIBLE_VAULT_PASSWORD_FILE variable on the ansible server.

This variable will point to the file which will hold the password to unlock the ansible vault.

error404
  • 2,684
  • 2
  • 13
  • 21