ansible-roles/mysql/tasks/nrpe.yml
Jérémy Lecour 8920ff1ee4 Add "always_run: yes" where it's pertinent
There is also the "check_mode: no", but commented,
for when we switch to Ansible 2.2
2017-01-31 11:45:35 +01:00

43 lines
1 KiB
YAML

---
- name: is NRPE present ?
stat:
path: /etc/nagios/nrpe.d/evolix.cfg
#check_mode: no (for migration to Ansible 2.2)
always_run: yes
register: nrpe_evolix_config
tags:
- mysql
- nrpe
- block:
- name: Create a password for NRPE
shell: perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..16)'
register: mysql_nrpe_password
changed_when: False
- debug:
msg: "repl password: {{ mysql_nrpe_password.stdout }}"
- name: Create nrpe user
mysql_user:
name: nrpe
password: '{{ mysql_nrpe_password.stdout }}'
config_file: /root/.my.cnf
update_password: on_create
state: present
register: create_nrpe_user
- name: config check_mysql to use the new password
replace:
dest: /etc/nagios/nrpe.d/evolix.cfg
regexp: '\bMYSQL_PASSWD\b'
replace: '{{ mysql_nrpe_password.stdout }}'
notify: restart nagios-nrpe-server
when: create_nrpe_user.changed
when: nrpe_evolix_config.stat.exists
tags:
- mysql
- nrpe