# Question on hosts and group\_vars setup, and error when running playbook

**URL:** <https://forum.ansible.com/t/question-on-hosts-and-group-vars-setup-and-error-when-running-playbook/26602>\
**Category:** Ansible Project\
**Created:** [January 30, 2018, 3:27pm UTC](https://forum.ansible.com/t/question-on-hosts-and-group-vars-setup-and-error-when-running-playbook/26602 "2018-01-30T15:27:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ZillaYT](https://avatars.discourse-cdn.com/v4/letter/z/4da419/32.png) [@ZillaYT](https://forum.ansible.com/u/ZillaYT)\
**Post date:** [January 30, 2018, 3:27pm UTC](https://forum.ansible.com/t/question-on-hosts-and-group-vars-setup-and-error-when-running-playbook/26602/1 "2018-01-30T15:27:23Z")

</div>

I’m following the guidelines discussed in [Laying out roles, inventories and playbooks](https://leucos.github.io/ansible-files-layout), and I have segregated my development vs. productions files this way

`  
/path\_to\_playbooks/inventories/development/host\_vars/git  
/path\_to\_playbooks/inventories/development/host\_vars/atlassian

/path\_to\_playbooks/inventories/production/host\_vars/git  
/path\_to\_playbooks/inventories/production/host\_vars/atlassian

`

I of course have a host group defined in each host file, for example, I may have this in my git host file

`[git_servers] git1.domain.com git2.domain.com`

Now I defined corresponding group vars this way. Is this correct?

`  
/path\_to\_playbooks/inventories/development/group\_vars/git\_servers

/path\_to\_playbooks/inventories/production/group\_vars/git\_servers

`

In the group vars files, I have variables defined, for example:

`  
In /path\_to\_playbooks/inventories/development/group\_vars/git\_servers

admin\_username: git\_admin  
`

I then have a role that simply prints out the admin\_username var

`

- debuyg: msg=“Admin user is {{ admin\_username }}”

`

…and run the playbook this way

`$ ansible-playbook -i inventories/development/host_vars/git setup-git.yml`

setup-git.yml has

`

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [January 30, 2018, 3:41pm UTC](https://forum.ansible.com/t/question-on-hosts-and-group-vars-setup-and-error-when-running-playbook/26602/2 "2018-01-30T15:41:57Z")

</div>

Your inventory (hosts) file should not be inside of group\_vars.

Based on what I have read, your inventory is currently at: /path\_to\_playbooks/inventories/production/host\_vars/git  
It instead needs to be located at: /path\_to\_playbooks/inventories/production/git

Leaving your host\_vars and group\_vars where they are

---

<div class="post-metadata">

**Author:** ![ZillaYT](https://avatars.discourse-cdn.com/v4/letter/z/4da419/32.png) [@ZillaYT](https://forum.ansible.com/u/ZillaYT)\
**Post date:** [January 30, 2018, 4:02pm UTC](https://forum.ansible.com/t/question-on-hosts-and-group-vars-setup-and-error-when-running-playbook/26602/3 "2018-01-30T16:02:29Z")

</div>

Thank you, that was the issue. Now I know that my host files MUST be in the same directory level as my group\_vars directory.
