Search code examples
ansibleansible-vault

Can 'extra_vars' receive multiple files?


According the Ansible documentation defining variables at runtime, it says I can load variables from a file.

ansible-playbook release.yml --extra-vars  "@some_file"

However, in my case I have two files containing extra variables for my playbook invocation.

Concatenating them together is not an option because one is a secret file created and keyed using Vault. The other file is generated from an upstream process.

I have tried:

ansible-playbook release.yml --extra-vars  "@some_file @some_other_file"

... but it didn't work. Upon invocation I get

ERROR: file could not read: some_file @some_other_file

so my guess is it takes everything after the first @ symbols as the path of the file.

My questions is, can extra-vars accept multiple files?


Solution

  • It turns out I can use:

    ansible-playbook release.yml --extra-vars=@some_file --extra-vars=@some_other_file
    

    This does work for me. Please let me know if there is a better answer. Thanks.