-
-
Notifications
You must be signed in to change notification settings - Fork 87
/
main.yml
98 lines (87 loc) · 2.95 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
---
- name: Include OS-specific variables.
include_vars: "{{ ansible_os_family }}.yml"
- name: Set the packagecloud repository name based on the version.
set_fact:
varnish_packagecloud_repo: "varnish{{ varnish_version|replace('.', '') }}"
- include_tasks: setup-RedHat.yml
when: ansible_os_family == 'RedHat'
- include_tasks: setup-Debian.yml
when: ansible_os_family == 'Debian'
- name: Ensure Varnish config path exists.
file:
path: "{{ varnish_systemd_override_path }}"
state: directory
mode: 0755
- name: Copy Varnish configuration (sysvinit).
template:
src: varnish.j2
dest: "{{ varnish_sysvinit_config_path }}/varnish"
owner: root
group: root
mode: 0644
when: >
(ansible_os_family == 'RedHat' and ansible_distribution_major_version|int < 7) or
(ansible_os_family == 'Debian' and ansible_distribution_release != "xenial")
notify: restart varnish
- name: Copy override for systemd unit.
template:
src: varnish.service.j2
dest: "{{ varnish_systemd_override_path }}/varnish.service"
owner: root
group: root
mode: 0644
when: >
(ansible_os_family == 'RedHat' and ansible_distribution_major_version|int >= 7) or
(ansible_distribution == 'Debian' and ansible_distribution_version|int >= 8) or
(ansible_distribution == 'Ubuntu' and ansible_distribution_version.split(".")[0]|int >= 16)
notify:
- reload systemd
- restart varnish
- name: Copy Varnish configuration (systemd).
template:
src: varnish.params.j2
dest: "{{ varnish_config_path }}/varnish.params"
owner: root
group: root
mode: 0644
when: >
(ansible_os_family == 'RedHat' and ansible_distribution_major_version|int >= 7) or
(ansible_os_family == 'Debian' and ansible_distribution_release == "xenial")
- name: Copy Varnish default VCL.
template:
src: "{{ varnish_default_vcl_template_path }}"
dest: "{{ varnish_config_path }}/default.vcl"
owner: root
group: root
mode: 0644
when: varnish_use_default_vcl
notify: restart varnish
- name: Copy varnish secret.
template:
src: secret.j2
dest: "{{ varnish_config_path }}/secret"
owner: root
group: root
mode: 0644
notify: restart varnish
- name: Ensure Varnish services are started and enabled on startup.
service:
name: "{{ item }}"
state: started
enabled: true
with_items: "{{ varnish_enabled_services | default([]) }}"
when: >
varnish_enabled_services and (ansible_os_family != 'Debian' or
(ansible_os_family != 'Debian' and ansible_distribution_release != "xenial"))
# See: https://github.com/ansible/ansible/issues/22303
- name: Ensure Varnish services are started and enabled on startup (Xenial specific)
service:
name: "{{ item }}"
state: started
enabled: true
use: "service"
with_items: "{{ varnish_enabled_services | default([]) }}"
when:
- varnish_enabled_services | length > 0
- (ansible_os_family == 'Debian' and ansible_distribution_release == "xenial")