The vault password can be exported to the machine where you want to run the ansible playbook (like a local machine or Jenkins, etc.) and run the playbook as follows:
To export the ansible vault password
export VAULT_PASSWORD=valut-password-here
Then you can use it in two ways, either directly.
ansible-playbook your-playbook.yml --vault-password-file <(cat <<<"$VAULT_PASSWORD")
By using the Python OS module, you can read from the environment and then pass it to the Ansible Playbook.
ansible-playbook your-playbook.yml --vault-password-file ./vault_password.py
where vault_password.py
has this code:
#!/usr/bin/env python
import os
print os.environ['VAULT_PASSWORD']