Add check for mailserver-pgsql

This commit is contained in:
Tunui Franken 2025-02-01 23:49:12 +01:00
parent f026e3a166
commit 70382d628f
4 changed files with 46 additions and 0 deletions

View file

@ -55,6 +55,27 @@
- "{{ role_path }}/templates/zones.d/master/*.conf.j2" - "{{ role_path }}/templates/zones.d/master/*.conf.j2"
notify: Reload icinga2 service notify: Reload icinga2 service
- name: Create global-templates zone directory
become: true
ansible.builtin.file:
path: /etc/icinga2/zones.d/global-templates
state: directory
owner: nagios
group: nagios
mode: 0750
- name: Copy files under global-templates zone directory
become: true
ansible.builtin.template:
src: "{{ item }}"
dest: "/etc/icinga2/zones.d/global-templates/{{ item | basename | replace('.j2', '') }}"
owner: nagios
group: nagios
mode: 0644
with_fileglob:
- "{{ role_path }}/templates/zones.d/global-templates/*.conf.j2"
notify: Reload icinga2 service
- name: Create services directory - name: Create services directory
become: true become: true
ansible.builtin.file: ansible.builtin.file:

View file

@ -0,0 +1,6 @@
# {{ ansible_managed }}
object CheckCommand "sudo_pgsql" {
import "pgsql"
command = [ "sudo", "-u", "postgres" ] + command
}

View file

@ -10,3 +10,13 @@
group: nagios group: nagios
mode: 0644 mode: 0644
notify: Reload icinga2 service notify: Reload icinga2 service
- name: Copy sudoers file for nagios as postgres
become: true
ansible.builtin.copy:
content: 'nagios ALL=(postgres) NOPASSWD:/usr/lib/nagios/plugins/check_pgsql'
dest: /etc/sudoers.d/nagios-pgsql
owner: root
group: root
mode: 0440
validate: 'visudo -cf %s'

View file

@ -26,3 +26,12 @@ apply Service "imaps" {
check_command = "simap" check_command = "simap"
assign where host.name == "{{ inventory_hostname }}" assign where host.name == "{{ inventory_hostname }}"
} }
apply Service "mailserver-pgsql" {
import "generic-service"
check_command = "sudo_pgsql"
command_endpoint = host.name
assign where host.name == "{{ inventory_hostname }}"
vars.pgsql_hostname = "/run/postgresql"
vars.pgsql_database = "mailserver"
}