patroni/tasks/main.yaml

71 lines
2.3 KiB
YAML
Raw Normal View History

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-03-29 20:49:37 +00:00
- name: Set facts about needed vars
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-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-03-29 20:49:37 +00:00
- 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"
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
- 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