An Ansible role which installs and configures Patroni - HA solution for PostgreSQL/EPAS.
Note: The role only installs EPAS: 10, 11, 12, 13, 14 or 15 across multiple nodes.
Not all Distribution or versions are supported on all the operating systems available.
The ansible playbook must be executed under an account that has full privileges.
The requirements for this ansible galaxy role are:
- Ansible >= 2.9
community.general
edb_devops.edb_postgres
->setup_repo
- for installing the EPAS/PG repositoryedb_devops.edb_postgres
->install_dbserver
- for installing the EPAS/PG binaries
When executing the role via ansible there are three required variables:
Operating Systems supported are: CentOS7, RHEL7, CentOS8, RHEL8, AlmaLinux8, Debian10, Ubuntu20, and Ubuntu22
Postgres Versions supported are: 10, 11, 12, 13, 14 and 15
Database Engine supported are: PG and EPAS
Certain parameters are restricted by Patroni and are required to be set in the Patroni DCS configuration file. These parameters and their Patroni defaults are:
max_wal_senders: 5
max_replication_slots: 5
wal_keep_segments: 8
wal_keep_size: 128MB
Learn more about PostgreSQL parameters controlled by Patroni.
Using this parameter you can customize these and other Postgres parameters in the Patroni DCS config file. Note: To ensure the playbook runs successfully, input parameter names and values as strings.
Example:
patroni_pg_init_params:
- name: 'max_keep_segments'
value: '32'
The resulting Patroni DCS config will appear as such:
postgresql:
parameters:
max_keep_segments: '32'
These and other variables can be assigned in the pre_tasks
definition of the
section: How to include the setup_patroni
role in your Playbook
The rest of the variables can be configured and are available in the:
- roles/setup_patroni/defaults/main.yml
- roles/setup_patroni/vars/EPAS_RedHat.yml
- roles/setup_patroni/vars/PG_RedHat.yml
- roles/setup_patroni/vars/EPAS_Debian.yml
- roles/setup_patroni/vars/PG_Debian.yml
setup_patroni
has dependencies on the following roles
setup_repo
install_dbserver
setup_etcd
Content of the inventory.yml
file:
all:
children:
primary:
hosts:
primary1:
ansible_host: xxx.xxx.xxx.xxx
private_ip: xxx.xxx.xxx.xxx
etcd: true
etcd_cluster_name: 'patroni-etcd'
standby:
hosts:
standby1:
ansible_host: xxx.xxx.xxx.xxx
private_ip: xxx.xxx.xxx.xxx
upstream_node_private_ip: xxx.xxx.xxx.xxx
replication_type: synchronous
etcd: true
etcd_cluster_name: 'patroni-etcd'
standby2:
ansible_host: xxx.xxx.xxx.xxx
private_ip: xxx.xxx.xxx.xxx
upstream_node_private_ip: xxx.xxx.xxx.xxx
replication_type: asynchronous
etcd: true
etcd_cluster_name: 'patroni-etcd'
Below is an example of how to include the setup_patroni
role:
---
- hosts: primary,standby
name: Install Patroni on Instances
become: true
gather_facts: yes
any_errors_fatal: true
collections:
- edb_devops.edb_postgres
pre_tasks:
- name: Initialize the user defined variables
set_fact:
pg_type: "PG"
pg_version: 14
use_patroni: true
patroni_pg_init_params:
- name: 'max_keep_size'
value: '160'
roles:
- role: setup_repo
when: "'setup_repo' in lookup('edb_devops.edb_postgres.supported_roles', wantlist=True)"
- role: install_dbserver
when: "'install_dbserver' in lookup('edb_devops.edb_postgres.supported_roles', wantlist=True)"
- role: setup_etcd
when: "'setup_etcd' in lookup('edb_devops.edb_postgres.supported_roles', wantlist=True)"
- role: setup_patroni
when: "'setup_patroni' in lookup('edb_devops.edb_postgres.supported_roles', wantlist=True)"
Defining and adding variables is done in the set_fact
of the pre_tasks
.
All the variables are available at:
- roles/setup_patroni/defaults/main.yml
- roles/setup_patroni/vars/EPAS_RedHat.yml
- roles/setup_patroni/vars/PG_RedHat.yml
- roles/setup_patroni/vars/EPAS_Debian.yml
- roles/setup_patroni/vars/PG_Debian.yml
Distribution | 10 | 11 | 12 | 13 | 14 | 15 |
---|---|---|---|---|---|---|
CentOS 7 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Red Hat Linux 7 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
RockyLinux 8 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Red Hat Linux 8 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
AlmaLinux8 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Ubuntu 20.04 LTS (Focal) - x86_64 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Debian 9 (Stretch) - x86_64 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Debian 10 (Buster) - x86_64 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Distribution | 10 | 11 | 12 | 13 | 14 | 15 |
---|---|---|---|---|---|---|
CentOS 7 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Red Hat Linux 7 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
RockyLinux 8 | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ |
Red Hat Linux 8 | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ |
AlmaLinux8 | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ |
Ubuntu 20.04 LTS (Focal) - x86_64 | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ |
Debian 9 (Stretch) - x86_64 | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ |
Debian 10 (Buster) - x86_64 | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ |
- ✅ - Tested and supported
- ❌ - Not supported
# To deploy community Postgres version 14 on CentOS7 hosts with the user centos
$ ansible-playbook playbook.yml \
-u centos \
-i inventory.yml \
--private-key <key.pem> \
--extra-vars="pg_version=14 pg_type=PG"
# To deploy EPAS version 12 on RHEL8 hosts with the user ec2-user
$ ansible-playbook playbook.yml \
-u ec2-user \
-i inventory.yml \
--private-key <key.pem> \
--extra-vars="pg_version=12 pg_type=EPAS"
BSD
Author:
- Vibhor Kumar (Co-Author)
- EDB Postgres
- DevOps
- [email protected] www.enterprisedb.com