From 1aa29f98d112fc31c958ef9cf0dbd38292d948f4 Mon Sep 17 00:00:00 2001 From: transcaffeine Date: Tue, 23 Mar 2021 06:55:31 +0100 Subject: [PATCH] fix(redis): ensure idempotency is guaranteed --- roles/redis/handlers/main.yml | 7 +++++++ roles/redis/tasks/main.yml | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 roles/redis/handlers/main.yml diff --git a/roles/redis/handlers/main.yml b/roles/redis/handlers/main.yml new file mode 100644 index 0000000..4b02c5a --- /dev/null +++ b/roles/redis/handlers/main.yml @@ -0,0 +1,7 @@ +--- + +- name: restart-redis + docker_container: + name: "{{ redis_docker_container_name }}" + state: started + restart: yes diff --git a/roles/redis/tasks/main.yml b/roles/redis/tasks/main.yml index 066f686..c91680a 100644 --- a/roles/redis/tasks/main.yml +++ b/roles/redis/tasks/main.yml @@ -34,13 +34,13 @@ dest: "{{ redis_config_file }}" owner: "{{ redis_user }}" group: "{{ redis_user }}" + notify: restart-redis - name: Setup redis docker container docker_container: image: "{{ redis_docker_image }}" name: "{{ redis_docker_container_name }}" restart_policy: unless-stopped - recreate: true pull: true user: "{{ redis_user_res.uid }}:{{ redis_user_res.group }}" ports: "{{ redis_docker_ports }}" @@ -51,3 +51,6 @@ healthcheck: test: >- redis-cli -a {{ redis_secret }} PING || exit 1 + +- name: Ensure redis is restarted if config changed + meta: flush_handlers