2023-02-07 23:39:20 +00:00
|
|
|
- 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:
|
2023-03-29 20:49:37 +00:00
|
|
|
- "{{ 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"
|
2023-02-07 23:39:20 +00:00
|
|
|
- "{{ ansible_facts['distribution'] }}.yaml"
|
|
|
|
- "{{ ansible_facts['os_family'] }}.yaml"
|
|
|
|
paths:
|
|
|
|
- "vars"
|
2023-03-29 20:49:37 +00:00
|
|
|
tags: patroni_vars
|
2023-02-07 23:39:20 +00:00
|
|
|
|
2023-04-19 12:19:52 +00:00
|
|
|
- name: Set facts about Patroni vars
|
2023-03-29 20:49:37 +00:00
|
|
|
set_fact:
|
|
|
|
patroni_postgresql_home_dir: "{{ patroni_postgresql_home_dir }}"
|
|
|
|
patroni_postgresql_data_dir: "{{ patroni_postgresql_data_dir }}"
|
2023-02-10 14:44:03 +00:00
|
|
|
|
2023-04-19 12:19:52 +00:00
|
|
|
- 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
|
|
|
|
|
2023-03-29 20:49:37 +00:00
|
|
|
- name: "Set locale for PostgreSQL"
|
|
|
|
include_tasks: locale.yaml
|
|
|
|
tags: patroni_locale
|
2023-02-10 14:44:03 +00:00
|
|
|
|
2023-04-19 12:19:52 +00:00
|
|
|
- name: "Install Patroni repository and deps for {{ ansible_facts['distribution'] }}"
|
2023-03-29 20:49:37 +00:00
|
|
|
include_tasks: "{{ ansible_facts['os_family'] }}/patroni_repos_and_deps.yaml"
|
|
|
|
when: patroni_install_official_repo
|
|
|
|
tags: patroni_repos_and_deps
|
|
|
|
|
2023-04-19 12:19:52 +00:00
|
|
|
- name: "Install PostgreSQL for {{ ansible_facts['distribution'] }}"
|
2023-03-29 20:49:37 +00:00
|
|
|
include_tasks: "{{ ansible_facts['os_family'] }}/postgresql_install.yaml"
|
2023-04-19 11:24:08 +00:00
|
|
|
tags: patroni_postgresql_install
|
2023-03-29 20:49:37 +00:00
|
|
|
|
|
|
|
- name: "Manage TLS/SSL certificates"
|
|
|
|
include_tasks: cacert.yaml
|
|
|
|
when: patroni_ssl
|
|
|
|
|
|
|
|
- name: "Check if patroni.yaml exist"
|
2023-02-07 23:39:20 +00:00
|
|
|
stat:
|
|
|
|
path: /etc/patroni/patroni.yaml
|
|
|
|
register: patroni_config
|
|
|
|
|
2023-04-19 12:19:52 +00:00
|
|
|
- name: "Install Patroni for {{ ansible_facts['distribution'] }}"
|
2023-02-07 23:39:20 +00:00
|
|
|
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
|
|
|
|
|
2023-07-21 14:13:51 +00:00
|
|
|
#- name: Patroni cluster reconfiguration after restore from backup
|
|
|
|
# include_tasks: restore.yaml
|
|
|
|
# when: patroni_wal_g_restore_from_backup
|
|
|
|
|
|
|
|
- name: Dynamic Patroni configuration
|
2023-02-07 23:39:20 +00:00
|
|
|
include_tasks: dynamic_config.yaml
|
|
|
|
tags: patroni_dynamic_configure
|