How can i include other var files in a yaml file with only variables defined

14 views
Skip to first unread message

ishan jain

unread,
Oct 24, 2016, 7:57:15 AM10/24/16
to Ansible Project
Hi,

I use simple YAML files for defining some constant values to be used in my playbooks. A typical file would look like this:

var1: abc
var2: xyz
var3:
   - item1
   - item2
var4:
   4.1: a
   4.2: b


I simply include the the file(s) like above in my playbooks in vars: section and all the constant values are available to me. Now i have a situation where i would like to break my vars file into several sub categories and include them all in one main vars file. I expect that i will have to include this one var file and others would be imported by this var file. I used include statement to have this:

- include: subvars1.yaml
- include: subvars2.yaml
var1: abc
var2: xyz
var3:
   - item1
   - item2


But this one is failing with some syntax error message. 
How can i include another vars file into one vars only file ?

Brian Coca

unread,
Oct 24, 2016, 9:27:21 AM10/24/16
to ansible...@googlegroups.com
You cannot, YAML does not have an include feature.


----------
Brian Coca
Reply all
Reply to author
Forward
0 new messages