Skip to content

jayesh68088/postgres-ha-deployment-automation

Repository files navigation

Postgres HA Deployment Automation

edb-deployment is a Python-based automation toolkit for provisioning and deploying PostgreSQL / EDB Postgres Advanced Server environments across public cloud, bare metal, and local virtualization targets.

For recruiter review, this repository demonstrates:

  • enterprise database engineering exposure
  • replication and HA deployment patterns
  • Linux and shell automation depth
  • Infrastructure as Code and DevOps workflows
  • cloud readiness across AWS, Azure, and Google Cloud

Why This Project Matters

This is not a toy CRUD app. The codebase coordinates multiple infrastructure and deployment layers:

  • spec-driven environment definition
  • Terraform generation and execution
  • Ansible-based software rollout
  • optional tpaexec orchestration for Always-On / PoT paths
  • inventory generation, SSH automation, password handling, and state tracking
  • functional validation of live database services and HA components

Key Features

  • Supports AWS, Azure, Google Cloud, bare metal, VMware Workstation, and VirtualBox deployment targets
  • Handles PostgreSQL, EPAS, and managed-database support flows for RDS/Aurora, Azure Database for PostgreSQL, and Google Cloud SQL
  • Encodes multiple reference architectures including single-node, synchronous replication, Pgpool-II, and BDR-oriented Always-On topologies
  • Automates PEM, Barman, EFM, Pgpool-II, pgbouncer, and HARP deployment where the selected architecture requires them
  • Produces repeatable project workspaces under ~/.edb-deployment
  • Includes a real functional test harness using Docker, Testinfra, and SSH-based service validation

Architecture Overview

flowchart TD
    A[CLI input] --> B[Commander]
    B --> C[Project subclass]
    C --> D[Merge default spec and user overrides]
    D --> E[Write ansible_vars.json and terraform_vars.json]
    E --> F[Render edb-terraform project]
    F --> G[terraform init/apply]
    G --> H[servers.yml outputs]
    H --> I[Render inventory.yml and ssh_config]
    I --> J[ansible-playbook or tpaexec deploy]
    J --> K[Inventory, passwords, and operations output]
Loading

More detail: docs/architecture.md

Tech Stack

  • Python
  • Terraform
  • Ansible
  • TPAexec
  • Jinja2
  • PyYAML
  • AWS CLI
  • Azure CLI
  • Google Cloud SDK
  • Bash / shell scripting
  • Docker / Testinfra for functional validation

Setup

Install dependencies:

python -m pip install -r requirements.txt
python -m pip install -e .

Run a no-cloud smoke test:

python scripts/smoke_test.py

Full setup guide: docs/setup.md

How To Run

Inspect default specs:

edb-deployment aws specs

Configure an AWS HA project:

edb-deployment aws configure pgdemo \
  --reference-architecture EDB-RA-2 \
  --os RockyLinux8 \
  --pg-type PG \
  --pg-version 14 \
  --efm-version 4.6 \
  --aws-region us-east-2 \
  --ssh-pub-key ~/.ssh/id_rsa.pub \
  --ssh-private-key ~/.ssh/id_rsa \
  --edb-credentials "<username>:<password>"

Provision and deploy:

edb-deployment aws provision pgdemo
edb-deployment aws deploy pgdemo
edb-deployment aws display pgdemo

More examples: docs/usage.md

Operations

Common day-2 commands:

edb-deployment aws logs pgdemo
edb-deployment aws passwords pgdemo
edb-deployment aws ssh pgdemo pg1
edb-deployment aws destroy pgdemo
edb-deployment aws remove pgdemo

Operations runbook: docs/operations.md

Project Structure

.
├── edbdeploy/                  # Python package, cloud/project orchestration, wrappers
├── edbdeploy/data/ansible/     # Reference architecture playbooks and roles
├── tests/                      # Docker-based functional validation
├── scripts/                    # Repo smoke tests and helper utilities
├── docs/                       # Architecture, setup, usage, operations, recruiter docs
├── VMWARE.md                   # VMware-specific notes
├── VIRTUALBOX.md               # VirtualBox-specific notes
└── README-WIN.md               # Windows / WSL notes

Screenshots / Visuals

  • Existing asset: imgs/github_branches.png
  • Additional architecture visual is embedded above in Mermaid for GitHub rendering

Validation Strategy

  • python scripts/smoke_test.py for fast, no-cloud CLI validation
  • tests/run.sh for live functional runs against real infrastructure
  • Testinfra checks validate service status, sockets, replication state, Barman, EFM, Pgpool-II, HARP, and pgbouncer behavior where applicable

Learning Outcomes

  • Translating deployment requirements into reusable infrastructure specifications
  • Combining Terraform, Ansible, and Python orchestration instead of treating them as separate silos
  • Modeling HA Postgres topologies with operational concerns such as failover, backups, monitoring, routing, and SSH access
  • Packaging a complex automation repo into recruiter-friendly documentation without overstating unsupported capabilities

Possible Enhancements

These are not claims about current functionality. They are honest extension ideas based on the existing scope.

  • Add CI smoke testing for parser/spec validation on every pull request
  • Expand automated coverage for list, display, show, and managed-database paths
  • Add provider-specific examples for Azure Database and Cloud SQL operations
  • Add JSON schema exports or typed config validation for user spec files
  • Introduce structured logging or log summarization for long-running cloud workflows

Documentation Index

Provenance And License

This repository retains the original BSD-style EnterpriseDB license and attribution because the local project is derived from that upstream open-source codebase. The packaging, documentation, publication hygiene, and validation improvements in this repository were added without changing the underlying license.

About

Spec-driven PostgreSQL / EPAS deployment automation across cloud, bare metal, and local HA lab environments

Topics

Resources

License

Unknown, Unknown licenses found

Licenses found

Unknown
LICENSE
Unknown
LICENSE.md

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors