From 27e4512e502870af67aa7665c16b43e71a2ccff8 Mon Sep 17 00:00:00 2001 From: Ludovic Poujol Date: Tue, 3 Oct 2017 10:21:13 +0200 Subject: [PATCH] Redis: Ensure that we do not modify munin-node config if there is multiple redis config blocs --- redis/tasks/munin.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/redis/tasks/munin.yml b/redis/tasks/munin.yml index 04d6449c..74676e07 100644 --- a/redis/tasks/munin.yml +++ b/redis/tasks/munin.yml @@ -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 "