2016-12-22 16:12:34 +01:00
|
|
|
---
|
2017-01-12 17:36:59 +01:00
|
|
|
- name: apg package is installed
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.apt:
|
2017-01-12 17:36:59 +01:00
|
|
|
name: apg
|
|
|
|
state: present
|
|
|
|
|
2016-12-22 16:12:34 +01:00
|
|
|
- name: Generate random password for nrpe user
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.command:
|
|
|
|
cmd: apg -n1 -m 12 -M SCNL
|
2016-12-22 18:18:55 +01:00
|
|
|
register: postgresql_nrpe_password
|
2016-12-22 16:12:34 +01:00
|
|
|
changed_when: False
|
|
|
|
|
2021-05-02 01:14:06 +02:00
|
|
|
- name: python-psycopg2 is installed (Ansible dependency)
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.apt:
|
2017-01-12 18:10:05 +01:00
|
|
|
name: python-psycopg2
|
|
|
|
state: present
|
2021-09-30 17:05:10 +02:00
|
|
|
when: ansible_python_version is version('3', '<')
|
2021-05-02 01:14:06 +02:00
|
|
|
|
|
|
|
- name: python3-psycopg2 is installed (Ansible dependency)
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.apt:
|
2021-05-02 01:14:06 +02:00
|
|
|
name: python3-psycopg2
|
|
|
|
state: present
|
2021-09-30 17:05:10 +02:00
|
|
|
when: ansible_python_version is version('3', '>=')
|
2017-01-12 18:10:05 +01:00
|
|
|
|
2017-05-20 00:23:58 +02:00
|
|
|
- name: Is nrpe present ?
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.stat:
|
2017-05-20 00:23:58 +02:00
|
|
|
path: /etc/nagios/nrpe.d/evolix.cfg
|
|
|
|
register: nrpe_evolix_config
|
2016-12-22 16:12:34 +01:00
|
|
|
|
2017-05-20 00:23:58 +02:00
|
|
|
- block:
|
|
|
|
- name: Create nrpe user
|
2023-07-03 14:21:22 +02:00
|
|
|
become: true
|
2017-05-20 00:23:58 +02:00
|
|
|
become_user: postgres
|
2023-03-20 23:33:19 +01:00
|
|
|
community.postgresql.postgresql_user:
|
2017-05-20 00:23:58 +02:00
|
|
|
name: nrpe
|
|
|
|
password: '{{ postgresql_nrpe_password.stdout }}'
|
2019-11-14 11:39:02 +01:00
|
|
|
encrypted: yes
|
2017-05-20 00:23:58 +02:00
|
|
|
no_password_changes: yes
|
|
|
|
register: postgresql_create_nrpe_user
|
|
|
|
when: nrpe_evolix_config.stat.exists
|
|
|
|
|
|
|
|
- name: Add NRPE check
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.lineinfile:
|
2017-05-20 00:23:58 +02:00
|
|
|
name: /etc/nagios/nrpe.d/evolix.cfg
|
|
|
|
regexp: '^command\[check_pgsql\]='
|
2022-12-28 09:03:37 +01:00
|
|
|
line: 'command[check_pgsql]=/usr/lib/nagios/plugins/check_pgsql -H localhost -l nrpe -p "{{ postgresql_nrpe_password.stdout }}"'
|
2017-05-20 00:23:58 +02:00
|
|
|
notify: restart nagios-nrpe-server
|
2021-05-09 23:06:42 +02:00
|
|
|
when: postgresql_create_nrpe_user is changed
|
2017-05-20 00:23:58 +02:00
|
|
|
when: nrpe_evolix_config.stat.exists
|