Move services of mailserver's monitoring to a dedicated role

This commit is contained in:
Tunui Franken 2025-01-26 23:21:12 +01:00
parent 8ba59814bb
commit 6f78bac499
6 changed files with 63 additions and 21 deletions

View file

@ -26,5 +26,7 @@
tags: spf, report tags: spf, report
- role: mailserver_dmarc - role: mailserver_dmarc
tags: dmarc, report tags: dmarc, report
- role: mailserver_monitoring
tags: monitoring, icinga, icinga2
- role: mailserver_dns_report - role: mailserver_dns_report
tags: report tags: report

View file

@ -52,7 +52,26 @@
group: nagios group: nagios
mode: 0644 mode: 0644
with_fileglob: with_fileglob:
- "{{ role_path }}/templates/zones.d/master/*" - "{{ role_path }}/templates/zones.d/master/*.conf.j2"
notify: Reload icinga2 service
- name: Create services directory
become: true
ansible.builtin.file:
path: /etc/icinga2/zones.d/master/services
state: directory
owner: nagios
group: nagios
mode: 0750
- name: Copy common services
become: true
ansible.builtin.template:
src: zones.d/master/services/common.conf.j2
dest: /etc/icinga2/zones.d/master/services/common.conf
owner: nagios
group: nagios
mode: 0644
notify: Reload icinga2 service notify: Reload icinga2 service
- name: Install bsd-mailx for sending mail notifications - name: Install bsd-mailx for sending mail notifications

View file

@ -87,23 +87,3 @@ apply Service "mailq" {
vars.mailq_warning = 10 vars.mailq_warning = 10
vars.mailq_critical = 20 vars.mailq_critical = 20
} }
apply Service "smtp" {
import "generic-service"
check_command = "smtp"
assign where host.name == "{{ relayhost }}"
}
apply Service "submission" {
import "generic-service"
check_command = "smtp"
assign where host.name == "{{ relayhost }}"
vars.smtp_port = 587
vars.smtp_starttls = true
}
apply Service "imaps" {
import "generic-service"
check_command = "simap"
assign where host.name == "{{ relayhost }}"
}

View file

@ -0,0 +1,8 @@
---
- name: Reload icinga2 service
delegate_to: "{{ icinga2_master }}"
become: true
ansible.builtin.systemd:
name: icinga2
state: reloaded

View file

@ -0,0 +1,12 @@
---
- name: Copy mailserver services on icinga2 Master
delegate_to: "{{ icinga2_master }}"
become: true
ansible.builtin.template:
src: zones.d/master/services/mailserver.conf.j2
dest: /etc/icinga2/zones.d/master/services/mailserver.conf
owner: nagios
group: nagios
mode: 0644
notify: Reload icinga2 service

View file

@ -0,0 +1,21 @@
# {{ ansible_managed }}
apply Service "smtp" {
import "generic-service"
check_command = "smtp"
assign where host.name == "{{ inventory_hostname }}"
}
apply Service "submission" {
import "generic-service"
check_command = "smtp"
assign where host.name == "{{ inventory_hostname }}"
vars.smtp_port = 587
vars.smtp_starttls = true
}
apply Service "imaps" {
import "generic-service"
check_command = "simap"
assign where host.name == "{{ inventory_hostname }}"
}