Skip to content

This repository provides an Ansible-based automation for deploying a highly available PostgreSQL cluster using Patroni, etcd, and ProxySQL. It is designed for production-grade PostgreSQL clusters with automated failover and load balancing.

Notifications You must be signed in to change notification settings

maasumiyaat/ha-postgres

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ansible PostgreSQL High Availability (HA) Cluster

This repository provides an Ansible-based automation for deploying a highly available PostgreSQL cluster using Patroni, etcd, and ProxySQL. It is designed for production-grade PostgreSQL clusters with automated failover and load balancing.

Features

  • Automated deployment of PostgreSQL HA cluster
  • Patroni for PostgreSQL high availability and failover
  • etcd for distributed consensus and configuration
  • ProxySQL for load balancing
  • Secure password management via Ansible variables
  • Customizable cluster and network settings

Directory Structure

├── inventory.yml           # Ansible inventory file
├── site.yml                # Main playbook
├── group_vars/
│   └── all.yml             # Global variables (PostgreSQL, authentication, etc.)
├── roles/
│   ├── common/             # Common setup tasks
│   ├── patroni/            # Patroni installation and configuration
│   ├── postgres/           # PostgreSQL installation and configuration
│   ├── proxysql/           # ProxySQL installation and configuration
│   └── verify/             # Cluster verification tasks
├── test_cluster.sh         # Script to test cluster status
├── test_failover.sh        # Script to test failover
└── readme.md               # This file

Getting Started

  1. Clone the repository:
    git clone <this-repo-url>
    cd ansible-postgres-ha
  2. Configure your inventory:
    • Edit inventory.yml to define your cluster nodes and their variables.
  3. Set variables:
    • Edit group_vars/all.yml for cluster-wide settings (PostgreSQL version, passwords, etc).
  4. Run the playbook:
    ansible-playbook -i inventory.yml site.yml
  5. Test the cluster:
    • Use test_cluster.sh and test_failover.sh to verify deployment and failover.

Security & Privacy Considerations

  • Passwords:
    • Default passwords are set in group_vars/all.yml. Change these before deploying to production or making the repository public.
    • Consider using Ansible Vault to encrypt sensitive variables (passwords, secrets).
  • Inventory:
    • Do not commit real IP addresses or sensitive hostnames to the public repository.
  • Secrets:
    • Remove or encrypt any secrets, tokens, or private keys before publishing.
  • Access Control:
    • Ensure only trusted users have access to your Ansible control node and inventory.

Recommendations Before Making Public

  • Change all default passwords in group_vars/all.yml.
  • Remove or anonymize inventory files (inventory.yml) if they contain real infrastructure details.
  • Use Ansible Vault for all sensitive variables.
  • Review all scripts and playbooks for hardcoded secrets or sensitive data.

License

Specify your license here (e.g., MIT, Apache 2.0, etc).


Maintainer: Your Name ([email protected])

About

This repository provides an Ansible-based automation for deploying a highly available PostgreSQL cluster using Patroni, etcd, and ProxySQL. It is designed for production-grade PostgreSQL clusters with automated failover and load balancing.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages