Global vars file?

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?

Isn't that the group_vars/all file?

-sv

Isn't that the group_vars/all file?

-sv

It is!

These have lowest priority and are exactly what you want.

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!

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.

Should we update that page?

Lorin

Yes, best practices probably needs a few updates :slight_smile: