ansible-roles/evolinux-base/tasks/log2mail.yml
David Prevot fc692cf65b
All checks were successful
gitea/ansible-roles/pipeline/head This commit looks good
Allow more --check runs
Use “when: not ansible_check_mode” or “when <file>.stat.exists or not
ansible_check_mode” in order to provide a meaningful diff if possible.

This is an improvement from the previously reverted commit
1728eaee68.
2022-12-21 18:05:41 +01:00

43 lines
1 KiB
YAML

---
- 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: Is log2mail/config/default present?
stat:
path: /etc/log2mail/config/default
register: _log2mail_config_default
- 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: _log2mail_config_default.stat.exists or not ansible_check_mode