Skip to content

Commit

Permalink
Merge pull request #17 from dseira/master
Browse files Browse the repository at this point in the history
Fixed varnish 6 systemd packaging changes
  • Loading branch information
aboe76 authored Sep 30, 2019
2 parents 6115f8c + 112cc49 commit b2bf3b9
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,29 @@ WantedBy=multi-user.target
```

So you can edit and have the file managed by salt.


* Varnish versions from 6 (including it) have change the systemd unit service; are OS agnostic (see [packaging changes](https://varnish-cache.org/docs/trunk/whats-new/upgrading-6.0.html#packaging-changes)).

For Debian Family OSes can use the previous trick (changing the unit service).

For RedHat Family OSes there is a new variable `version` that setup an `override.conf` for the default varnish systemd service that allow to use the `varnish.params` file. For example, to install varnish 6 LTS:

```
varnish:
ng:
lookup:
repo: 'varnish60lts'
version: '6'
install_from_repo: True
enabled: True
config_source_path: salt://hostname/varnish.params.jinja
vcl:
files:
default:
path: /etc/varnish/default.vcl
source_path: salt://hostname/default.vcl.jinja
```

This change is compatible with other varnish versions (there is no error if not set).

40 changes: 40 additions & 0 deletions varnish/ng/service.sls
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,46 @@

{% from "varnish/ng/map.jinja" import varnish_settings with context %}
{% set initsystem = salt['grains.get']('init') %}
{% set version = varnish_settings.version | default('0') %}
{% if initsystem == 'systemd' and version >= '6' %}
{% if grains['os_family'] == 'RedHat' %}
varnish.systemd_varnish_params:
file.managed:
- name: /etc/systemd/system/varnish.service.d/override.conf
- makedirs: True
- user: root
- group: root
- mode: '644'
- contents: |
[Service]
EnvironmentFile=/etc/varnish/varnish.params
ExecStart=
ExecStart=/usr/sbin/varnishd \
-P /var/run/varnish.pid \
-f ${VARNISH_VCL_CONF} \
-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \
-T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \
-S ${VARNISH_SECRET_FILE} \
-s ${VARNISH_STORAGE} \
$DAEMON_OPTS
module.run:
- name: service.systemctl_reload
- onchanges:
- file: /etc/systemd/system/varnish.service.d/override.conf
{% endif %}
varnish.varnish_secret:
cmd.run:
- name: uuidgen > /etc/varnish/secret
- unless: test -f /etc/varnish/secret
{% endif %}
varnish.service:
{% if ( 'enabled' in varnish_settings and varnish_settings.enabled ) or ('enabled' not in varnish_settings ) %}
service.running:
Expand Down

0 comments on commit b2bf3b9

Please sign in to comment.