Group_vars behavior when using directory for inventory and playbooks structured in playbooks folder

9 views
Skip to first unread message

ruv.d...@gmail.com

unread,
Nov 9, 2020, 5:42:40 AM11/9/20
to Ansible Project
Hi all,

I would like to have the following project structure:

.
├── group_vars
│   └── all.yml
├── hosts
│   └── localhost
└── playbooks
    └── main.yml

The problem here is that the group_vars are not loaded in this configuration, they would need to be moved either under the 'hosts' inventory directory or under the playbooks directory.
 Is there any way to make the above structure work? 

Vladimir Botka

unread,
Nov 9, 2020, 6:15:43 AM11/9/20
to ruv.d...@gmail.com, ansible...@googlegroups.com
On Mon, 9 Nov 2020 02:42:40 -0800 (PST)
"ruv.d...@gmail.com" <ruv.d...@gmail.com> wrote:

> *├── group_vars*
> *│ └── all.yml*
> *├── hosts*
> *│ └── localhost*
> *└── playbooks*
> * └── main.yml*
>
> The problem here is that the group_vars are not loaded in this
> configuration, they would need to be moved either under the 'hosts'
> inventory directory or under the playbooks directory.
> Is there any way to make the above structure work?

No. It is not. See "Organizing host and group variables"
https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html#organizing-host-and-group-variables

"Ansible loads host and group variable files by searching paths
relative to the inventory file or the playbook file."

IMHO, the simplest workaround would be a symlink.


--
Vladimir Botka
Reply all
Reply to author
Forward
0 new messages