2015-05-28 11:32:57 +02:00
|
|
|
---
|
|
|
|
- name: Install the required packages needed by the external varnish repo
|
2017-10-28 13:25:59 +02:00
|
|
|
apt: pkg={{ item }} state=present cache_valid_time=1800 update_cache=yes
|
2016-08-25 14:07:23 +02:00
|
|
|
with_items: '{{ varnish_repo_requirements }}'
|
2015-05-28 11:32:57 +02:00
|
|
|
when: varnish_repo
|
|
|
|
tags: varnish
|
|
|
|
|
|
|
|
- name: Get the varnish repo key
|
2017-10-28 13:25:59 +02:00
|
|
|
apt_key: url=https://packagecloud.io/varnishcache/varnish{{ varnish_compact_ver }}/gpgkey state=present
|
2015-05-28 11:32:57 +02:00
|
|
|
when: varnish_repo
|
|
|
|
register: varnish_repo_list
|
|
|
|
tags: varnish
|
|
|
|
|
|
|
|
- name: Define the varnish repository
|
2017-10-28 13:25:59 +02:00
|
|
|
apt_repository: repo='{{ varnish_repo_url }}' state=present update_cache=yes
|
2015-05-28 11:32:57 +02:00
|
|
|
when: varnish_repo
|
|
|
|
register: varnish_repo_list
|
|
|
|
tags: varnish
|
|
|
|
|
|
|
|
- name: Install the varnish package
|
2017-10-28 13:25:59 +02:00
|
|
|
apt: pkg={{ item }} state={{ varnish_pkg_state }} cache_valid_time=1800 update_cache=yes
|
2016-08-25 14:07:23 +02:00
|
|
|
with_items: '{{ varnish_pkg_name }}'
|
2015-05-28 11:32:57 +02:00
|
|
|
tags: varnish
|
|
|
|
|
2015-07-13 14:17:42 +02:00
|
|
|
- name: Configure some kernel parameters via sysctl
|
|
|
|
sysctl: name={{ item.name }} value={{ item.value }} sysctl_file=/etc/sysctl.d/{{ varnish_sysctl_file }} reload=yes state=present
|
2016-08-25 14:07:23 +02:00
|
|
|
with_items: '{{ varnish_sysctl_kernel_parameters }}'
|
2015-07-13 14:17:42 +02:00
|
|
|
when: varnish_set_sysctl_params
|
|
|
|
tags: [ 'varnish', 'varnishconf', 'sysctl' ]
|
|
|
|
|
2015-05-31 19:35:38 +02:00
|
|
|
- name: Install the varnish parameters file. The config file needs to be set by a local task
|
|
|
|
template: src={{ item }}.j2 dest=/etc/default/varnish owner=root group=root mode=0444
|
|
|
|
with_items:
|
|
|
|
- varnish.params
|
2015-07-13 14:17:42 +02:00
|
|
|
notify: Restart varnish
|
|
|
|
tags: [ 'varnish', 'varnishconf' ]
|
|
|
|
|
|
|
|
- name: Install the varnish systemd unit in debian 8
|
|
|
|
template: src={{ item }}.systemd.j2 dest=/etc/systemd/system/{{ item }} owner=root group=root mode=0444
|
|
|
|
with_items:
|
|
|
|
- varnish.service
|
|
|
|
notify: Restart varnish
|
|
|
|
when: is_debian8
|
|
|
|
register: install_varnish_unit
|
|
|
|
tags: [ 'varnish', 'varnishconf' ]
|
|
|
|
|
|
|
|
- name: Reload the systemd unit when changed
|
|
|
|
command: systemctl daemon-reload
|
|
|
|
when: ( install_varnish_unit | changed )
|
2015-05-31 19:35:38 +02:00
|
|
|
tags: [ 'varnish', 'varnishconf' ]
|
2015-05-28 11:32:57 +02:00
|
|
|
|
2015-05-31 19:35:38 +02:00
|
|
|
- name: Ensure that the varnish service is started and enabled
|
|
|
|
service: name=varnish state=started enabled=yes
|
|
|
|
when: varnish_enabled
|
|
|
|
tags: varnish
|
2015-05-28 11:32:57 +02:00
|
|
|
|
2015-05-31 19:35:38 +02:00
|
|
|
- name: Ensure that the varnish service is stopped and disabled
|
|
|
|
service: name=varnish state=stopped enabled=no
|
|
|
|
when: not varnish_enabled
|
|
|
|
tags: varnish
|