Redis: Ensure that we do not modify munin-node config if there is multiple redis config blocs
This commit is contained in:
parent
36419c5b3c
commit
27e4512e50
|
@ -61,12 +61,24 @@
|
||||||
notify: restart munin-node
|
notify: restart munin-node
|
||||||
tags: redis
|
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:
|
ini_file:
|
||||||
dest: /etc/munin/plugin-conf.d/munin-node
|
dest: /etc/munin/plugin-conf.d/munin-node
|
||||||
section: 'redis_*'
|
section: 'redis_*'
|
||||||
option: env.password
|
option: env.password
|
||||||
value: '{{ redis_password }}'
|
value: '{{ redis_password }}'
|
||||||
notify: restart munin-node
|
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
|
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 "
|
||||||
|
|
Loading…
Reference in a new issue