ej_6da
Last Updated: February 25, 2016
·
1.75K
· lorin

Specify a base directory

If your ansible playbooks live in a git repository, you can use this trick to specify a base directory for resolving your includes:

Add the following line to <INVENTORY_FILE_LOCATION>/group_vars/all:

base: "{{ lookup('pipe', 'git rev-parse --show-toplevel') }}"

Now you can do includes like this:

- include: {{ base }}/nginx/setup.yaml

4 Responses
Add your response

4433

Might want to use a local play and register it instead, just as that will execute a few too many times if used a lot... we need to get the "PIPE_ONCE" part going.

over 1 year ago ·
4434

If I just change that from PIPE to PIPE_ONCE, will that do the trick?

over 1 year ago ·
12931

New syntax for ansible using jinja:
base: "{{ lookup('pipe', 'git rev-parse --show-toplevel') }}"

over 1 year ago ·
12932

@gblahaerath Thanks, I updated the tip accordingly.

over 1 year ago ·