Skip to content

Latest commit

 

History

History
174 lines (131 loc) · 5.06 KB

README.md

File metadata and controls

174 lines (131 loc) · 5.06 KB

setup_repmgr

This Ansible Role installs and configures High-Availability of a streaming replication Postgres cluster, based on repmgr.

Note: Only PostgreSQL is supported by this role, EPAS will be supported in the future. For more details refer to the: Database engines supported section.

The ansible playbook must be executed under an account that has full privileges.

Requirements

The requirements for this Ansible Role are:

  1. Ansible >= 2.9
  2. community.general
  3. edb_devops.edb_postgres -> setup_repo - for installing the EPAS/PG repository
  4. edb_devops.edb_postgres -> install_dbserver - for installing the EPAS/PG binaries
  5. edb_devops.edb_postgres -> init_dbserver - for initializing the EPAS/PG data directory and configuring a primary node.
  6. edb_devops.edb_postgres -> setup_replication - for creating the standby.

Role variables

When executing the role via ansible there are three required variables:

  • pg_version

Postgres Versions supported are: 10, 11, 12, 13 and 14

  • pg_type

Database Engine supported is PG

These and other variables can be assigned in the pre_tasks definition of the section: How to include the setup_repmgr role in your Playbook

The rest of the variables can be configured and are available in the:

Dependencies

This role depends on the manage_dbserver role.

Example Playbook

Inventory file content

Content of the inventory.yml file for 3 Postgres nodes cluster composed of 1 primary node and 2 standby nodes:

all:
  children:
    primary:
      hosts:
        primary1:
          ansible_host: 192.168.122.1
          private_ip: 10.0.0.1
    standby:
      hosts:
        standby1:
          ansible_host: 192.168.122.2
          private_ip: 10.0.0.2
          upstream_node_private_ip: 10.0.0.1
          replication_type: synchronous
        standby2:
          ansible_host: 192.168.122.3
          private_ip: 10.0.0.3
          upstream_node_private_ip: 10.0.0.1
          replication_type: asynchronous

The following inventory example illustrates how to deploy a 2 Postgres nodes composed of 1 primary node, 1 standby node and 1 witness node:

all:
  children:
    primary:
      hosts:
        primary1:
          ansible_host: 192.168.122.1
          private_ip: 10.0.0.1
    standby:
      hosts:
        standby1:
          ansible_host: 192.168.122.2
          private_ip: 10.0.0.2
          upstream_node_private_ip: 10.0.0.1
          replication_type: asynchronous
    witness:
      hosts:
        witness1:
          init_dbserver: true
          ansible_host: 192.168.122.3
          private_ip: 10.0.0.3
          upstream_node_private_ip: 10.0.0.1

How to include the setup_repmgr role in your Playbook

Below is an example of how to include the setup_repmgr role:

---
- hosts: primary,standby,witness
  name: Install and configure Repmgr
  become: true
  gather_facts: yes

  collections:
    - edb_devops.edb_postgres

  pre_tasks:
    - name: Initialize the user defined variables
      set_fact:
        pg_type: "PG"
        pg_version: 14

        repmgr_failover: automatic
        repmgr_reconnect_attemps: 2
        repmgr_reconnect_interval: 2

  roles:
    - setup_repmgr

Database engines supported

Community PostgreSQL

Distribution 10 11 12 13 14
CentOS 7
Red Hat Linux 7
RockyLinux 8
Red Hat Linux 8
Ubuntu 20.04 LTS (Focal) - x86_64
Debian 9 (Stretch) - x86_64
Debian 10 (Buster) - x86_64
  • ✅ - Tested and supported
  • ❌ - Not supported

Playbook execution examples

# To deploy community Postgres version 14 on CentOS8 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"

License

BSD

Author information

Author:

  • Julien Tachoires (@jt-edb)