Skip to content
This repository was archived by the owner on Feb 13, 2023. It is now read-only.

Commit fe68fbf

Browse files
committed
Merge branch '1455-varnish-5'
2 parents 1f3fd52 + fcb7633 commit fe68fbf

File tree

12 files changed

+99
-61
lines changed

12 files changed

+99
-61
lines changed

provisioning/requirements.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,4 @@
7878
- src: geerlingguy.solr
7979
version: 3.5.5
8080
- src: geerlingguy.varnish
81-
version: 1.9.0
81+
version: 2.0.0

provisioning/roles/geerlingguy.varnish/.travis.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,18 @@ env:
66
- distro: centos6
77
- distro: ubuntu1604
88
- distro: ubuntu1404
9+
# See: https://github.com/varnishcache/pkg-varnish-cache/issues/78
10+
# - distro: debian9
911
- distro: debian8
1012

13+
# Also test installing older versions.
14+
- distro: centos7
15+
playbook: test-41.yml
16+
varnish_version: "4.1"
17+
- distro: ubuntu1604
18+
varnish_version: "4.1"
19+
playbook: test-41.yml
20+
1121
script:
1222
# Configure test script so we can run extra tests after playbook is run.
1323
- export container_id=$(date +%s)
@@ -23,5 +33,10 @@ script:
2333
# Make sure Varnish is running.
2434
- 'docker exec --tty ${container_id} env TERM=xterm varnishd -V'
2535

36+
# Test the version of Varnish installed (default to the main.yml default).
37+
- |
38+
varnish_version="${varnish_version:-5.1}"
39+
docker exec --tty ${container_id} env TERM=xterm varnishd -V | grep "${varnish_version}"
40+
2641
notifications:
2742
webhooks: https://galaxy.ansible.com/api/v1/notifications/

