# Global vars file?

**URL:** <https://forum.ansible.com/t/global-vars-file/12320>\
**Category:** Ansible Project\
**Created:** [February 10, 2013, 1:39am UTC](https://forum.ansible.com/t/global-vars-file/12320 "2013-02-10T01:39:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![fdavis](https://avatars.discourse-cdn.com/v4/letter/f/a698b9/32.png) [@fdavis](https://forum.ansible.com/u/fdavis)\
**Post date:** [February 10, 2013, 1:39am UTC](https://forum.ansible.com/t/global-vars-file/12320/1 "2013-02-10T01:39:37Z")

</div>

In the case of variables that don’t change for an entire infrastructure.  
Such as, the ticket queue gets emails at “admin@your.domain.here”

I was wondering if there could be an easier/automatic way to include a ‘global-vars.yml’.  
This isn’t so much a feature as it is a time saving and typo preventing device.

I don’t know if it would be better as a configurable,

in ansible.cfg  
global\_vars=/path/to/repo/global-vars.yml  
or as environment variable  
export ANSIBLE\_GLOBAL\_VARS=/path/to/repo/global-vars.yml

or an include base path.

in ansible.cfg  
playbooks\_home=/path/to/repo  
or as environment variable  
export ANSIBLE\_PLAYBOOKS\_HOME=/path/to/repo

The only reason I suggest the latter, is because I remember someone asking about  
a base path for includes. I don’t remember what happened to that thread.  
I think they wanted to includes tasks?

- include: ${some\_basepath\_variable}/path/to/task

Perhaps we could solve both problems at once with that idea?

Any interest here?

---

<div class="post-metadata">

**Author:** ![Seth\_Vidal](https://avatars.discourse-cdn.com/v4/letter/s/7ba0ec/32.png) [@Seth\_Vidal](https://forum.ansible.com/u/Seth_Vidal)\
**Post date:** [February 10, 2013, 2:07am UTC](https://forum.ansible.com/t/global-vars-file/12320/2 "2013-02-10T02:07:26Z")

</div>

Isn't that the group\_vars/all file?

-sv

---

<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:** [February 10, 2013, 2:50am UTC](https://forum.ansible.com/t/global-vars-file/12320/3 "2013-02-10T02:50:14Z")

</div>

> Isn't that the group\_vars/all file?
> 
> -sv

It is!

These have lowest priority and are exactly what you want.

---

<div class="post-metadata">

**Author:** ![fdavis](https://avatars.discourse-cdn.com/v4/letter/f/a698b9/32.png) [@fdavis](https://forum.ansible.com/u/fdavis)\
**Post date:** [February 10, 2013, 4:29am UTC](https://forum.ansible.com/t/global-vars-file/12320/4 "2013-02-10T04:29:32Z")

</div>

Wow. I can’t believe I missed that.

Our inventory isn’t in /etc, for some reason I completely  
missed that the docs say “relative” to the inventory file.

Even so, I bet I could’ve used the following inside of the inventory file.

[all:vars]  
variables …

Thank you!

---

<div class="post-metadata">

**Author:** ![Lorin\_Hochstein1](https://avatars.discourse-cdn.com/v4/letter/l/ce73a5/32.png) [@Lorin\_Hochstein1](https://forum.ansible.com/u/Lorin_Hochstein1)\
**Post date:** [February 10, 2013, 4:37am UTC](https://forum.ansible.com/t/global-vars-file/12320/5 "2013-02-10T04:37:11Z")

</div>

Oooh, that's nice, I'm going to use that as well.

I had started with a global\_vars.yaml file that was I explicitly importing.  
I got the idea from [http://ansible.cc/docs/bestpractices.html](http://ansible.cc/docs/bestpractices.html).

Should we update that page?

Lorin

---

<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:** [February 10, 2013, 4:38am UTC](https://forum.ansible.com/t/global-vars-file/12320/6 "2013-02-10T04:38:00Z")

</div>

Yes, best practices probably needs a few updates 🙂
