--- - name: Check if redis is running command: systemctl status redis-server ignore_errors: yes changed_when: False register: service_redis_status failed_when: False - block: - name: Ensure redis config exists copy: content: "" dest: "/etc/redis/redis.conf" force: no owner: redis group: redis mode: 0640 - name: Template redis config blockinfile: block: "{{ lookup('template', 'etc/redis/redis.conf.j2') }}" path: "/etc/redis/redis.conf" notify: - Restart redis when: service_redis_status.rc != 0 - name: Ensure redis auth config exists copy: content: "" dest: "/etc/redis/redis-auth.conf" force: no owner: redis group: redis mode: 0640 - name: Template redis auth config blockinfile: block: "{{ lookup('template', 'etc/redis/redis-auth.conf.j2') }}" path: "/etc/redis/redis-auth.conf" notify: - Restart redis