Skip to content
This repository was archived by the owner on Nov 23, 2021. It is now read-only.

Commit f3b35d0

Browse files
committed
Reworked Varnish service configuration
1 parent 7ad2f1f commit f3b35d0

File tree

7 files changed

+28
-56
lines changed

7 files changed

+28
-56
lines changed

roles/varnish/defaults/main.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ varnish__admin_listen: '6082'
2424
# How much memory is reserved for the Varnish cache
2525
varnish__memory_allocation: '{{ 0.5 * ansible_memtotal_mb|int }}m'
2626

27-
# .. envvar:: varnish__ncsa_enabled
28-
#
29-
# Is Varnish NCSA-style logging enabled?
30-
varnish__ncsa_enabled: True
31-
3227
# .. envvar:: varnish__ttl
3328
#
3429
# Default time to live (TTL) for cached objects.

roles/varnish/handlers/main.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
---
22

3+
- name: Reload systemd daemon
4+
shell: systemctl daemon-reload
5+
notify: Restart varnish
6+
37
- name: Restart varnish
48
service: name=varnish state=restarted
5-
6-
- name: Reload varnish
7-
service: name=varnish state=reloaded
8-
9-
- name: Restart varnishncsa
10-
service: name=varnishncsa state=restarted
11-
12-
- name: Reload varnishncsa
13-
service: name=varnishncsa state=reloaded

roles/varnish/tasks/main.yml

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,14 @@
1010
with_flattened:
1111
- 'varnish'
1212

13-
- name: Configure Varnish
13+
- name: Configure Varnish service
1414
template:
15-
src: 'etc/default/varnish.j2'
16-
dest: '/etc/default/varnish'
15+
src: 'etc/systemd/system/varnish.service.j2'
16+
dest: '/etc/systemd/system/varnish.service'
1717
owner: 'root'
1818
group: 'root'
1919
mode: '0644'
20-
notify: [ 'Restart varnish' ]
21-
22-
- name: Append "varnish" group to "varnishlog" user
23-
user:
24-
name: 'varnishlog'
25-
append: 'true'
26-
groups: 'varnish'
27-
28-
- name: Configure Varnish NCSA-style logging
29-
template:
30-
src: 'etc/default/varnishncsa.j2'
31-
dest: '/etc/default/varnishncsa'
32-
owner: 'root'
33-
group: 'root'
34-
mode: '0644'
35-
notify: [ 'Restart varnishncsa' ]
20+
notify: [ 'Reload systemd daemon' ]
3621

3722
- name: Configure default.vcl for Varnish
3823
template:

roles/varnish/templates/etc/default/varnish.j2

Lines changed: 0 additions & 19 deletions
This file was deleted.

roles/varnish/templates/etc/default/varnishncsa.j2

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# {{ ansible_managed }}
2+
3+
[Unit]
4+
Description=Varnish HTTP accelerator
5+
Documentation=https://www.varnish-cache.org/docs/4.1/ man:varnishd
6+
7+
[Service]
8+
Type=simple
9+
LimitNOFILE=131072
10+
LimitMEMLOCK=82000
11+
PIDFile=/run/varnishd.pid
12+
ExecStart=/usr/sbin/varnishd -j unix,user=vcache -P /run/varnishd.pid -F -a *:{{ varnish__listen }} -T localhost:{{ varnish__admin_listen }} -t {{ varnish__ttl }} -f /etc/varnish/default.vcl -S /etc/varnish/secret -s malloc,{{ varnish__memory_allocation }}
13+
ExecReload=/usr/share/varnish/reload-vcl
14+
ProtectSystem=full
15+
ProtectHome=true
16+
PrivateTmp=true
17+
PrivateDevices=true
18+
19+
[Install]
20+
WantedBy=multi-user.target

roles/wordpress/meta/main.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ dependencies:
7474
tags: [ 'depend::varnish', 'depend::varnish:wordpress', 'depend-of::wordpress', 'type::dependency' ]
7575
varnish__listen: '{{ wordpress__varnish_listen }}'
7676
varnish__backends: [ '{{ wordpress__varnish_backend }}' ]
77-
varnish__ncsa_enabled: '{{ wordpress__varnish_ncsa_enabled }}'
7877
varnish__add_ban_lurker_headers: '{{ wordpress__varnish_add_ban_lurker_headers }}'
7978
varnish__normalize_query_parameters: '{{ wordpress__varnish_normalize_query_parameters }}'
8079
varnish__purge_allow: '{{ wordpress__varnish_purge_allow }}'

0 commit comments

Comments
 (0)