patroni/tasks/main.yaml
2023-03-29 23:49:37 +03:00

71 lines
2.2 KiB
YAML

- 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 needed vars
set_fact:
patroni_postgresql_home_dir: "{{ patroni_postgresql_home_dir }}"
patroni_postgresql_data_dir: "{{ patroni_postgresql_data_dir }}"
- name: "Set locale for PostgreSQL"
include_tasks: locale.yaml
tags: patroni_locale
- name: "Install Patroni repository and deps for {{ ansible_facts['os_family'] }}"
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['os_family'] }}"
include_tasks: "{{ ansible_facts['os_family'] }}/postgresql_install.yaml"
tags: patroni_install
- name: "Manage TLS/SSL certificates"
include_tasks: cacert.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['os_family'] }}"
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
when:
- patroni_postgresql_dynamic_parameters
tags: patroni_dynamic_configure