DEV Community

Roman Chudov
Roman Chudov

Posted on

Ansible Playbook for PostgreSQL Patroni Cluster

I've recently published an Ansible playbook for deploying a PostgreSQL high-availability cluster powered by Patroni, with all the essential components included. It's a ready-to-go setup for development and testing environments.

๐Ÿ”ง Whatโ€™s inside:

  • PostgreSQL 16 with Patroni for automatic failover
  • etcd for distributed state management
  • PgBouncer for connection pooling
  • HAProxy for routing between master and replicas
  • Keepalived for floating Virtual IP
  • Node Exporter + Postgres Exporter for monitoring

๐Ÿงฉ Architecture:
Client โ†’ Keepalived VIP โ†’ HAProxy โ†’ PgBouncer โ†’ PostgreSQL

๐Ÿš€ The setup is simple: define your servers in inventory.ini, set a few variables, and run make up. In just a few minutes, youโ€™ll have a fully working Patroni cluster ready for testing or experimentation.

โš ๏ธ Disclaimer: This is a dev/test configuration. Donโ€™t use it in production without proper hardening (passwords, TLS, firewalls, limited SSH, etc).

๐Ÿ‘‰ GitHub: https://github.com/rom8726/ansible-patroni

Top comments (0)