patroni/patroni.yaml
2023-09-30 21:22:06 +03:00

91 lines
2.6 KiB
YAML

- hosts: localhost
gather_facts: false
tasks:
- name: Print Ansible version
debug:
msg: "{{ ansible_version }}"
- hosts: all,!localhost
gather_facts: false
tasks:
- name: Wait 300 seconds
ansible.builtin.wait_for_connection:
timeout: 300
- hosts: all,!localhost
tasks:
- name: Include Patroni vars
ansible.builtin.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_distribution }}.yaml"
- "{{ ansible_os_family }}.yaml"
- patroni.yaml
paths:
- "vars"
- hosts: all,!localhost
become: true
tasks:
- name: Debian based repository
when: ansible_facts['os_family'] == "Debian"
block:
- name: Add repository for Debian
copy:
dest: /etc/apt/sources.list.d/mirror.0xace.cc.list
content: |
deb [trusted=yes] https://mirror.0xace.cc/debian/consul/ default all
deb [trusted=yes] https://mirror.0xace.cc/debian/custom/ default all
- name: RHEL based repository
when: ansible_facts['os_family'] == "RedHat"
block:
- name: Add custom 0xace.cc repository for RHEL
ansible.builtin.yum_repository:
name: "rhel-custom"
description: "RHEL custom 0xace.cc repository"
file: "mirror.0xace.cc"
baseurl: "https://mirror.0xace.cc/rhel/$releasever/custom"
gpgcheck: false
enabled: true
- hosts: all,!localhost
gather_facts: true
become: true
tasks:
- name: Set hostname
ansible.builtin.hostname:
name: "{{ inventory_hostname }}"
- import_role:
name: hosts
- hosts: all,!localhost
gather_facts: true
become: true
tasks:
- import_role:
name: consul
- hosts: patroni
gather_facts: true
become: true
tasks:
- import_role:
name: patroni
- import_role:
name: keepalived
when: keepalived_vip is defined
- import_role:
name: haproxy
- import_role:
name: pgbouncer
- import_role:
name: postgres-exporter
- import_role:
name: node-exporter