# group\_vars not visible to playbook

**URL:** <https://forum.ansible.com/t/group-vars-not-visible-to-playbook/15686>\
**Category:** Ansible Project\
**Created:** [July 17, 2014, 4:09am UTC](https://forum.ansible.com/t/group-vars-not-visible-to-playbook/15686 "2014-07-17T04:09:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Wang](https://avatars.discourse-cdn.com/v4/letter/j/cdc98d/32.png) [@John\_Wang](https://forum.ansible.com/u/John_Wang)\
**Post date:** [July 17, 2014, 4:09am UTC](https://forum.ansible.com/t/group-vars-not-visible-to-playbook/15686/1 "2014-07-17T04:09:17Z")

</div>

Hi,

It’s seemed that variables defined in the group\_vars are not visible to playbooks. Then where should I keep the those variables?  
Here is what I’m trying to do:

directory tree:

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [July 17, 2014, 7:37am UTC](https://forum.ansible.com/t/group-vars-not-visible-to-playbook/15686/2 "2014-07-17T07:37:59Z")

</div>

You cant't define something that points to the inventory (hosts: in the  
play) with something that comes from the inventory (group\_vars)​. That  
would create a black hole.

---

<div class="post-metadata">

**Author:** ![John\_Wang](https://avatars.discourse-cdn.com/v4/letter/j/cdc98d/32.png) [@John\_Wang](https://forum.ansible.com/u/John_Wang)\
**Post date:** [July 17, 2014, 9:29am UTC](https://forum.ansible.com/t/group-vars-not-visible-to-playbook/15686/3 "2014-07-17T09:29:05Z")

</div>

I felt that. Then is there a way to define variable which can be used in the position of the mentioned “var1” in foo.yml ? Is the command line options (i.e., -e) is the only way ?

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [July 17, 2014, 9:33am UTC](https://forum.ansible.com/t/group-vars-not-visible-to-playbook/15686/4 "2014-07-17T09:33:06Z")

</div>

​I believe so yes. Not sure if there's a way to use a var from var: of  
vars\_files: section, but maybe if set in a previous play.​

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [July 17, 2014, 12:31pm UTC](https://forum.ansible.com/t/group-vars-not-visible-to-playbook/15686/5 "2014-07-17T12:31:34Z")

</div>

If you want to pass in the host specifier, you’ll need to use “-e”. Or maybe a lookup plugin reading an environment variable. -e is a bit clear.

-e @filename.yml is also a valid syntax.

---

<div class="post-metadata">

**Author:** ![John\_Wang](https://avatars.discourse-cdn.com/v4/letter/j/cdc98d/32.png) [@John\_Wang](https://forum.ansible.com/u/John_Wang)\
**Post date:** [July 17, 2014, 2:58pm UTC](https://forum.ansible.com/t/group-vars-not-visible-to-playbook/15686/6 "2014-07-17T14:58:19Z")

</div>

> If you want to pass in the host specifier, you’ll need to use “-e”. Or maybe a lookup plugin reading an environment variable. -e is a bit clear.
> 
> -e @filename.yml is also a valid syntax.

Ok, I see. Thanks for mentioning the @filename.yml syntax also.
