forked from evolix/ansible-roles
postgresql: add munin/nrpe artefacts only if needed
This commit is contained in:
parent
283953a69f
commit
3d9d816f83
|
@ -1,4 +1,14 @@
|
|||
---
|
||||
- name: Are Munin plugins present in /etc ?
|
||||
stat:
|
||||
path: /etc/munin/plugins
|
||||
register: etc_munin_plugins
|
||||
|
||||
- name: Are Munin plugins present in /usr/share ?
|
||||
stat:
|
||||
path: /usr/share/munin/plugins
|
||||
register: usr_share_munin_plugins
|
||||
|
||||
- name: Add Munin plugins for PostgreSQL
|
||||
file:
|
||||
state: link
|
||||
|
@ -11,6 +21,7 @@
|
|||
- postgres_users
|
||||
- postgres_xlog
|
||||
notify: restart munin-node
|
||||
when: etc_munin_plugins.stat.exists and usr_share_munin_plugins.stat.exists
|
||||
|
||||
- name: Add Munin plugins for PostgreSQL (for specific databases)
|
||||
file:
|
||||
|
@ -21,3 +32,4 @@
|
|||
- ['postgres_cache_', 'postgres_connections_', 'postgres_locks_', 'postgres_querylength_', 'postgres_scans_', 'postgres_size_', 'postgres_transactions_', 'postgres_tuples_']
|
||||
- '{{postgresql_databases}}'
|
||||
notify: restart munin-node
|
||||
when: etc_munin_plugins.stat.exists and usr_share_munin_plugins.stat.exists
|
||||
|
|
|
@ -14,19 +14,27 @@
|
|||
name: python-psycopg2
|
||||
state: present
|
||||
|
||||
- name: Create nrpe user
|
||||
become: yes
|
||||
become_user: postgres
|
||||
postgresql_user:
|
||||
name: nrpe
|
||||
password: '{{ postgresql_nrpe_password.stdout }}'
|
||||
no_password_changes: yes
|
||||
register: postgresql_create_nrpe_user
|
||||
- name: Is nrpe present ?
|
||||
stat:
|
||||
path: /etc/nagios/nrpe.d/evolix.cfg
|
||||
register: nrpe_evolix_config
|
||||
|
||||
- name: Add NRPE check
|
||||
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}}"'
|
||||
when: postgresql_create_nrpe_user.changed
|
||||
notify: restart nagios-nrpe-server
|
||||
- block:
|
||||
- name: Create nrpe user
|
||||
become: yes
|
||||
become_user: postgres
|
||||
postgresql_user:
|
||||
name: nrpe
|
||||
password: '{{ postgresql_nrpe_password.stdout }}'
|
||||
no_password_changes: yes
|
||||
register: postgresql_create_nrpe_user
|
||||
when: nrpe_evolix_config.stat.exists
|
||||
|
||||
- name: Add NRPE check
|
||||
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.changed
|
||||
when: nrpe_evolix_config.stat.exists
|
||||
|
|
Loading…
Reference in a new issue