# using ansible vault from within a playbook

**URL:** <https://forum.ansible.com/t/using-ansible-vault-from-within-a-playbook/19296>\
**Category:** Ansible Project\
**Created:** [September 18, 2015, 3:42am UTC](https://forum.ansible.com/t/using-ansible-vault-from-within-a-playbook/19296 "2015-09-18T03:42:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steve\_McKuhr](https://avatars.discourse-cdn.com/v4/letter/s/bbce88/32.png) [@Steve\_McKuhr](https://forum.ansible.com/u/Steve_McKuhr)\
**Post date:** [September 18, 2015, 3:42am UTC](https://forum.ansible.com/t/using-ansible-vault-from-within-a-playbook/19296/1 "2015-09-18T03:42:23Z")

</div>

Scenario: generate a random password, save it into a config file, encrypt the  
file with ansible-vault then use it to configure db user password on remote.

I'd like this to happen in an automatic manner but when calling 'ansible-vault'  
from within the task it goes into "waiting mode" -- prompting for the password  
I'm guessing. I do call the playbook with '--ask-vault-pass'.

Perhaps my approach to the solving the problem needs to be changed. I could use  
GPG but would like to stick to Ansible native tools. Any suggestions?
