ej_6da
Last Updated: February 25, 2016
·
1.708K
· lorin
Me pixel

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
Say Thanks
Respond

4 Responses
Add your response

4433
3c1b7e921632632e11d5d2ee59403f5f

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
Me pixel

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

over 1 year ago ·
12931
1944a75dbe7ef6ca39081aeee2acd440

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

over 1 year ago ·
12932
Me pixel

@gblahaerath Thanks, I updated the tip accordingly.

over 1 year ago ·
Filed Under

Awesome Job

Bc0a6794 05ee 11e8 902a 778405599bdb
Software Engineer
·
Denver, San Francisco
·
Full Time