provisioning/roles/geerlingguy.varnish/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ Available variables are listed below, along with default values (see `defaults/m
1616

1717
Varnish package name you want to install. See `apt-cache policy varnish` or `yum list varnish` for a listing of available candidates.
1818

19-
varnish_version: "4.1"
19+
varnish_version: "5.1"
2020

21-
Varnish version that should be installed. See `https://repo.varnish-cache.org/redhat/` for a listing of available versions (e.g. `3.0`, `4.0`, `4.1`). _Note: Ubuntu 16.04 "Xenial" defaults to 4.1 from the universe repoistory_
21+
Varnish version that should be installed. See the [Varnish Cache packagecloud.io repositories](https://packagecloud.io/varnishcache) for a listing of available versions. Some examples include: `5.1`, `5.0`, `4.1`, `4.0`, `3.0`, and `2.1`.
2222

2323
varnish_config_path: /etc/varnish
2424

provisioning/roles/geerlingguy.varnish/defaults/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
varnish_package_name: "varnish"
3-
varnish_version: "4.1"
3+
varnish_version: "5.1"
44

55
varnish_use_default_vcl: true
66
varnish_default_vcl_template_path: default.vcl.j2

provisioning/roles/geerlingguy.varnish/meta/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ galaxy_info:
66
description: Varnish for Linux.
77
company: "Midwestern Mac, LLC"
88
license: "license (BSD, MIT)"
9-
min_ansible_version: 2.1
9+
min_ansible_version: 2.2
1010
platforms:
1111
- name: EL
1212
versions:

provisioning/roles/geerlingguy.varnish/tasks/main.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,21 @@
22
- name: Include OS-specific variables.
33
include_vars: "{{ ansible_os_family }}.yml"
44

5+
- name: Set the packagecloud repository name based on the version.
6+
set_fact:
7+
varnish_packagecloud_repo: "varnish{{ varnish_version|replace('.', '') }}"
8+
59
- include: setup-RedHat.yml
610
when: ansible_os_family == 'RedHat'
711

812
- include: setup-Debian.yml
913
when: ansible_os_family == 'Debian'
1014

15+
- name: Ensure Varnish config path exists.
16+
file:
17+
path: "{{ varnish_config_path }}"
18+
state: directory
19+
1120
- name: Copy Varnish configuration (sysvinit).
1221
template:
1322
src: varnish.j2
@@ -36,19 +45,14 @@
3645
- name: Copy Varnish configuration (systemd).
3746
template:
3847
src: varnish.params.j2
39-
dest: /etc/varnish/varnish.params
48+
dest: "{{ varnish_config_path }}/varnish.params"
4049
owner: root
4150
group: root
4251
mode: 0644
4352
when: >
4453
(ansible_os_family == 'RedHat' and ansible_distribution_major_version|int >= 7) or
4554
(ansible_os_family == 'Debian' and ansible_distribution_release == "xenial")
4655
47-
- name: Ensure Varnish config path exists.
48-
file:
49-
path: "{{ varnish_config_path }}"
50-
state: directory
51-
5256
- name: Copy Varnish default VCL.
5357
template:
5458
src: "{{ varnish_default_vcl_template_path }}"

provisioning/roles/geerlingguy.varnish/tasks/setup-Debian.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,18 @@
33
apt:
44
name: apt-transport-https
55
state: installed
6-
when: ansible_distribution_release != "xenial"
76

8-
- name: Add Varnish apt key.
7+
- name: Add packagecloud.io Varnish apt key.
98
apt_key:
10-
url: https://repo.varnish-cache.org/GPG-key.txt
9+
url: https://packagecloud.io/varnishcache/{{ varnish_packagecloud_repo }}/gpgkey
1110
state: present
12-
when: ansible_distribution_release != "xenial"
1311

14-
- name: Add Varnish apt repository.
12+
- name: Add packagecloud.io Varnish apt repository.
1513
apt_repository:
16-
repo: "deb https://repo.varnish-cache.org/{{ ansible_distribution | lower }}/ {{ ansible_distribution_release }} varnish-{{ varnish_version }}"
14+
repo: "deb https://packagecloud.io/varnishcache/{{ varnish_packagecloud_repo }}/{{ ansible_distribution | lower }}/ {{ ansible_distribution_release }} main"
1715
state: present
18-
when: ansible_distribution_release != "xenial"
1916

20-
- name: Install Varnish.
17+
- name: Ensure Varnish is installed.
2118
apt:
2219
name: "{{ varnish_package_name }}"
2320
state: present

provisioning/roles/geerlingguy.varnish/tasks/setup-RedHat.yml

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,29 @@
22
- name: Ensure Varnish dependencies are installed.
33
yum: name={{ item }} state=present
44
with_items:
5-
- gcc
6-
- libedit-devel
7-
- initscripts
8-
- redhat-rpm-config
5+
- yum-utils
6+
- pygpgme
97

10-
- name: Add Varnish repository.
11-
yum:
12-
name: https://repo.varnish-cache.org/redhat/varnish-{{ varnish_version }}.el6.rpm
13-
state: present
14-
when: ansible_distribution_major_version|int < 7
15-
16-
- name: Set a string for the varnish repository identifier.
17-
set_fact:
18-
varnish_yum_repo: "varnish-{{ varnish_version }},epel"
8+
- name: Add Varnish packagecloud.io yum repo.
9+
yum_repository:
10+
name: varnishcache_{{ varnish_packagecloud_repo }}
11+
description: Varnish Cache packagecloud.io repository.
12+
baseurl: https://packagecloud.io/varnishcache/{{ varnish_packagecloud_repo }}/el/{{ ansible_distribution_major_version|int }}/$basearch
13+
repo_gpgcheck: no
14+
gpgcheck: no
15+
enabled: yes
16+
gpgkey: https://packagecloud.io/varnishcache/{{ varnish_packagecloud_repo }}/gpgkey
17+
sslverify: 1
18+
sslcacert: /etc/pki/tls/certs/ca-bundle.crt
19+
register: varnish_packagecloud_repo_addition
1920

20-
- name: Set repo fact appropriately.
21-
set_fact:
22-
varnish_yum_enablerepo: "{{ varnish_yum_repo if (ansible_distribution_major_version|int < 7) else 'epel' }}"
21+
- name: Refresh yum metadata cache if repo changed.
22+
command: >
23+
yum clean metadata
24+
warn=no
25+
when: varnish_packagecloud_repo_addition.changed
2326

24-
- name: Install Varnish.
27+
- name: Ensure Varnish is installed.
2528
yum:
2629
name: "{{ varnish_package_name }}"
2730
state: installed
28-
enablerepo: "{{ varnish_yum_enablerepo }}"
29-
disablerepo: "*"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
- name: Check what version of Varnish was installed.
3+
command: varnishd -V
4+
register: varnish_version
5+
changed_when: no
6+
7+
- name: Display the installed Varnish version.
8+
debug: var=varnish_version
9+
changed_when: no
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
- name: Update apt cache.
3+
apt: update_cache=yes cache_valid_time=600
4+
when: ansible_os_family == 'Debian'
5+
6+
- name: Ensure build dependencies are installed (RedHat 7+).
7+
yum: 'name="{{ item }}" state=present'
8+
with_items:
9+
- logrotate
10+
- systemd-sysv
11+
when: ansible_os_family == 'RedHat' and ansible_distribution_major_version >= '7'
12+
13+
- name: Ensure build dependencies are installed (RedHat < 7).
14+
yum: 'name="{{ item }}" state=present'
15+
with_items:
16+
- logrotate
17+
when: ansible_os_family == 'RedHat' and ansible_distribution_major_version < '7'

0 commit comments

Comments
 (0)