- name: Install Patroni {{ patroni_version }} with Python 3.6 when: "patroni_use_python39 is not defined or not patroni_use_python39" block: - name: Add Patroni repository dnf: name: "{{ patroni_repo_package }}" state: present disable_gpg_check: yes - name: "Install Patroni {{ patroni_version }} with Python 3.6" dnf: name: "{{ item }}" state: present disable_gpg_check: yes update_cache: yes loop: - "{{ patroni_default_packages }}" register: patroni_setup - name: Install Patroni {{ patroni_version }} with Python 3.9 when: - patroni_use_python39 is defined - patroni_use_python39 block: - name: Enable Python 3.9 module shell: dnf module enable -y python39 register: enable_python39_module changed_when: "'Nothing to do' not in enable_python39_module.stdout" - name: Install Python 3.9 dnf: name: python39 state: present - name: Set python3.9 as python shell: alternatives --set python /usr/bin/python3.9 register: set_python39_as_python changed_when: false failed_when: set_python39_as_python.stdout != '' - name: "Install Patroni {{ patroni_version }} with Python 3.9" dnf: name: "{{ patroni_python39_packages }}" disablerepo: pgdg* state: latest