--- - name: Add gpg keys for redis ansible.builtin.apt_key: url: "{{ item.url }}" keyring: "{{ item.keyring }}" loop: "{{ redis_debian_apt_key }}" - name: Enable https transport for apt apt: name: apt-transport-https update_cache: yes - name: Add redis.list to sources template: src: "etc/apt/sources.list.d/redis.list.j2" dest: /etc/apt/sources.list.d/redis.list #- name: Add redis repository from PPA # ansible.builtin.apt_repository: # repo: ppa:redislabs/redis - name: Check if redis is installed ansible.builtin.shell: dpkg-query -l {{ redis_debian_package }} 2>&1 | grep {{ redis_debian_version }} ignore_errors: True register: is_redis changed_when: is_redis.rc != 0 failed_when: False - name: Mask redis before install ansible.builtin.systemd: name: "{{ redis_debian_package }}" masked: yes when: is_redis.rc != 0 - name: Install redis {{ redis_debian_version }} apt: name: - "{{ redis_debian_package }}={{ redis_debian_version }}" - "redis-tools={{ redis_debian_version }}" update_cache: yes when: is_redis.rc != 0 - name: Move default config file to /etc/redis/redis.conf.orig command: mv /etc/redis/redis.conf /etc/redis/redis.conf.orig when: is_redis.rc != 0 - name: Check if redis-sentinel is installed ansible.builtin.shell: dpkg-query -W {{ redis_sentinel_debian_package }} 2>&1 | grep {{ redis_sentinel_debian_version }} ignore_errors: True register: is_redis_sentinel changed_when: is_redis_sentinel.rc != 0 failed_when: False - name: Mask redis-sentinel before install ansible.builtin.systemd: name: "{{ redis_sentinel_debian_package }}" masked: yes when: is_redis_sentinel.rc != 0 - name: Install redis-sentinel {{ redis_sentinel_debian_version }} apt: name: "{{ redis_sentinel_debian_package }}={{ redis_sentinel_debian_version }}" update_cache: yes when: is_redis_sentinel != 0 - name: Move default config file to /etc/redis/sentinel.conf.orig command: mv /etc/redis/sentinel.conf /etc/redis/sentinel.conf.orig when: is_redis_sentinel.rc != 0