Where to put templates/files outside of a role

46 views
Skip to first unread message

Kai Weber

unread,
Feb 6, 2015, 9:06:12 AM2/6/15
to ansible...@googlegroups.com
Hi,

I am writing a role for varnish. Because Varnish configuration language is
a "real" language I can and will not restrict what configuration a user can
provide. To make it as flexible as possible I planned to use a variable with an
empty default. So a user of my role can provide a complete VCL in a playbook
like this:

- name: Configure varnish host
hosts: 'proxy'
sudo: True
vars:
varnish_vcl_content: |
backend default {
.host = foo
.port = 80
}
roles:
- { role: varnish }

Now my questions:

1. Do you think, this is a good practice?

2. Is there a recommended directory for templates outside of role directories?
Where would you put it? A user can fill the variable like this:

varnish_vcl_content: "{{ lookup('template', 'default.vcl') }}"

Brian Coca

unread,
Feb 6, 2015, 9:50:51 AM2/6/15
to ansible...@googlegroups.com
Lookup plugins will search for relative paths by default in a role's
files/ directory and then in a play's files/ directory.

Also you probably want to just use the file lookup plugin unless you
are inserting jinja statements inside the default.vcl file.

--
Brian Coca
Reply all
Reply to author
Forward
0 new messages