- name: Install postgresql-common apt: name: postgresql-common state: present - name: Create dir createcluster.d file: path: /etc/postgresql-common/createcluster.d state: directory - name: Disable main cluster creation by default copy: dest: /etc/postgresql-common/createcluster.d/create-main-cluster.conf content: | create_main_cluster = false - 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: Mask PostgreSQL before install ansible.builtin.systemd: name: "{{ patroni_postgresql_unit_name }}" masked: yes when: patroni_postgresql_package_name not in ansible_facts.packages or ansible_facts.packages[patroni_postgresql_package_name][0]['version'] != (patroni_postgresql_version|string + "-" + patroni_postgresql_version_build|string) - name: "Install {{ patroni_postgresql_package_name }}-{{ patroni_postgresql_version }}-{{ patroni_postgresql_version_build }}" apt: name: "{{ patroni_postgresql_package }}" update_cache: yes register: patroni_postgresql_setup when: patroni_postgresql_package_name not in ansible_facts.packages - name: "Update {{ patroni_postgresql_package_name }}-{{ patroni_postgresql_version }}-{{ patroni_postgresql_version_build }}" apt: name: "{{ patroni_postgresql_package }}" update_cache: yes 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 + "-" + patroni_postgresql_version_build|string)