In ansible project I have a folder with multiple yaml files with variables. I am fetching these variables to playbook using include_vars module. But now I have to fetch these variables from roles used by playbooks and include_vars module uses vars folder inside role folder so i am unable to fetch variable files from my folder outside the role folder (if the path is relative and the task is inside a role, it will look inside the role’s vars/ subdirectory). Can someone advice how can I fetch vars from folder outside roles when I am using relative path to this folder?
When using include_vars module in role’s main task it always inserts path to vars folder in role into my relative path to variable folder
├── roles
│ ├── apply_configuration
│ │ ├── handlers
│ │ │ └── main.yml
│ │ └── tasks
│ │ └── main.yml
└── topologies
└── topo1
├── device1
│ ├── config_vars
│ │ ├── vars1.yml
│ │ ├── vars2.yml
│ │ ├── vars3.yml
fatal: [device1]: FAILED! => {“ansible_facts”: {}, “ansible_included_var_files”: [], “changed”: false, “message”: “/home/user1/git/ansible_project/roles/apply_configuration/vars/topologies/topo1/device1/config_vars directory does not exist”}
mih is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.