# How to use ansible-vault file per inventory

**URL:** <https://forum.ansible.com/t/how-to-use-ansible-vault-file-per-inventory/11220>\
**Category:** Get Help\
**Created:** [November 29, 2024, 7:49am UTC](https://forum.ansible.com/t/how-to-use-ansible-vault-file-per-inventory/11220 "2024-11-29T07:49:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lundyg](https://avatars.discourse-cdn.com/v4/letter/l/b9e5f3/32.png) [@lundyg](https://forum.ansible.com/u/lundyg)\
**Post date:** [November 29, 2024, 7:49am UTC](https://forum.ansible.com/t/how-to-use-ansible-vault-file-per-inventory/11220/1 "2024-11-29T07:49:02Z")

</div>

Hi,  
I would like to

- use one inventory file per environement ( pre-production , production…)
- store my credentials in an ansible vault file

credentials are specific per environment … so per inventory

How should I do.

I tried in the inventory

```auto
all:
  vars_files:
    - my-vault-file-for-my-env.yml

```

But it fails. It seems inventory only support **vars:** ( but not **vars\_files** )  
I don’t want to list all encrypted vars one by one in **vars:**

Regards,

---

<div class="post-metadata">

**Author:** ![jiholland](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jiholland/32/11273_2.png) [@jiholland](https://forum.ansible.com/u/jiholland)\
**Post date:** [November 29, 2024, 11:21am UTC](https://forum.ansible.com/t/how-to-use-ansible-vault-file-per-inventory/11220/2 "2024-11-29T11:21:27Z")

</div>

You can encrypt your credentials with  
`$ ansible-vault encrypt_string 'example' –name 'ansible_password'`

and paste the output into your inventory:

```yaml
all:
  vars:
    ansible_password: !vault |
          $ANSIBLE_VAULT;1.1;AES256
          62653535306638306233383135366334653064646435633833323366353939333266323263343434
          6538643636626432373138336462353335353265336432630a613261623439643136383234386634
          37666439303139363534623864656437646531303466643234363635613665646237343236636162
          3738613130363633340a636463633866623361363439353331366334653862633161646534633133
          3663

```
