--- - name: Install Varnish apt: name: varnish state: present - name: Remove default varnish configuration files file: path: "{{ item }}" state: absent with_fileglob: "/etc/defaults/varnish*" - name: Copy Custom Varnish ExecReload script copy: src: "reload-vcl.sh" dest: "/etc/varnish/reload-vcl.sh" mode: "0700" owner: root group: root - name: Create a system config directory for systemd overrides file: path: /etc/systemd/system/varnish.service.d state: directory - name: Modify Varnish configuration files template: src: varnish.conf.j2 dest: /etc/systemd/system/varnish.service.d/varnish.conf force: yes backup: yes notify: reload systemctl - name: Patch logrotate conf replace: name: /etc/logrotate.d/varnish regexp: '^(\s+)(/usr/sbin/invoke-rc.d {{item}}.*)' replace: '\1systemctl -q is-active {{item}} && \2' with_items: - varnishlog - varnishncsa