- name: Make sure handlers are flushed immediately meta: flush_handlers - name: Load a variable file based on the OS type include_vars: "{{ lookup('first_found', params) }}" vars: params: files: - "{{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_major_version'] }}.yaml" - "{{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_version'] }}.yaml" - "{{ ansible_facts['os_family'] }}-{{ ansible_facts['distribution_major_version'] }}.yaml" - "{{ ansible_facts['os_family'] }}-{{ ansible_facts['distribution_version'] }}.yaml" - "{{ ansible_facts['distribution'] }}.yaml" - "{{ ansible_facts['os_family'] }}.yaml" paths: - "vars" tags: patroni_vars - name: Set facts about Patroni vars set_fact: patroni_postgresql_home_dir: "{{ patroni_postgresql_home_dir }}" patroni_postgresql_data_dir: "{{ patroni_postgresql_data_dir }}" - name: Set facts about WAL-G vars set_fact: wal_g_pg_home_dir: "{{ wal_g_pg_home_dir }}" wal_g_pg_data_dir: "{{ wal_g_pg_data_dir }}" when: - patroni_wal_g_install is defined - patroni_wal_g_install - name: "Set locale for PostgreSQL" include_tasks: locale.yaml tags: patroni_locale - name: "Install Patroni repository and deps for {{ ansible_facts['distribution'] }}" include_tasks: "{{ ansible_facts['os_family'] }}/patroni_repos_and_deps.yaml" when: patroni_install_official_repo tags: patroni_repos_and_deps - name: "Install PostgreSQL for {{ ansible_facts['distribution'] }}" include_tasks: "{{ ansible_facts['os_family'] }}/postgresql_install.yaml" tags: patroni_postgresql_install - name: "Manage TLS/SSL certificates" #include_tasks: cacert.yaml include_tasks: ssl/main.yaml when: patroni_ssl - name: "Check if patroni.yaml exist" stat: path: /etc/patroni/patroni.yaml register: patroni_config - name: "Install Patroni for {{ ansible_facts['distribution'] }}" include_tasks: "{{ ansible_facts['os_family'] }}/main.yaml" tags: patroni_install - name: "Bootstrap Patroni configuration" include_tasks: config.yaml when: not patroni_config.stat.exists tags: patroni_configure - name: Enable and start patroni systemd: daemon_reload: true name: patroni enabled: true state: started masked: no register: patroni_enable_and_start tags: patroni, patroni_start - name: Dynamic Patroni configuration include_tasks: dynamic_config.yaml tags: patroni_dynamic_configure - name: Patroni restart if pending restart include_tasks: restart_pending.yaml tags: patroni_restart_pending