2016-09-29 16:33:48 +02:00
|
|
|
---
|
|
|
|
|
|
|
|
- name: is NRPE present ?
|
|
|
|
stat:
|
|
|
|
path: /etc/nagios/nrpe.d/evolix.cfg
|
2017-03-24 14:15:09 +01:00
|
|
|
check_mode: no
|
2016-09-29 16:33:48 +02:00
|
|
|
register: nrpe_evolix_config
|
|
|
|
tags:
|
|
|
|
- mysql
|
|
|
|
- nrpe
|
|
|
|
|
2017-04-05 12:10:19 +02:00
|
|
|
- name: NRPE user exists for MySQL ?
|
|
|
|
stat:
|
|
|
|
path: ~nagios/.my.cnf
|
|
|
|
check_mode: no
|
|
|
|
register: nrpe_my_cnf
|
|
|
|
tags:
|
|
|
|
- mysql
|
|
|
|
- nrpe
|
|
|
|
|
2016-09-29 16:33:48 +02:00
|
|
|
- block:
|
|
|
|
- name: Create a password for NRPE
|
2017-08-12 18:11:13 +02:00
|
|
|
command: "apg -n 1 -m 16 -M lcN"
|
2016-09-29 16:33:48 +02:00
|
|
|
register: mysql_nrpe_password
|
2017-11-26 18:58:39 +01:00
|
|
|
check_mode: no
|
2016-12-16 01:27:12 +01:00
|
|
|
changed_when: False
|
2016-09-29 16:33:48 +02:00
|
|
|
|
|
|
|
- name: Create nrpe user
|
|
|
|
mysql_user:
|
|
|
|
name: nrpe
|
|
|
|
password: '{{ mysql_nrpe_password.stdout }}'
|
2017-09-20 11:33:27 +02:00
|
|
|
priv: "*.*:REPLICATION CLIENT"
|
2016-09-29 16:33:48 +02:00
|
|
|
config_file: /root/.my.cnf
|
2017-04-05 12:10:19 +02:00
|
|
|
update_password: always
|
2016-09-29 16:33:48 +02:00
|
|
|
state: present
|
|
|
|
register: create_nrpe_user
|
|
|
|
|
2017-04-05 12:10:19 +02:00
|
|
|
- name: Store credentials in nagios home
|
|
|
|
ini_file:
|
|
|
|
dest: "~nagios/.my.cnf"
|
|
|
|
owner: nagios
|
|
|
|
group: nagios
|
|
|
|
mode: "0600"
|
|
|
|
section: client
|
|
|
|
option: '{{ item.option }}'
|
|
|
|
value: '{{ item.value }}'
|
2021-05-04 14:18:40 +02:00
|
|
|
loop:
|
2017-04-05 12:10:19 +02:00
|
|
|
- { option: 'user', value: 'nrpe' }
|
|
|
|
- { option: 'password', value: '{{ mysql_nrpe_password.stdout }}' }
|
2021-05-09 23:06:42 +02:00
|
|
|
when: create_nrpe_user is changed
|
2016-09-29 16:33:48 +02:00
|
|
|
|
2021-05-09 23:06:42 +02:00
|
|
|
when:
|
|
|
|
- nrpe_evolix_config.stat.exists
|
|
|
|
- (not nrpe_my_cnf.stat.exists or (mysql_force_new_nrpe_password | bool))
|
2016-09-29 16:33:48 +02:00
|
|
|
tags:
|
|
|
|
- mysql
|
|
|
|
- nrpe
|