--- - name: Deploy log2mail systemd unit copy: src: log2mail.service dest: /etc/systemd/system/log2mail.service mode: "0644" - name: Remove log2mail sysvinit service file: path: /etc/init.d/log2mail state: absent - name: Enable and start log2mail service systemd: name: log2mail daemon-reload: yes state: started enabled: yes when: not ansible_check_mode - name: log2mail config is present blockinfile: dest: /etc/log2mail/config/default owner: log2mail group: adm mode: "0640" marker: "# {mark} ANSIBLE MANAGED RULES FOR DEFAULT INSTANCE" block: | file = /var/log/syslog pattern = "Out of memory: Kill" mailto = {{ log2mail_alert_email or general_alert_email | mandatory }} template = /etc/log2mail/mail notify: restart log2mail tags: - log2mail when: not ansible_check_mode