vars_files, include_vars don't work with role vars

26 views
Skip to first unread message

1.61803

unread,
Oct 31, 2017, 6:33:58 AM10/31/17
to Ansible Project

I want to separate vars in a role structure from vars/main.yml into different files using vars_files or include_vars as per Variable File Separation, with something like


---
- vars_files: external_vars.yml


but I get this message


ERROR! The vars/main.yml file for role 'foo' must contain a dictionary of variables


If I omit the dash for the list it still doesn't work and get another message, which I haven't saved for this post.


I use ansible 2.3.2.0.


Shouldn't either work in such a case? Is there any other way to accomplish this?

Brian Coca

unread,
Oct 31, 2017, 11:04:20 AM10/31/17
to Ansible Project
The vars/main.yml cannot contain keywords, it (like all vars files)
MUST be a dictionary, not a list.

There is no way to do 'includes' inside a vars file. What you are
doing is just not supported.




--
----------
Brian Coca

1.61803

unread,
Oct 31, 2017, 11:50:21 AM10/31/17
to Ansible Project
On Tuesday, October 31, 2017 at 4:04:20 PM UTC+1, Brian Coca wrote:
The vars/main.yml cannot contain keywords, it (like all vars files) MUST be a dictionary, not a list.
There is no way to do 'includes' inside a vars file. What you are doing is just not supported.

Since you triaged #32328, could you turn it into a feature request? Role vars separation would be a useful addition.
Reply all
Reply to author
Forward
0 new messages