Understanding group vars

22 views
Skip to first unread message

Shua Talansky

unread,
Apr 28, 2016, 7:11:48 PM4/28/16
to Ansible Project
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
```
however when I do 
```
$ ansible selenium_hub -m debug -a "var=hostvars[inventory_hostname]"
```
I get variables that are defined under prod website - what am I doing wrong?

Johannes Kastl

unread,
May 3, 2016, 3:21:25 AM5/3/16
to ansible...@googlegroups.com
On 28.04.16 17:44 Shua Talansky wrote:

> ├── prod
> │ ├── selenium_hub
> │ │ └── vars.yml

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

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

signature.asc
Reply all
Reply to author
Forward
0 new messages