- name: Disable PostgreSQL module shell: dnf module disable -y postgresql register: disable_postgresql_module changed_when: "'Nothing to do' not in disable_postgresql_module.stdout" - name: Gather packages package_facts: manager: auto - name: Set fact about PostgreSQL package set_fact: patroni_postgresql_installed_package: "{{ ansible_facts.packages[patroni_postgresql_package_name][0]['name'] }}" when: patroni_postgresql_package_name in ansible_facts.packages - name: Print installed PostgreSQL version debug: msg: "{{ ansible_facts.packages[patroni_postgresql_package_name][0]['version'] }}" verbosity: 2 when: patroni_postgresql_installed_package is defined - name: "Install {{ patroni_postgresql_package_name }}-{{ patroni_postgresql_version }}" dnf: name: "{{ item }}" loop: - "{{ patroni_postgresql_packages }}" register: patroni_postgresql_setup when: patroni_postgresql_package_name not in ansible_facts.packages - name: "Update {{ patroni_postgresql_package_name }}-{{ patroni_postgresql_version }}" dnf: name: "{{ item }}" loop: - "{{ patroni_postgresql_packages }}" register: patroni_postgresql_update when: - patroni_postgresql_package_name in ansible_facts.packages - ansible_facts.packages[patroni_postgresql_package_name][0]['version'] != patroni_postgresql_version|string