Question on hosts and group_vars setup, and error when running playbook

I’m following the guidelines discussed in Laying out roles, inventories and playbooks, 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

`

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

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.