--- - 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 copy: src: varnish.conf dest: /etc/systemd/system/varnish.service.d/ notify: reload systemctl - name: Patch logrotate conf replace: name: /etc/logrotate.d/varnish regexp: "/usr/sbin/invoke-rc.d {{item}} reload.*$" replace: "systemctl -q is-active {{item}} && /usr/sbin/invoke-rc.d {{item}} reload > /dev/null ||true" with_items: - varnishlog - varnishncsa