ansible-roles/varnish-cache/tasks/main.yml

61 lines
2.1 KiB
YAML
Raw Normal View History

---
- 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
with_items: '{{ varnish_repo_requirements }}'
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
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
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
with_items: '{{ varnish_pkg_name }}'
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
with_items: '{{ varnish_sysctl_kernel_parameters }}'
2015-07-13 14:17:42 +02:00
when: varnish_set_sysctl_params
tags: [ 'varnish', 'varnishconf', 'sysctl' ]
- 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 )
tags: [ 'varnish', 'varnishconf' ]
- name: Ensure that the varnish service is started and enabled
service: name=varnish state=started enabled=yes
when: varnish_enabled
tags: varnish
- name: Ensure that the varnish service is stopped and disabled
service: name=varnish state=stopped enabled=no
when: not varnish_enabled
tags: varnish