group_var not visible in role?

53 views
Skip to first unread message

Nusenu

unread,
Feb 20, 2015, 5:16:37 PM2/20/15
to ansible...@googlegroups.com
Hi,

I'm having the problem that group_vars do not seem to be visible in the
role. I assumed it should be.


working:
-------------
tasks:

- name: create groups based on pkg
group_by: key={{ansible_pkg_mgr}}

# this one is defined in a group_var
- debug: var=user1
-------------


not working:
-------------
tasks:

- name: create groups based on package manager
group_by: key="{{ansible_pkg_mgr}}"

roles:
- role1
-------------


role1 uses a variable 'user1' that is defined in group_vars/*, but when
running the playbook I get "undefined variables.." in places where a
task tries to access user1.

Is this expected?

thanks,
Nusenu

Dan Vaida

unread,
Feb 21, 2015, 2:25:17 PM2/21/15
to ansible...@googlegroups.com, nus...@openmailbox.org
I think your other thread to which I replied is related to this as well. Perhaps this example would be more helpful: https://github.com/danvaida/Ansible-Berlin-Meetup/blob/master/ansible-intro-examples/ghost.yml
Reply all
Reply to author
Forward
0 new messages