On ansible 2.1.1.0
given a structure as so
.
|-- inventories
| `-- env
| |-- group_vars
| | `-- someconfig
| `-- hosts.ini
`-- main.yml
group_vars as
---
myconfig: somevalue
hosts.ini as
localhost
[env]
localhost
main.yml as
---
- hosts: env
user: someuser
tasks:
- debug: msg="loaded {{ myconfig }}"
On running
ansible-playbook -i inventories/env/hosts.ini main.yml
Why isn't myconfig loaded ?
From this issue and this link it seems that this is the recommended structure. So why does not the play load the group_vars adjacent from the specified inventory file ?
Configuration files in the group_vars
directory must match the group name defined in the inventory file.
In your case you either have to create a group called someconfig
or rename that particular file to a name of one of your groups, for example env
.