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
|
- name: Add Munin plugins for PostgreSQL
|
||||||
file:
|
file:
|
||||||
state: link
|
state: link
|
||||||
|
@ -11,6 +21,7 @@
|
||||||
- postgres_users
|
- postgres_users
|
||||||
- postgres_xlog
|
- postgres_xlog
|
||||||
notify: restart munin-node
|
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)
|
- name: Add Munin plugins for PostgreSQL (for specific databases)
|
||||||
file:
|
file:
|
||||||
|
@ -21,3 +32,4 @@
|
||||||
- ['postgres_cache_', 'postgres_connections_', 'postgres_locks_', 'postgres_querylength_', 'postgres_scans_', 'postgres_size_', 'postgres_transactions_', 'postgres_tuples_']
|
- ['postgres_cache_', 'postgres_connections_', 'postgres_locks_', 'postgres_querylength_', 'postgres_scans_', 'postgres_size_', 'postgres_transactions_', 'postgres_tuples_']
|
||||||
- '{{postgresql_databases}}'
|
- '{{postgresql_databases}}'
|
||||||
notify: restart munin-node
|
notify: restart munin-node
|
||||||
|
when: etc_munin_plugins.stat.exists and usr_share_munin_plugins.stat.exists
|
||||||
|
|
|
@ -14,19 +14,27 @@
|
||||||
name: python-psycopg2
|
name: python-psycopg2
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Create nrpe user
|
- name: Is nrpe present ?
|
||||||
become: yes
|
stat:
|
||||||
become_user: postgres
|
path: /etc/nagios/nrpe.d/evolix.cfg
|
||||||
postgresql_user:
|
register: nrpe_evolix_config
|
||||||
name: nrpe
|
|
||||||
password: '{{ postgresql_nrpe_password.stdout }}'
|
|
||||||
no_password_changes: yes
|
|
||||||
register: postgresql_create_nrpe_user
|
|
||||||
|
|
||||||
- name: Add NRPE check
|
- block:
|
||||||
lineinfile:
|
- name: Create nrpe user
|
||||||
name: /etc/nagios/nrpe.d/evolix.cfg
|
become: yes
|
||||||
regexp: '^command\[check_pgsql\]='
|
become_user: postgres
|
||||||
line: 'command[check_pgsql]=/usr/lib/nagios/plugins/check_pgsql -H localhost -l nrpe -p "{{postgresql_nrpe_password.stdout}}"'
|
postgresql_user:
|
||||||
when: postgresql_create_nrpe_user.changed
|
name: nrpe
|
||||||
notify: restart nagios-nrpe-server
|
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