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

Commit

Permalink
Merge branch '1455-varnish-5'
Browse files Browse the repository at this point in the history
  • Loading branch information
geerlingguy committed Jun 28, 2017
2 parents 1f3fd52 + fcb7633 commit fe68fbf
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 61 deletions.
2 changes: 1 addition & 1 deletion provisioning/requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@
- src: geerlingguy.solr
version: 3.5.5
- src: geerlingguy.varnish
version: 1.9.0
version: 2.0.0
15 changes: 15 additions & 0 deletions provisioning/roles/geerlingguy.varnish/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,18 @@ env:
- distro: centos6
- distro: ubuntu1604
- distro: ubuntu1404
# See: https://github.com/varnishcache/pkg-varnish-cache/issues/78
# - distro: debian9
- distro: debian8

# Also test installing older versions.
- distro: centos7
playbook: test-41.yml
varnish_version: "4.1"
- distro: ubuntu1604
varnish_version: "4.1"
playbook: test-41.yml

script:
# Configure test script so we can run extra tests after playbook is run.
- export container_id=$(date +%s)
Expand All @@ -23,5 +33,10 @@ script:
# Make sure Varnish is running.
- 'docker exec --tty ${container_id} env TERM=xterm varnishd -V'

# Test the version of Varnish installed (default to the main.yml default).
- |
varnish_version="${varnish_version:-5.1}"
docker exec --tty ${container_id} env TERM=xterm varnishd -V | grep "${varnish_version}"
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
4 changes: 2 additions & 2 deletions provisioning/roles/geerlingguy.varnish/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ Available variables are listed below, along with default values (see `defaults/m

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

varnish_version: "4.1"
varnish_version: "5.1"

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_
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`.

varnish_config_path: /etc/varnish

Expand Down
2 changes: 1 addition & 1 deletion provisioning/roles/geerlingguy.varnish/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
varnish_package_name: "varnish"
varnish_version: "4.1"
varnish_version: "5.1"

varnish_use_default_vcl: true
varnish_default_vcl_template_path: default.vcl.j2
Expand Down
2 changes: 1 addition & 1 deletion provisioning/roles/geerlingguy.varnish/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ galaxy_info:
description: Varnish for Linux.
company: "Midwestern Mac, LLC"
license: "license (BSD, MIT)"
min_ansible_version: 2.1
min_ansible_version: 2.2
platforms:
- name: EL
versions:
Expand Down
16 changes: 10 additions & 6 deletions provisioning/roles/geerlingguy.varnish/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,21 @@
- 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: setup-RedHat.yml
when: ansible_os_family == 'RedHat'

- include: setup-Debian.yml
when: ansible_os_family == 'Debian'

- name: Ensure Varnish config path exists.
file:
path: "{{ varnish_config_path }}"
state: directory

- name: Copy Varnish configuration (sysvinit).
template:
src: varnish.j2
Expand Down Expand Up @@ -36,19 +45,14 @@
- name: Copy Varnish configuration (systemd).
template:
src: varnish.params.j2
dest: /etc/varnish/varnish.params
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: Ensure Varnish config path exists.
file:
path: "{{ varnish_config_path }}"
state: directory

- name: Copy Varnish default VCL.
template:
src: "{{ varnish_default_vcl_template_path }}"
Expand Down
13 changes: 5 additions & 8 deletions provisioning/roles/geerlingguy.varnish/tasks/setup-Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,18 @@
apt:
name: apt-transport-https
state: installed
when: ansible_distribution_release != "xenial"

- name: Add Varnish apt key.
- name: Add packagecloud.io Varnish apt key.
apt_key:
url: https://repo.varnish-cache.org/GPG-key.txt
url: https://packagecloud.io/varnishcache/{{ varnish_packagecloud_repo }}/gpgkey
state: present
when: ansible_distribution_release != "xenial"

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

- name: Install Varnish.
- name: Ensure Varnish is installed.
apt:
name: "{{ varnish_package_name }}"
state: present
39 changes: 20 additions & 19 deletions provisioning/roles/geerlingguy.varnish/tasks/setup-RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,29 @@
- name: Ensure Varnish dependencies are installed.
yum: name={{ item }} state=present
with_items:
- gcc
- libedit-devel
- initscripts
- redhat-rpm-config
- yum-utils
- pygpgme

- name: Add Varnish repository.
yum:
name: https://repo.varnish-cache.org/redhat/varnish-{{ varnish_version }}.el6.rpm
state: present
when: ansible_distribution_major_version|int < 7

- name: Set a string for the varnish repository identifier.
set_fact:
varnish_yum_repo: "varnish-{{ varnish_version }},epel"
- name: Add Varnish packagecloud.io yum repo.
yum_repository:
name: varnishcache_{{ varnish_packagecloud_repo }}
description: Varnish Cache packagecloud.io repository.
baseurl: https://packagecloud.io/varnishcache/{{ varnish_packagecloud_repo }}/el/{{ ansible_distribution_major_version|int }}/$basearch
repo_gpgcheck: no
gpgcheck: no
enabled: yes
gpgkey: https://packagecloud.io/varnishcache/{{ varnish_packagecloud_repo }}/gpgkey
sslverify: 1
sslcacert: /etc/pki/tls/certs/ca-bundle.crt
register: varnish_packagecloud_repo_addition

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

- name: Install Varnish.
- name: Ensure Varnish is installed.
yum:
name: "{{ varnish_package_name }}"
state: installed
enablerepo: "{{ varnish_yum_enablerepo }}"
disablerepo: "*"
9 changes: 9 additions & 0 deletions provisioning/roles/geerlingguy.varnish/tests/debug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
- name: Check what version of Varnish was installed.
command: varnishd -V
register: varnish_version
changed_when: no

- name: Display the installed Varnish version.
debug: var=varnish_version
changed_when: no
17 changes: 17 additions & 0 deletions provisioning/roles/geerlingguy.varnish/tests/setup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
- name: Update apt cache.
apt: update_cache=yes cache_valid_time=600
when: ansible_os_family == 'Debian'

- name: Ensure build dependencies are installed (RedHat 7+).
yum: 'name="{{ item }}" state=present'
with_items:
- logrotate
- systemd-sysv
when: ansible_os_family == 'RedHat' and ansible_distribution_major_version >= '7'

- name: Ensure build dependencies are installed (RedHat < 7).
yum: 'name="{{ item }}" state=present'
with_items:
- logrotate
when: ansible_os_family == 'RedHat' and ansible_distribution_major_version < '7'
14 changes: 14 additions & 0 deletions provisioning/roles/geerlingguy.varnish/tests/test-41.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
- hosts: all

vars:
varnish_version: "4.1"

pre_tasks:
- include: setup.yml

roles:
- role_under_test

post_tasks:
- include: debug.yml
27 changes: 4 additions & 23 deletions provisioning/roles/geerlingguy.varnish/tests/test.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,10 @@
- hosts: all

pre_tasks:
- name: Update apt cache.
apt: update_cache=yes cache_valid_time=600
when: ansible_os_family == 'Debian'

- name: Ensure build dependencies are installed (RedHat 7+).
yum: 'name="{{ item }}" state=present'
with_items:
- logrotate
- redhat-rpm-config
- systemd-sysv
- initscripts
when: ansible_os_family == 'RedHat' and ansible_distribution_major_version >= '7'

- name: Ensure build dependencies are installed (RedHat < 7).
yum: 'name="{{ item }}" state=present'
with_items:
- logrotate
when: ansible_os_family == 'RedHat' and ansible_distribution_major_version < '7'

- name: Force working version of Varnish on Ubuntu 14.04.
set_fact:
varnish_version: "4.0"
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '14.04'
- include: setup.yml

roles:
- role_under_test

post_tasks:
- include: debug.yml

0 comments on commit fe68fbf

Please sign in to comment.