how are variable files found?

I can’t figure out how to organise my variables.

For roles, they are in a vars directory relative to the role, alongside tasks, meta etc.

For playbooks, directories like group_vars are found if placed in the same directory as the playbook.

However, I have variables common to more than one playbook, with the playbooks in different locations.

What I want is to be able to have an Ansible directory located somewhere on my system, with various projects below it, organised so that the directory tree is self-contained. This lets me put it in git and have nothing missing. But to do that I need to somehow tell Ansible where that topmost directory is, and I need to be able to point playbooks at locations that are relative to that topmost directory.

Is there some nicer way than hardcoding absolute paths into playbooks?

BTW this is not about groups; it’s about being able to build the same things in different environments, and needing sets of variables that define those environments to be available to many different playbooks.

Regards, K.

I’ve found a solution which is neat, though probably obvious to all here :slight_smile:

I set up an environment variable XXX_ROOT and I make everything relative to “{{ansible_env.XXX_ROOT}}/”. That way I can move really easily to another tree by just changing the one environment variable, or even work in multiple trees in different windows.

Regards, K.