redis: add log2mail configuration for Redis if installed
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Jérémy Lecour 2020-03-02 21:19:50 +01:00
parent e510c44a4a
commit bc1a6f347a
6 changed files with 71 additions and 26 deletions

View file

@ -18,3 +18,8 @@
service:
name: nagios-nrpe-server
state: restarted
- name: restart log2mail
service:
name: log2mail
state: restarted

View file

@ -0,0 +1,20 @@
---
- name: log2mail config is present
blockinfile:
dest: /etc/log2mail/config/redis.conf
owner: log2mail
group: adm
mode: "0640"
create: yes
marker: "# {mark} ANSIBLE MANAGED RULES FOR DEFAULT INSTANCE"
content: |
file = {{ redis_log_dir }}/redis-server.log
pattern = "Cannot allocate memory"
mailto = {{ log2mail_alert_email or general_alert_email | mandatory }}
template = /etc/log2mail/mail
notify: restart log2mail
when: log2mail_config_dir.stat.exists
tags:
- redis
- log2mail

View file

@ -0,0 +1,20 @@
---
- name: log2mail config is present
blockinfile:
dest: /etc/log2mail/config/redis.conf
owner: log2mail
group: adm
mode: "0640"
create: yes
marker: "# {mark} ANSIBLE MANAGED RULES FOR INSTANCE {{ redis_instance_name }}"
content: |
file = {{ redis_log_dir }}/redis-server.log
pattern = "Cannot allocate memory"
mailto = {{ log2mail_alert_email or general_alert_email | mandatory }}
template = /etc/log2mail/mail
notify: restart log2mail
when: log2mail_config_dir.stat.exists
tags:
- redis
- log2mail

View file

@ -1,22 +0,0 @@
---
- name: Is log2mail present ?
stat:
path: /etc/log2mail/config
check_mode: no
register: log2mail_config_dir
tags:
- redis
- log2mail
- name: Copy log2mail config
template:
src: log2mail.j2
dest: /etc/log2mail/config/redis.conf
owner: log2mail
group: adm
mode: "0640"
when: log2mail_config_dir.stat.exists
tags:
- redis
- log2mail

View file

@ -81,6 +81,32 @@
- redis
- munin
- name: Is log2mail installed
stat:
path: /etc/log2mail/config
register: _log2mail_installed
tags:
- redis
- log2mail
- include: default-log2mail.yml
when:
- _log2mail_installed.stat.exists
- _log2mail_installed.stat.isdir
- redis_instance_name is undefined
tags:
- redis
- log2mail
- include: instance-log2mail.yml
when:
- _log2mail_installed.stat.exists
- _log2mail_installed.stat.isdir
- redis_instance_name is defined
tags:
- redis
- log2mail
- name: is NRPE present ?
stat:
path: /etc/nagios/nrpe.d/evolix.cfg

View file

@ -1,4 +0,0 @@
file = /var/log/redis/redis-server.log
pattern = "Can't save in background: fork: Cannot allocate memory"
mailto = {{ log2mail_alert_email or general_alert_email | mandatory }}
template = /etc/log2mail/mail