varnish: add templating of default.vcl
This commit is contained in:
parent
cbd7772f76
commit
7310004d3d
|
@ -1,3 +1,9 @@
|
||||||
---
|
---
|
||||||
- name: reload systemctl
|
- name: reload systemctl
|
||||||
command: systemctl daemon-reload
|
systemd:
|
||||||
|
daemon_reload: yes
|
||||||
|
|
||||||
|
- name: reload varnish
|
||||||
|
service:
|
||||||
|
name: varnish
|
||||||
|
state: reloaded
|
||||||
|
|
|
@ -39,3 +39,15 @@
|
||||||
with_items:
|
with_items:
|
||||||
- varnishlog
|
- varnishlog
|
||||||
- varnishncsa
|
- varnishncsa
|
||||||
|
|
||||||
|
- name: Copy Varnish configuration
|
||||||
|
template:
|
||||||
|
src: "{{ item }}"
|
||||||
|
dest: /etc/varnish/default.vcl
|
||||||
|
force: yes
|
||||||
|
with_first_found:
|
||||||
|
- "templates/varnish/default.{{ inventory_hostname }}.vcl.j2"
|
||||||
|
- "templates/varnish/default.{{ host_group }}.vcl.j2"
|
||||||
|
- "templates/varnish/default.default.vcl.j2"
|
||||||
|
- "default.vcl.j2"
|
||||||
|
notify: reload varnish
|
||||||
|
|
41
varnish/templates/default.vcl.j2
Normal file
41
varnish/templates/default.vcl.j2
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
#
|
||||||
|
# This is an example VCL file for Varnish.
|
||||||
|
#
|
||||||
|
# It does not do anything by default, delegating control to the
|
||||||
|
# builtin VCL. The builtin VCL is called when there is no explicit
|
||||||
|
# return statement.
|
||||||
|
#
|
||||||
|
# See the VCL chapters in the Users Guide at https://www.varnish-cache.org/docs/
|
||||||
|
# and http://varnish-cache.org/trac/wiki/VCLExamples for more examples.
|
||||||
|
|
||||||
|
# Marker to tell the VCL compiler that this VCL has been adapted to the
|
||||||
|
# new 4.0 format.
|
||||||
|
vcl 4.0;
|
||||||
|
|
||||||
|
# Default backend definition. Set this to point to your content server.
|
||||||
|
backend default {
|
||||||
|
.host = "127.0.0.1";
|
||||||
|
.port = "8080";
|
||||||
|
}
|
||||||
|
|
||||||
|
sub vcl_recv {
|
||||||
|
# Happens before we check if we have this in cache already.
|
||||||
|
#
|
||||||
|
# Typically you clean up the request here, removing cookies you don't need,
|
||||||
|
# rewriting the request, etc.
|
||||||
|
}
|
||||||
|
|
||||||
|
sub vcl_backend_response {
|
||||||
|
# Happens after we have read the response headers from the backend.
|
||||||
|
#
|
||||||
|
# Here you clean the response headers, removing silly Set-Cookie headers
|
||||||
|
# and other mistakes your backend does.
|
||||||
|
}
|
||||||
|
|
||||||
|
sub vcl_deliver {
|
||||||
|
# Happens when we have all the pieces we need, and are about to send the
|
||||||
|
# response to the client.
|
||||||
|
#
|
||||||
|
# You can do accounting or modifying the final object here.
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue