Redis: Ensure that we do not modify munin-node config if there is multiple redis config blocs

This commit is contained in:
Ludovic Poujol 2017-10-03 10:21:13 +02:00
parent 36419c5b3c
commit 27e4512e50
1 changed files with 14 additions and 2 deletions

View File

@ -61,12 +61,24 @@
notify: restart munin-node
tags: redis
- name: Add redis password for munin
- name: Count redis condif blocks in munin-node configuration
command: grep -c "\[redis_" /etc/munin/plugin-conf.d/munin-node
register: munin_redis_blocs_in_config
failed_when: False
changed_when: False
- name: Add redis password for munin (if no more than 1 config block)
ini_file:
dest: /etc/munin/plugin-conf.d/munin-node
section: 'redis_*'
option: env.password
value: '{{ redis_password }}'
notify: restart munin-node
when: redis_password != '' and redis_password != None
when: "redis_password != '' and redis_password != None and {{munin_redis_blocs_in_config.stdout | int}} <= 1"
tags: redis
- name: Warn if multiple instance in munin-plugins configuration
debug:
msg: "WARNING - It seems you have multiple redis sections in your munin-node configuration - Munin config NOT changed"
when: "redis_password != '' and redis_password != None and {{munin_redis_blocs_in_config.stdout | int}} > 1 "