From 9e4b08a75972e2eeeab11ac5885f462a9bfca390 Mon Sep 17 00:00:00 2001 From: opan Date: Fri, 25 Jun 2021 10:14:06 +0700 Subject: [PATCH 01/16] Add support redis cluster Co-authored-by: William Dembo <1708-william.dembo@users.noreply.source.golabs.io> --- defaults/main.yml | 4 ++++ templates/redis.conf.j2 | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index 405ffa79..d05a905d 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -117,6 +117,10 @@ redis_hz: 10 # io-threads-do-reads yes redis_config_additional: "" +## Redis cluster configs +redis_cluster_enabled: false +redis_cluster_node_timeout: 15000 + ## Redis sentinel configs # Set this to true on a host to configure it as a Sentinel redis_sentinel: false diff --git a/templates/redis.conf.j2 b/templates/redis.conf.j2 index 04e24a4f..e5326df4 100644 --- a/templates/redis.conf.j2 +++ b/templates/redis.conf.j2 @@ -53,6 +53,13 @@ min-slaves-max-lag {{ redis_min_slaves_max_lag }} masterauth {{ redis_password }} {% endif -%} +{% if redis_cluster_enabled %} +# Cluster +cluster-enabled yes +cluster-config-file nodes-{{ redis_port }}.conf +cluster-node-timeout {{ redis_cluster_node_timeout }} +{% endif -%} + # Security {% if redis_password -%} requirepass {{ redis_password }} @@ -104,4 +111,4 @@ aof-rewrite-incremental-fsync yes {% if redis_config_additional|length -%} # Additional {{ redis_config_additional -}} -{% endif -%} \ No newline at end of file +{% endif -%} From fe7e5b2711c0db95ac4b9ca6c720577fb2d0f05b Mon Sep 17 00:00:00 2001 From: Imre Nagi Date: Mon, 11 Apr 2022 11:45:26 +0700 Subject: [PATCH 02/16] fix: remove redis restart command after changing the config Signed-off-by: Imre Nagi Co-authored-by: William Dembo <29192168+walbertus@users.noreply.github.com> --- defaults/main.yml | 2 +- tasks/server.yml | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index d05a905d..bd3d8fe8 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -4,7 +4,7 @@ redis_version: 2.8.24 redis_install_dir: /opt/redis redis_dir: /var/lib/redis/{{ redis_port }} redis_config_file_name: "{{ redis_port }}.conf" -redis_download_url: "http://download.redis.io/releases/redis-{{ redis_version }}.tar.gz" +redis_download_url: "https://download.redis.io/releases/redis-{{ redis_version }}.tar.gz" redis_protected_mode: "yes" # Set this to true to validate redis tarball checksum against vars/main.yml diff --git a/tasks/server.yml b/tasks/server.yml index 7befe8a9..e2644192 100644 --- a/tasks/server.yml +++ b/tasks/server.yml @@ -117,7 +117,6 @@ dest: /etc/redis/{{ redis_config_file_name }} owner: "{{ redis_user }}" mode: 0640 - notify: "restart redis" - name: add redis init config file template: @@ -125,7 +124,6 @@ src: redis.init.conf.j2 mode: 0600 when: ansible_os_family == "RedHat" - notify: "restart redis" - name: add redis init config file template: @@ -133,7 +131,6 @@ src: redis.init.conf.j2 mode: 0600 when: ansible_os_family == "Debian" - notify: "restart redis" # Flush handlers before ensuring the service is started to prevent # a start and then restart From fd6aa57bb22c9bc5af7ce64b33ddd4c267120ec1 Mon Sep 17 00:00:00 2001 From: Imre Nagi Date: Mon, 18 Apr 2022 14:36:52 +0700 Subject: [PATCH 03/16] Add notify restart Signed-off-by: Imre Nagi Co-authored-by: William Dembo <1708-william.dembo@users.noreply.source.golabs.io> --- tasks/server.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tasks/server.yml b/tasks/server.yml index e2644192..7befe8a9 100644 --- a/tasks/server.yml +++ b/tasks/server.yml @@ -117,6 +117,7 @@ dest: /etc/redis/{{ redis_config_file_name }} owner: "{{ redis_user }}" mode: 0640 + notify: "restart redis" - name: add redis init config file template: @@ -124,6 +125,7 @@ src: redis.init.conf.j2 mode: 0600 when: ansible_os_family == "RedHat" + notify: "restart redis" - name: add redis init config file template: @@ -131,6 +133,7 @@ src: redis.init.conf.j2 mode: 0600 when: ansible_os_family == "Debian" + notify: "restart redis" # Flush handlers before ensuring the service is started to prevent # a start and then restart From 1bf8e6b34fe3dbed444485bbc2ec58eee35e78f2 Mon Sep 17 00:00:00 2001 From: opanmustopah Date: Wed, 15 Jun 2022 12:28:58 +0700 Subject: [PATCH 04/16] feat: add config to control slave promotion Add config to control whehter a slave can be promoted as a master or not --- defaults/main.yml | 3 +++ templates/redis.conf.j2 | 3 +++ 2 files changed, 6 insertions(+) diff --git a/defaults/main.yml b/defaults/main.yml index bd3d8fe8..bf9181cc 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -120,6 +120,9 @@ redis_config_additional: "" ## Redis cluster configs redis_cluster_enabled: false redis_cluster_node_timeout: 15000 +# Prevent slave to be promoted as a master in case of auto-failover +# only works in version 4.x and above +redis_cluster_slave_no_failover: "no" ## Redis sentinel configs # Set this to true on a host to configure it as a Sentinel diff --git a/templates/redis.conf.j2 b/templates/redis.conf.j2 index e5326df4..8529d05b 100644 --- a/templates/redis.conf.j2 +++ b/templates/redis.conf.j2 @@ -58,6 +58,9 @@ masterauth {{ redis_password }} cluster-enabled yes cluster-config-file nodes-{{ redis_port }}.conf cluster-node-timeout {{ redis_cluster_node_timeout }} +{% if redis_version | split('.') | first | int >= 4 %} +cluster-slave-no-failover {{ redis_cluster_slave_no_failover }} +{% end %} {% endif -%} # Security From fa7ee062f3301ce182ee1a8fe0f27511a7883a5d Mon Sep 17 00:00:00 2001 From: opanmustopah Date: Wed, 15 Jun 2022 14:58:53 +0700 Subject: [PATCH 05/16] fix: wrong closing if syntax --- templates/redis.conf.j2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/redis.conf.j2 b/templates/redis.conf.j2 index 8529d05b..96cecdd9 100644 --- a/templates/redis.conf.j2 +++ b/templates/redis.conf.j2 @@ -58,9 +58,9 @@ masterauth {{ redis_password }} cluster-enabled yes cluster-config-file nodes-{{ redis_port }}.conf cluster-node-timeout {{ redis_cluster_node_timeout }} -{% if redis_version | split('.') | first | int >= 4 %} +{% if redis_version | split('.') | first | int >= 4 -%} cluster-slave-no-failover {{ redis_cluster_slave_no_failover }} -{% end %} +{% endif -%} {% endif -%} # Security From 6752266df2e0ab0f1bcb5e62a90f55783183d239 Mon Sep 17 00:00:00 2001 From: opanmustopah Date: Wed, 15 Jun 2022 15:33:31 +0700 Subject: [PATCH 06/16] fix: split syntax --- templates/redis.conf.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/redis.conf.j2 b/templates/redis.conf.j2 index 96cecdd9..c709e30c 100644 --- a/templates/redis.conf.j2 +++ b/templates/redis.conf.j2 @@ -58,7 +58,7 @@ masterauth {{ redis_password }} cluster-enabled yes cluster-config-file nodes-{{ redis_port }}.conf cluster-node-timeout {{ redis_cluster_node_timeout }} -{% if redis_version | split('.') | first | int >= 4 -%} +{% if redis_version.split('.') | first | int >= 4 -%} cluster-slave-no-failover {{ redis_cluster_slave_no_failover }} {% endif -%} {% endif -%} From 1c9d03f2fefbb76db0d976bc6e7bbde65f0ea036 Mon Sep 17 00:00:00 2001 From: opanmustopah Date: Mon, 29 Aug 2022 16:17:11 +0700 Subject: [PATCH 07/16] fix: update protected_mode to no set sentinels nodes option to empty by default --- defaults/main.yml | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index bf9181cc..632e9afb 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -127,7 +127,7 @@ redis_cluster_slave_no_failover: "no" ## Redis sentinel configs # Set this to true on a host to configure it as a Sentinel redis_sentinel: false -redis_sentinel_protected_mode: "yes" +redis_sentinel_protected_mode: "no" redis_sentinel_dir: /var/lib/redis/sentinel_{{ redis_sentinel_port }} redis_sentinel_bind: 0.0.0.0 redis_sentinel_port: 26379 @@ -136,15 +136,17 @@ redis_sentinel_pidfile: /var/run/redis/sentinel_{{ redis_sentinel_port }}.pid redis_sentinel_logfile: '""' redis_sentinel_syslog_ident: sentinel_{{ redis_sentinel_port }} redis_sentinel_oom_score_adjust: 0 -redis_sentinel_monitors: - - name: master01 - host: localhost - port: 6379 - quorum: 2 - auth_pass: ant1r3z - down_after_milliseconds: 30000 - parallel_syncs: 1 - failover_timeout: 180000 - notification_script: false - client_reconfig_script: false - rename_commands: [] +redis_sentinel_monitors: [] +# Example: +# redis_sentinel_monitors: +# - name: master01 +# host: localhost +# port: 6379 +# quorum: 2 +# auth_pass: ant1r3z +# down_after_milliseconds: 30000 +# parallel_syncs: 1 +# failover_timeout: 180000 +# notification_script: false +# client_reconfig_script: false +# rename_commands: [] From 53aa2f87f19fe84990218ac352c68f11b51e8db8 Mon Sep 17 00:00:00 2001 From: opanmustopah Date: Mon, 17 Oct 2022 16:16:59 +0700 Subject: [PATCH 08/16] feat: add redis_sentinel_static_monitor_master set to false if master is registered via command instead updating from config file --- defaults/main.yml | 3 +++ templates/redis_sentinel.conf.j2 | 2 ++ 2 files changed, 5 insertions(+) diff --git a/defaults/main.yml b/defaults/main.yml index 632e9afb..63757eea 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -137,6 +137,9 @@ redis_sentinel_logfile: '""' redis_sentinel_syslog_ident: sentinel_{{ redis_sentinel_port }} redis_sentinel_oom_score_adjust: 0 redis_sentinel_monitors: [] +# Set this to false if you monitor master via command instead hardcoded +# in the config file +redis_sentinel_static_monitor_master: true # Example: # redis_sentinel_monitors: # - name: master01 diff --git a/templates/redis_sentinel.conf.j2 b/templates/redis_sentinel.conf.j2 index 2fc59390..830fb5b9 100644 --- a/templates/redis_sentinel.conf.j2 +++ b/templates/redis_sentinel.conf.j2 @@ -13,6 +13,7 @@ bind {{ redis_sentinel_bind }} requirepass {{ redis_sentinel_password }} {% endif %} +{% if redis_sentinel_static_monitor_master %} {% for master in redis_sentinel_monitors -%} sentinel monitor {{ master.name }} {{ master.host }} {{ master.port }} {{ master.quorum|d('2') }} {% for option in ('auth_pass', 'down_after_milliseconds', 'parallel_syncs', 'failover_timeout', 'notification_script', 'client_reconfig_script') -%} @@ -26,6 +27,7 @@ sentinel rename-command {{ master.name }} {{ command }} {% endfor -%} {% endif -%} {% endfor -%} +{% endif %} logfile {{ redis_sentinel_logfile }} syslog-enabled {{ redis_syslog_enabled }} From aae5b13a6cde68cde9bfb0a04bb87dfffd7bdc0f Mon Sep 17 00:00:00 2001 From: opanmustopah Date: Tue, 18 Oct 2022 13:38:53 +0700 Subject: [PATCH 09/16] fix: allow to partially update sentinel config --- defaults/main.yml | 6 +-- tasks/sentinel.yml | 64 ++++++++++++++++++++++++++++++++ templates/redis_sentinel.conf.j2 | 5 ++- 3 files changed, 70 insertions(+), 5 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 63757eea..97e55727 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -137,9 +137,9 @@ redis_sentinel_logfile: '""' redis_sentinel_syslog_ident: sentinel_{{ redis_sentinel_port }} redis_sentinel_oom_score_adjust: 0 redis_sentinel_monitors: [] -# Set this to false if you monitor master via command instead hardcoded -# in the config file -redis_sentinel_static_monitor_master: true +# Set this to true if you update the configuration via runtime +# e.g: registering master to monitor via command-line instead manually edit the config file +redis_sentinel_runtime_monitor_master: false # Example: # redis_sentinel_monitors: # - name: master01 diff --git a/tasks/sentinel.yml b/tasks/sentinel.yml index dc389d57..a71211b4 100644 --- a/tasks/sentinel.yml +++ b/tasks/sentinel.yml @@ -102,6 +102,26 @@ - redis_sentinel_pidfile != '""' - not sentinel_piddir.stat.exists +- name: check if sentinel is running + command: + cmd: systemctl status sentinel_{{ redis_sentinel_port }} + ignore_errors: true + changed_when: false + register: sentinel_service_status + +- name: run flushconfig to rewrite config file from current configuration + command: + cmd: "redis-cli -p {{ redis_sentinel_port }} SENTINEL FLUSHCONFIG" + when: sentinel_service_status | success + +- name: backup existing config file + copy: + src: /etc/redis/sentinel_{{ redis_sentinel_port }}.conf + dest: /etc/redis/sentinel_{{ redis_sentinel_port }}.conf.{{ ansible_date_time['date'] }} + owner: "{{ redis_user }}" + mode: 0640 + backup: yes + - name: create sentinel config file template: src: redis_sentinel.conf.j2 @@ -109,6 +129,50 @@ owner: "{{ redis_user }}" mode: 0640 notify: "restart sentinel" + when: not redis_sentinel_runtime_monitor_master + +- name: update static configuration in config file + blockinfile: + path: /etc/redis/sentinel_{{ redis_sentinel_port }}.conf + insertafter: "### STATIC CONFIG START HERE ###" + insertbefore: "### STATIC CONFIG STOP HERE ###" + owner: "{{ redis_user }}" + mode: 0640 + when: redis_sentinel_runtime_monitor_master == true + block: | + # redis-sentinel {{ redis_version }} configuration file + # sentinel_{{ redis_sentinel_port }}.conf + + daemonize {{ redis_daemonize }} + protected-mode {{ redis_sentinel_protected_mode }} + dir {{ redis_sentinel_dir }} + pidfile {{ redis_sentinel_pidfile }} + port {{ redis_sentinel_port }} + bind {{ redis_sentinel_bind }} + + # Security + {% if redis_sentinel_password %} + requirepass {{ redis_sentinel_password }} + {% endif %} + + {% for master in redis_sentinel_monitors -%} + sentinel monitor {{ master.name }} {{ master.host }} {{ master.port }} {{ master.quorum|d('2') }} + {% for option in ('auth_pass', 'down_after_milliseconds', 'parallel_syncs', 'failover_timeout', 'notification_script', 'client_reconfig_script') -%} + {% if master[option] is defined and master[option] -%} + sentinel {{ option|replace('_', '-') }} {{ master.name }} {{ master[option] }} + {% endif %} + {% endfor -%} + {% if master['rename_commands'] is defined -%} + {% for command in master['rename_commands'] -%} + sentinel rename-command {{ master.name }} {{ command }} + {% endfor -%} + {% endif -%} + {% endfor -%} + + logfile {{ redis_sentinel_logfile }} + syslog-enabled {{ redis_syslog_enabled }} + syslog-ident {{ redis_sentinel_syslog_ident }} + syslog-facility {{ redis_syslog_facility }} - name: add sentinel init config file template: diff --git a/templates/redis_sentinel.conf.j2 b/templates/redis_sentinel.conf.j2 index 830fb5b9..919ddb34 100644 --- a/templates/redis_sentinel.conf.j2 +++ b/templates/redis_sentinel.conf.j2 @@ -1,3 +1,4 @@ +### STATIC CONFIG START HERE ### # redis-sentinel {{ redis_version }} configuration file # sentinel_{{ redis_sentinel_port }}.conf @@ -13,7 +14,6 @@ bind {{ redis_sentinel_bind }} requirepass {{ redis_sentinel_password }} {% endif %} -{% if redis_sentinel_static_monitor_master %} {% for master in redis_sentinel_monitors -%} sentinel monitor {{ master.name }} {{ master.host }} {{ master.port }} {{ master.quorum|d('2') }} {% for option in ('auth_pass', 'down_after_milliseconds', 'parallel_syncs', 'failover_timeout', 'notification_script', 'client_reconfig_script') -%} @@ -27,9 +27,10 @@ sentinel rename-command {{ master.name }} {{ command }} {% endfor -%} {% endif -%} {% endfor -%} -{% endif %} logfile {{ redis_sentinel_logfile }} syslog-enabled {{ redis_syslog_enabled }} syslog-ident {{ redis_sentinel_syslog_ident }} syslog-facility {{ redis_syslog_facility }} + +### STATIC CONFIG STOP HERE ### From 2b11094597610b5d2aa4b73121e8391fcaab52f3 Mon Sep 17 00:00:00 2001 From: opanmustopah Date: Tue, 18 Oct 2022 13:46:52 +0700 Subject: [PATCH 10/16] fix: update checking service sentinel running before flushconfig --- tasks/sentinel.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/sentinel.yml b/tasks/sentinel.yml index a71211b4..772ec6b9 100644 --- a/tasks/sentinel.yml +++ b/tasks/sentinel.yml @@ -112,7 +112,7 @@ - name: run flushconfig to rewrite config file from current configuration command: cmd: "redis-cli -p {{ redis_sentinel_port }} SENTINEL FLUSHCONFIG" - when: sentinel_service_status | success + when: sentinel_service_status.rc == 0 - name: backup existing config file copy: From 599a2b718b4484e43ba9e0461678efbfdfd11c5d Mon Sep 17 00:00:00 2001 From: opanmustopah Date: Tue, 18 Oct 2022 13:52:12 +0700 Subject: [PATCH 11/16] fix: set remote_src true when copying file --- tasks/sentinel.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/tasks/sentinel.yml b/tasks/sentinel.yml index 772ec6b9..46652e29 100644 --- a/tasks/sentinel.yml +++ b/tasks/sentinel.yml @@ -121,6 +121,7 @@ owner: "{{ redis_user }}" mode: 0640 backup: yes + remote_src: true - name: create sentinel config file template: From 0931bbef25edc5141846a57b3fba79eaee0cfd04 Mon Sep 17 00:00:00 2001 From: opanmustopah Date: Tue, 18 Oct 2022 13:57:01 +0700 Subject: [PATCH 12/16] fix: wrong placement of when clause --- tasks/sentinel.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tasks/sentinel.yml b/tasks/sentinel.yml index 46652e29..f957b17f 100644 --- a/tasks/sentinel.yml +++ b/tasks/sentinel.yml @@ -139,7 +139,7 @@ insertbefore: "### STATIC CONFIG STOP HERE ###" owner: "{{ redis_user }}" mode: 0640 - when: redis_sentinel_runtime_monitor_master == true + backup: yes block: | # redis-sentinel {{ redis_version }} configuration file # sentinel_{{ redis_sentinel_port }}.conf @@ -174,6 +174,7 @@ syslog-enabled {{ redis_syslog_enabled }} syslog-ident {{ redis_sentinel_syslog_ident }} syslog-facility {{ redis_syslog_facility }} + when: redis_sentinel_runtime_monitor_master == true - name: add sentinel init config file template: From 938c5cfea25ebb83948778180eba1bea15fa3a46 Mon Sep 17 00:00:00 2001 From: opanmustopah Date: Tue, 18 Oct 2022 14:12:32 +0700 Subject: [PATCH 13/16] fix: remove insertafter clause --- tasks/sentinel.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/tasks/sentinel.yml b/tasks/sentinel.yml index f957b17f..37de4848 100644 --- a/tasks/sentinel.yml +++ b/tasks/sentinel.yml @@ -135,7 +135,6 @@ - name: update static configuration in config file blockinfile: path: /etc/redis/sentinel_{{ redis_sentinel_port }}.conf - insertafter: "### STATIC CONFIG START HERE ###" insertbefore: "### STATIC CONFIG STOP HERE ###" owner: "{{ redis_user }}" mode: 0640 From 0862b96efc2dc90f774a8a2d7cbf30fbe705c7a4 Mon Sep 17 00:00:00 2001 From: opanmustopah Date: Tue, 18 Oct 2022 14:21:37 +0700 Subject: [PATCH 14/16] fix: remove unnecessary backup file --- tasks/sentinel.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/tasks/sentinel.yml b/tasks/sentinel.yml index 37de4848..817f8e91 100644 --- a/tasks/sentinel.yml +++ b/tasks/sentinel.yml @@ -120,7 +120,6 @@ dest: /etc/redis/sentinel_{{ redis_sentinel_port }}.conf.{{ ansible_date_time['date'] }} owner: "{{ redis_user }}" mode: 0640 - backup: yes remote_src: true - name: create sentinel config file From c8e6d566934493fd9823dc90d1736bb0280da074 Mon Sep 17 00:00:00 2001 From: opanmustopah Date: Wed, 19 Oct 2022 09:43:08 +0700 Subject: [PATCH 15/16] fix: call notify restart sentinel when partially update sentinel config file --- tasks/sentinel.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/tasks/sentinel.yml b/tasks/sentinel.yml index 817f8e91..02834344 100644 --- a/tasks/sentinel.yml +++ b/tasks/sentinel.yml @@ -172,6 +172,7 @@ syslog-enabled {{ redis_syslog_enabled }} syslog-ident {{ redis_sentinel_syslog_ident }} syslog-facility {{ redis_syslog_facility }} + notify: "restart sentinel" when: redis_sentinel_runtime_monitor_master == true - name: add sentinel init config file From c69335b8b46b54578bff5e3f1e6359e7861ac47a Mon Sep 17 00:00:00 2001 From: opanmustopah Date: Mon, 24 Oct 2022 09:36:56 +0700 Subject: [PATCH 16/16] fix: check config file before backup sentinel config --- tasks/sentinel.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tasks/sentinel.yml b/tasks/sentinel.yml index 02834344..907bbb37 100644 --- a/tasks/sentinel.yml +++ b/tasks/sentinel.yml @@ -114,6 +114,11 @@ cmd: "redis-cli -p {{ redis_sentinel_port }} SENTINEL FLUSHCONFIG" when: sentinel_service_status.rc == 0 +- name: check if sentinel config file exists + stat: + path: /etc/redis/sentinel_{{ redis_sentinel_port }}.conf + register: _config_file + - name: backup existing config file copy: src: /etc/redis/sentinel_{{ redis_sentinel_port }}.conf @@ -121,6 +126,7 @@ owner: "{{ redis_user }}" mode: 0640 remote_src: true + when: _config_file.stat.exists - name: create sentinel config file template: @@ -129,7 +135,9 @@ owner: "{{ redis_user }}" mode: 0640 notify: "restart sentinel" - when: not redis_sentinel_runtime_monitor_master + when: + - not redis_sentinel_runtime_monitor_master or + not _config_file.stat.exists - name: update static configuration in config file blockinfile: