Location of host and group configuration

16 views
Skip to first unread message

Uwe Sauter

unread,
Sep 1, 2016, 5:10:10 AM9/1/16
to Ansible Project
Hi all,

I'm currently struggling with how to tell Ansible where it can find host_vars and group_vars folders. Is there an environmet
variable for it? Does it have to be inside the same folder as the playbook?

Regards,

Uwe

ankur...@gmail.com

unread,
Sep 1, 2016, 6:29:45 AM9/1/16
to Ansible Project, uwe.sa...@gmail.com
It can be inside the same folder as the playbook.

root
  -- group_vars/all.yml
  -- host_vars/some_host.yml
  -- myPlaybook.yml

Uwe Sauter

unread,
Sep 1, 2016, 6:39:29 AM9/1/16
to ankur...@gmail.com, Ansible Project
Yes, that I've alredy figured out. But what if I want to group my playbooks inside different folders but the group and host vars
should be the same? Is there an option to tell Ansible where to look for those folders?

I imagine a dir tree like:

.
├── group_vars
│ ├── group1.yaml
│ └── group2.yaml
├── host_vars
│ ├── host1.yaml
│ ├── host2.yaml
│ └── localhost.yaml
├── group1-playbooks
│ ├── 00-requirements.yaml
│ ├── 01-copy-static-files.yaml
│ └── 99-cleanup.yaml
├── group2-playbooks
│ ├── 00-requirements.yaml
│ ├── 01-copy-static-files.yaml
│ └── 99-cleanup.yaml
└── inventory

Regards,

Uwe

Kai Stian Olstad

unread,
Sep 1, 2016, 7:26:26 AM9/1/16
to ansible...@googlegroups.com
On 01. sep. 2016 12:39, Uwe Sauter wrote:
> Yes, that I've alredy figured out. But what if I want to group my playbooks inside different folders but the group and host vars
> should be the same? Is there an option to tell Ansible where to look for those folders?

I don't think that is possible. You need to have the group_vars and
host_vars in the inventory directory or the playbook directory.
group_vars and host_vars in the playbook directory will overwrite those
in the inventory directory if both exist.

--
Kai Stian Olstad
Reply all
Reply to author
Forward
0 new messages