ansible-roles/postgresql/tasks/nrpe.yml
Jérémy Lecour a6bac1f20b
All checks were successful
Ansible Lint |Total|New|Outstanding|Fixed|Trend |:-:|:-:|:-:|:-:|:-: |2593|3|2590|23|:+1: Reference build: <a href="https://jenkins.evolix.org/job/gitea/job/ansible-roles/job/unstable/280//ansiblelint">Evolix » ansible-roles » unstable #280</a>
gitea/ansible-roles/pipeline/head This commit looks good
change syntax "become: [yes,no]" → "become: [true,false]"
2023-07-03 14:21:22 +02:00

50 lines
1.4 KiB
YAML

---
- name: apg package is installed
ansible.builtin.apt:
name: apg
state: present
- name: Generate random password for nrpe user
ansible.builtin.command:
cmd: apg -n1 -m 12 -M SCNL
register: postgresql_nrpe_password
changed_when: False
- name: python-psycopg2 is installed (Ansible dependency)
ansible.builtin.apt:
name: python-psycopg2
state: present
when: ansible_python_version is version('3', '<')
- name: python3-psycopg2 is installed (Ansible dependency)
ansible.builtin.apt:
name: python3-psycopg2
state: present
when: ansible_python_version is version('3', '>=')
- name: Is nrpe present ?
ansible.builtin.stat:
path: /etc/nagios/nrpe.d/evolix.cfg
register: nrpe_evolix_config
- block:
- name: Create nrpe user
become: true
become_user: postgres
community.postgresql.postgresql_user:
name: nrpe
password: '{{ postgresql_nrpe_password.stdout }}'
encrypted: yes
no_password_changes: yes
register: postgresql_create_nrpe_user
when: nrpe_evolix_config.stat.exists
- name: Add NRPE check
ansible.builtin.lineinfile:
name: /etc/nagios/nrpe.d/evolix.cfg
regexp: '^command\[check_pgsql\]='
line: 'command[check_pgsql]=/usr/lib/nagios/plugins/check_pgsql -H localhost -l nrpe -p "{{ postgresql_nrpe_password.stdout }}"'
notify: restart nagios-nrpe-server
when: postgresql_create_nrpe_user is changed
when: nrpe_evolix_config.stat.exists