---
- name: Install redis
  become: yes
  package:
    name: "{{ redis_package }}"
    state: present
  register: _task
  retries: 5
  delay: 3
  until: _task is succeeded
  tags: redis

- name: Ensure redis service is enabled and running
  become: yes
  service:
    name: "{{ redis_package }}"
    enabled: yes
    state: started
  tags: redis
  when: ansible_facts.os_family == 'RedHat'

---
- name: Install redis
  become: yes
  package:
    name: "{{ redis_package }}"
    state: present
  register: _task
  retries: 5
  delay: 3
  until: _task is succeeded
  tags: redis

- name: Allow redis to be controlled by systemd
  become: yes
  lineinfile:
    dest: /etc/redis/redis.conf
    line: supervised systemd
  tags: redis
  when: ansible_facts.os_family == 'Debian'

- name: Ensure redis service is enabled and running
  become: yes
  service:
    name: redis
    enabled: yes
    state: started
  tags: redis

Make redis controlled by systemd on ubuntu
Make redis controlled by systemd on ubuntu
