Add reload script + lineinfile --> ini_file + config ExecReload

This commit is contained in:
Gabriel Périard-Tremblay 2016-11-18 09:51:44 -05:00 committed by Jérémy Lecour
parent 3b1ed33e4b
commit 0b54ccd6c8
3 changed files with 26 additions and 4 deletions

View file

@ -1,2 +1,3 @@
---
thread_pools: "{{ ansible_processor_cores * ansible_processor_count }}"
malloc: "2G"

View 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"

View file

@ -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' }