Ansible not pulling in group_vars

135 views
Skip to first unread message

datsun80

unread,
Jul 29, 2015, 4:29:29 PM7/29/15
to Ansible Project
I moved my inventory files to their own directory and now the group_vars are not loading. 

Ansible Docs state:
Tip: In Ansible 1.2 or later the group_vars/ and host_vars/ directories can exist in either the playbook directory OR the inventory directory. If both paths exist, variables in the playbook directory will override variables set in the inventory directory.

My current layout is as follows:
├── hosts
│   └── dev
│   └── qa
├── group_vars
│   ├── all
│   └── dev
│   └── qa
├── roles
├── site.yml

What am I missing? If I move the inventory files back to the main directory with site.yml Ansible correctly pickups the group_vars.

senorsmile

unread,
Jul 29, 2015, 7:11:25 PM7/29/15
to Ansible Project, tim....@virginhealthmiles.com
How are you setting the inventory (I assume the hosts folder contain your inventory files).  Give us a sample of what's in the inventory files?

datsun80

unread,
Jul 30, 2015, 9:21:39 AM7/30/15
to Ansible Project, senor...@gmail.com
Yes, the hosts folder contains the inventory files.

I am calling it like so:
ansible-playbook -i hosts/qa -t redis site.yml

In the inventory file I have:
- name: Redis Server
hosts: redis
sudo: yes
roles:
- { role: redis, tags: ['redis'] }

Guy Matz

unread,
Jul 30, 2015, 11:29:12 AM7/30/15
to ansible...@googlegroups.com
Is that your inventory?  Or your site.yml?

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/944c4da6-e90d-4ba9-b7fb-d2d594086b7b%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

datsun80

unread,
Jul 30, 2015, 11:32:25 AM7/30/15
to Ansible Project, gm...@matz.org
Yes, I mistyped. This is in my site.yml file:

- name: Redis Server
hosts: redis
sudo: yes
roles:
- { role: redis, tags: ['redis'] }

datsun80

unread,
Aug 4, 2015, 10:35:26 AM8/4/15
to Ansible Project
No ideas? 

John Barker

unread,
Aug 4, 2015, 1:56:48 PM8/4/15
to Ansible Project
Are you using the

[qa:children] notation in your inventory files,
If so make sure you've copied that into the correct files when you split out to use separate inventory files.



John

datsun80

unread,
Aug 4, 2015, 2:06:59 PM8/4/15
to Ansible Project
Yes, my qa inventory has the following:

[redis]
1.1.1.1

[qa:children]
redis

datsun80

unread,
Aug 6, 2015, 10:52:11 AM8/6/15
to Ansible Project
I ended up reverting back to my old file structure to continue working on other projects. I just now tried again by moving the inventories to their own directory and to my surprise they are now pulling in the group vars. Not sure what I did before, but it is working now.
Reply all
Reply to author
Forward
0 new messages