How to use ansible-vault file per inventory

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

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,

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

and paste the output into your inventory:

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