# Ansible Vault API (decrypt programmatically)

**URL:** <https://forum.ansible.com/t/ansible-vault-api-decrypt-programmatically/19244>\
**Category:** Ansible Project\
**Created:** [September 12, 2015, 1:34am UTC](https://forum.ansible.com/t/ansible-vault-api-decrypt-programmatically/19244 "2015-09-12T01:34:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tom\_Paine1](https://avatars.discourse-cdn.com/v4/letter/t/3da27b/32.png) [@Tom\_Paine1](https://forum.ansible.com/u/Tom_Paine1)\
**Post date:** [September 12, 2015, 1:34am UTC](https://forum.ansible.com/t/ansible-vault-api-decrypt-programmatically/19244/1 "2015-09-12T01:34:20Z")

</div>

Are there any examples of using the Ansible Python API to decrypt an existing vault file?

---

<div class="post-metadata">

**Author:** ![Tom\_Paine1](https://avatars.discourse-cdn.com/v4/letter/t/3da27b/32.png) [@Tom\_Paine1](https://forum.ansible.com/u/Tom_Paine1)\
**Post date:** [September 12, 2015, 2:04am UTC](https://forum.ansible.com/t/ansible-vault-api-decrypt-programmatically/19244/2 "2015-09-12T02:04:19Z")

</div>

Well, that was easy!

`

import ansible.utils

bar = dict()

bar = ansible.utils.\_load\_vars\_from\_path(“secrets.yml”, results=bar, vault\_password=“password”)

print bar

`

---

<div class="post-metadata">

**Author:** ![Syed\_Saad\_Ahmed\_Ahme](https://avatars.discourse-cdn.com/v4/letter/s/d6d6ee/32.png) [@Syed\_Saad\_Ahmed\_Ahme](https://forum.ansible.com/u/Syed_Saad_Ahmed_Ahme)\
**Post date:** [March 20, 2017, 2:33pm UTC](https://forum.ansible.com/t/ansible-vault-api-decrypt-programmatically/19244/3 "2017-03-20T14:33:18Z")

</div>

Sit Tom Paine, Hope you are fine !  
Will you please help me, i want examples of using python code for rekeying mechanism for an existing vault file ?  
Your help will be highly appreciated.  
Thanks

---

<div class="post-metadata">

**Author:** ![Syed\_Saad\_Ahmed\_Ahme](https://avatars.discourse-cdn.com/v4/letter/s/d6d6ee/32.png) [@Syed\_Saad\_Ahmed\_Ahme](https://forum.ansible.com/u/Syed_Saad_Ahmed_Ahme)\
**Post date:** [March 20, 2017, 2:47pm UTC](https://forum.ansible.com/t/ansible-vault-api-decrypt-programmatically/19244/4 "2017-03-20T14:47:49Z")

</div>

Are there any examples of using the Ansible Python API for rekeying an existing vault file?
