Extending role variables Ansible

308 Views Asked by At

I am having an Ansible role. In this role, I have vars/main.yml file. In the same directory, I would like to have "secret.yml" file containing vault encrypted variables. What would be the syntax for "main.yml" file to pull the role-wide variables from secret.yml?

secret.yml content:

---
var1: value1
var2: value2

I tried:

main.yml content:

---
- name: Pull variables
  include_vars: secret.yml

error:

→ ./test_deploy.sh
ERROR! failed to combine variables, expected dicts but got a 'dict' and a 'AnsibleSequence':
{}
[{"name": "Pull variables", "include_vars": "secret.yml"}]

main.yml content:

---
- include: secret.yml

error:

→ ./test_deploy.sh
ERROR! failed to combine variables, expected dicts but got a 'dict' and a 'AnsibleSequence':
{}
[{"include": "secret.yml"}]

Does the Ansible even allow for such an import?

0

There are 0 best solutions below