- name: Gather packages package_facts: manager: auto - name: Set fact about Patroni package set_fact: patroni_installed_package: "{{ ansible_facts.packages[patroni_package_name][0]['name'] }}" when: patroni_package_name in ansible_facts.packages - name: Print installed Patroni version debug: msg: "{{ ansible_facts.packages[patroni_package_name][0]['version'] }}" verbosity: 2 when: patroni_installed_package is defined - name: Mask Patroni before install ansible.builtin.systemd: name: "{{ patroni_unit_name }}" masked: yes when: patroni_package_name not in ansible_facts.packages or ansible_facts.packages[patroni_package_name][0]['version'] != (patroni_version|string + "-" + patroni_version_build|string) - name: "Install {{ patroni_package_name }}-{{ patroni_version }}-{{ patroni_version_build }}" apt: name: "{{ patroni_package }}" update_cache: yes register: patroni_setup when: patroni_package_name not in ansible_facts.packages - name: "Update {{ patroni_package_name }}-{{ patroni_version }}-{{ patroni_version_build }}" apt: name: "{{ patroni_package }}" update_cache: yes register: patroni_update notify: Restart Patroni when: - patroni_package_name in ansible_facts.packages - ansible_facts.packages[patroni_package_name][0]['version'] != (patroni_version|string + "-" + patroni_version_build|string)