# global vars, vars\_file?

**URL:** <https://forum.ansible.com/t/global-vars-vars-file/12227>\
**Category:** Ansible Project\
**Created:** [January 21, 2013, 11:18pm UTC](https://forum.ansible.com/t/global-vars-vars-file/12227 "2013-01-21T23:18:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Wong](https://avatars.discourse-cdn.com/v4/letter/j/6f9a4e/32.png) [@John\_Wong](https://forum.ansible.com/u/John_Wong)\
**Post date:** [January 21, 2013, 11:18pm UTC](https://forum.ansible.com/t/global-vars-vars-file/12227/1 "2013-01-21T23:18:54Z")

</div>

This is how I structure my playbooks

/root/  
bootstrap.yml  
master.yml  
slave.yml

/apt/  
tasks/  
common.yml  
master.yml  
slave.yml

bootstrap is entry point

In bootstrap.yml I include master and slave playbooks

- include master.yml
- include slave.yml

In master and slave I need to include common,yml and {name}.yml

Common.yml contains common apt packages. I make user and hosts attribute as variables.

I want to supply a global var $user and $hosts in bootstrap.yml

---

<div class="post-metadata">

**Author:** ![John\_Wong](https://avatars.discourse-cdn.com/v4/letter/j/6f9a4e/32.png) [@John\_Wong](https://forum.ansible.com/u/John_Wong)\
**Post date:** [January 21, 2013, 11:39pm UTC](https://forum.ansible.com/t/global-vars-vars-file/12227/2 "2013-01-21T23:39:55Z")

</div>

The alternative is to place “include comm.yml” under apt/tasks/slave.yml and apt/tasks/master.yml, either as a standalone include, or a task-level include. The task-level include can pass in the parameters. That’s okay.  
But looking for a global var solution.

Thanks

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [January 22, 2013, 1:04pm UTC](https://forum.ansible.com/t/global-vars-vars-file/12227/3 "2013-01-22T13:04:21Z")

</div>

> Is there a way to specify global level vars? Currently, I have to specify it  
> by hand.

In the same directory as your inventory file, make a 'group\_vars/all'  
file and put it there, in YAML, without the "vars:" indent.

---

<div class="post-metadata">

**Author:** ![John\_Wong](https://avatars.discourse-cdn.com/v4/letter/j/6f9a4e/32.png) [@John\_Wong](https://forum.ansible.com/u/John_Wong)\
**Post date:** [January 24, 2013, 5:02am UTC](https://forum.ansible.com/t/global-vars-vars-file/12227/4 "2013-01-24T05:02:07Z")

</div>

Thanks. I double check with the docs. Not sure if I miss anything.

I issue  
ansible-playbook playbooks/bootstrap.yml -i /home/glasslab/workstation/vagrant-workstation/tests4/graphyte\_playbooks/hosts -u vagrant -k -vvv

inside graphyte\_playbooks

> graphyte\_playbooks/
> 
> - hosts  
> /group\_vars
> - master  
> /playbooks
> - bootstrap.yml
> - common.yml  
> /apt
> - setup.yml

In my bootstrap.yml I have

- include: common.yml hosts=master

and in common.yml I have - include: apt/setup.yml

The only place I define $hosts and $user are in apt/setup.yml

But instead, the debug shows user is not substituted.  
u’User=$user’, ‘192.168.1.151’

I just put the following in group\_vars/master
