path to group_vars

88 views
Skip to first unread message

jepper

unread,
Oct 21, 2015, 7:02:22 AM10/21/15
to Ansible Project
This might be a really dumb question. I am working on a project where the directory structure looks like the tree below. I am looking for confirmation from the forum that this will not read anything group_vars, as group_vars from what I can deduct, should live within the inventory directory, being relative to the inventory (and this cannot be changed in ansible.cfg?). Is my understanding correct?

├── apserver.yml
├── dbservers.yml
├── group_vars
│   ├── all (F)
│   ├── apservers (F)
│   └── dbservers (F)
├── inventory
│   ├── dev (F)
│   └── prod  (F)
├── roles
│   ├── activemq
│   │   ├── tasks
│   │   │   ├── main.yml

For avoidance of doubt, (F) means the entry is a file.

jepper

unread,
Oct 21, 2015, 7:56:46 AM10/21/15
to Ansible Project
On another project, I have my inventory file in a directory called env/sandbox 
├── env
│   └── sandbox
│       ├── group_vars
│       │   └── all
│       └── inventory


I then created this at the root of the ansible directory, with different variables.
├── group_vars
│   └── all

Running ansible-playbook -i env/sandbox/inventory site.yml, values from group_vars/all is used, instead of env/sandbox/group_vars/all.

I am confused. While it is suggested one may elect to have group_vars in the root directory, my understanding was that group_vars was relative to inventory. Apparently not. 

Brian Coca

unread,
Oct 21, 2015, 7:38:36 PM10/21/15
to Ansible Project
group/host_vars MUST be relative either to the inventory or to the
play being run.


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