# Understanding group vars

**URL:** <https://forum.ansible.com/t/understanding-group-vars/21302>\
**Category:** Ansible Project\
**Created:** [April 28, 2016, 3:44pm UTC](https://forum.ansible.com/t/understanding-group-vars/21302 "2016-04-28T15:44:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shua\_Talansky](https://avatars.discourse-cdn.com/v4/letter/s/e495f1/32.png) [@Shua\_Talansky](https://forum.ansible.com/u/Shua_Talansky)\
**Post date:** [April 28, 2016, 3:44pm UTC](https://forum.ansible.com/t/understanding-group-vars/21302/1 "2016-04-28T15:44:11Z")

</div>

Based on these docs [http://docs.ansible.com/ansible/playbooks\_best\_practices.html#group-and-host-variables](http://docs.ansible.com/ansible/playbooks_best_practices.html#group-and-host-variables) I would think this should work.  
I have a yml file with  
db:  
host: 123.45.6.7  
pass: secret

etc… I put one in selenium\_hub and one in website see below I am getting back the wrong vars - ansible selenium\_hub -m debug -a “var=hostvars[inventory\_hostname]”

shua@acm1-mgmt-us-east-1 17:26:10 (master) ~/infrastructure/ansible/group\_vars  
$ tree  
.  
├── all  
│ ├── common.yml  
│ ├── sudo.yml  
│ └── users.yml  
├── dev  
│ ├── sudo.yml  
│ ├── users.yml  
│ └── website  
│ ├── vars.yml  
│ └── vault.yml  
├── prod  
│ ├── selenium\_hub  
│ │ └── vars.yml  
│ ├── selenium\_node  
│ │ └── vars.yml  
│ ├── sudo.yml  
│ ├── users.yml  
│ └── website  
│ ├── vars.yml  
│ └── vault.yml  
└── us-east-1.yml

7 directories, 14 files

```auto
however when I do

```

$ ansible selenium\_hub -m debug -a “var=hostvars[inventory\_hostname]”

```auto
I get variables that are defined under prod website - what am I doing wrong?
```

---

<div class="post-metadata">

**Author:** ![Johannes\_Kastl](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@Johannes\_Kastl](https://forum.ansible.com/u/Johannes_Kastl)\
**Post date:** [May 3, 2016, 5:11am UTC](https://forum.ansible.com/t/understanding-group-vars/21302/2 "2016-05-03T05:11:20Z")

</div>

I thought host-specific variables are in a directory called host\_vars  
(or host\_vars/foobar for the host foobar), while group-specific  
variables go into the directory group\_vars.

So I am surprised you mixed these by having a selenium\_hub folder in  
your prod-group\_vars folder. Maybe that's causing the issue?

Johannes
