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

On Tue, Jan 30, 2018 at 9:27 AM, ZillaYT <[email protected]> wrote:

> 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
>
> ---
> - hosts: git_servers
>
> But I get an error that says
>
> fatal: [git1.domain.com]: FAILED! => {"msg": "'admin_username' is
> undefined"}
>
>
> So I'm wondering why Ansible does NOT see "admin_username" defined in my
> group_vars file?
>
>
> Thanks!
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/ansible-project/fa135ded-c9dc-4e1b-b69c-07917241a3ba%40googlegroups.
> com
> <https://groups.google.com/d/msgid/ansible-project/fa135ded-c9dc-4e1b-b69c-07917241a3ba%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Matt Martz
@sivel
sivel.net

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAD8N0v9kcZp01u1oRb4V9H0rGd8DtKhLbt6S3J6gipucyT5DAw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to