diff --git a/CHANGELOG.md b/CHANGELOG.md index 704d9494..dfece0b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,10 +29,11 @@ The **patch** part changes is incremented if multiple releases happen the same m * redis: some values should be quoted * redis: variable to disable transparent hugepage (default: do nothing) * squid: whitelist deb.freexian.com +* varnish: systemd override depends on Varnish version instead of Debian version ### Fixed -* evolinux-user: Fix sudoers privilege for chck php\_fpm80 +* evolinux-user: Fix sudoers privilege for check php\_fpm80 ### Removed diff --git a/varnish/tasks/main.yml b/varnish/tasks/main.yml index 75268841..be518130 100644 --- a/varnish/tasks/main.yml +++ b/varnish/tasks/main.yml @@ -6,6 +6,17 @@ tags: - varnish +- name: Fetch packages + package_facts: + manager: auto + tags: + - varnish + +- set_fact: + varnish_package_facts: ansible_facts.packages['varnish'] | first + tags: + - varnish + - name: Remove default varnish configuration files file: path: "{{ item }}" @@ -19,7 +30,7 @@ - varnish - config -- name: Copy Custom Varnish ExecReload script (Debian <10) +- name: Copy Custom Varnish ExecReload script (Debian < 10) template: src: "reload-vcl.sh.j2" dest: "/etc/varnish/reload-vcl.sh" @@ -38,27 +49,41 @@ tags: - varnish -- name: Override Varnish systemd unit (Stretch and before) - template: - src: varnish.conf.jessie.j2 - dest: /etc/systemd/system/varnish.service.d/evolinux.conf - force: yes - when: ansible_distribution_major_version is version('10', '<') +- name: Rename legacy systemd override + command: mv /etc/systemd/system/varnish.service.d/evolinux.conf /etc/systemd/system/varnish.service.d/override.conf + args: + removes: /etc/systemd/system/varnish.service.d/evolinux.conf + creates: /etc/systemd/system/varnish.service.d/override.conf notify: - reload systemd - - restart varnish tags: - varnish - - config - - update-config -# TODO: verify if it's still necessary for Debian 11 -- name: Override Varnish systemd unit (Buster and later) +- name: Varnish systemd override template (Varnish 4 and 5) + set_fact: + varnish_systemd_override_template: override.conf.varnish4.j2 + when: + - varnish_package_facts['version'] is version('4', '>=') + - varnish_package_facts['version'] is version('6', '<') + +- name: Varnish systemd override template (Varnish 6) + set_fact: + varnish_systemd_override_template: override.conf.varnish6.j2 + when: + - varnish_package_facts['version'] is version('6', '>=') + - varnish_package_facts['version'] is version('7', '<') + +- name: Varnish systemd override template (Varnish 7 and later) + set_fact: + varnish_systemd_override_template: override.conf.varnish7.j2 + when: + - varnish_package_facts['version'] is version('7', '>=') + +- name: Override Varnish systemd unit template: - src: varnish.conf.buster.j2 - dest: /etc/systemd/system/varnish.service.d/evolinux.conf + src: "{{ varnish_systemd_override_template }}" + dest: /etc/systemd/system/varnish.service.d/override.conf force: yes - when: ansible_distribution_major_version is version('10', '>=') notify: - reload systemd - restart varnish diff --git a/varnish/templates/varnish.conf.jessie.j2 b/varnish/templates/override.conf.varnish4.j2 similarity index 100% rename from varnish/templates/varnish.conf.jessie.j2 rename to varnish/templates/override.conf.varnish4.j2 diff --git a/varnish/templates/varnish.conf.buster.j2 b/varnish/templates/override.conf.varnish6.j2 similarity index 100% rename from varnish/templates/varnish.conf.buster.j2 rename to varnish/templates/override.conf.varnish6.j2 diff --git a/varnish/templates/override.conf.varnish7.j2 b/varnish/templates/override.conf.varnish7.j2 new file mode 100644 index 00000000..14a0b315 --- /dev/null +++ b/varnish/templates/override.conf.varnish7.j2 @@ -0,0 +1,18 @@ +# {{ ansible_managed }} + +[Service] +ExecStart= +ExecStart=/usr/sbin/varnishd \ + -j {{ varnish_jail }} \ + {{ varnish_addresses | map('regex_replace', '^(.*)$', '-a \\1') | list | join(' ') }} \ + -P %t/%N/varnishd.pid \ + -T {{ varnish_management_address }} \ + -f {{ varnish_config_file }} \ + -S {{ varnish_secret_file }} \ + -s {{ varnish_storage }} \ + -p feature=+http2 \ + -p thread_pools={{ varnish_thread_pools }} \ + -p thread_pool_add_delay={{ varnish_thread_pool_add_delay }} \ + -p thread_pool_min={{ varnish_thread_pool_min }} \ + -p thread_pool_max={{ varnish_thread_pool_max }} \ + {{ varnish_additional_options }}