Add reload script + lineinfile --> ini_file + config ExecReload
This commit is contained in:
parent
3b1ed33e4b
commit
0b54ccd6c8
|
@ -1,2 +1,3 @@
|
|||
---
|
||||
thread_pools: "{{ ansible_processor_cores * ansible_processor_count }}"
|
||||
malloc: "2G"
|
||||
|
|
5
varnish/files/reload-vcl.sh
Normal file
5
varnish/files/reload-vcl.sh
Normal file
|
@ -0,0 +1,5 @@
|
|||
#!/bin/sh
|
||||
UUID=`cat /proc/sys/kernel/random/uuid`
|
||||
/usr/sbin/varnishd -C -f /etc/varnish/default.vcl >/dev/null \
|
||||
&&/usr/bin/varnishadm -T localhost:6082 -S /etc/varnish/secret "vcl.load vcl_$UUID /etc/varnish/default.vcl" \
|
||||
&& /usr/bin/varnishadm -T localhost:6082 -S /etc/varnish/secret "vcl.use vcl_$UUID"
|
|
@ -12,11 +12,27 @@
|
|||
copy:
|
||||
src: "/lib/systemd/system/varnish.service"
|
||||
dest: "/etc/systemd/system/"
|
||||
remote_src: True
|
||||
force: no
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
- name: Modify Varnish configuration file
|
||||
lineinfile:
|
||||
- name: Copy Custom Varnish ExecReload script
|
||||
copy:
|
||||
src: "reload-vcl.sh"
|
||||
dest: "/etc/varnish/reload-vcl.sh"
|
||||
mode: 0700
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
- name: Modify Varnish configuration files
|
||||
ini_file:
|
||||
dest: "/etc/systemd/system/varnish.service"
|
||||
regexp: "^ExecStart="
|
||||
line: "ExecStart=/usr/sbin/varnishd -a 0.0.0.0:80 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret -s malloc,2G -p thread_pools={{ thread_pools }} -p thread_pool_add_delay=2 -p thread_pool_min=500 -p thread_pool_max=5000"
|
||||
section: "Service"
|
||||
option: "{{ item.option }}"
|
||||
value: "{{ value.value }}"
|
||||
notify: reload systemctl
|
||||
with_items:
|
||||
- { option: 'ExecStart', value: '/usr/sbin/varnishd -a 0.0.0.0:80 -T localhost:6082 -f /etc/varnish/default.vcl -S /etc/varnish/secret -s malloc,{{ malloc }} -p thread_pools={{ thread_pools }} -p thread_pool_add_delay=2 -p thread_pool_min=500 -p thread_pool_max=5000' }
|
||||
- { option: 'ExecReload', value: '/etc/varnish/reload-vcl.sh' }
|
||||
|
|
Loading…
Reference in a new issue