Ansible Deployment
The ansible/ directory in the pgcli repository turns the CLI into a
declarative deployment tool. Instead of running pg create, pg addon install and pg ha create by hand on every host, you describe the desired
state in group_vars/ and run one playbook. Re-running the playbook converges
the hosts to that state and is safe to repeat.
What it manages
| Resource | Ansible input | Role |
|---|---|---|
pg binary, podman, host config |
pgcli_* variables in group_vars/all |
pgcli |
| PostgreSQL instances and read-only replicas | pgcli_instances |
pg_instance |
| Host processes (webhook receivers, …) | pgcli_daemons |
pg_daemon |
| Add-ons (etcd, pgbouncer, MinIO, …) | pgcli_addons |
pg_addon |
| Patroni HA clusters and their etcd DCS | pg_ha_clusters, pgcli_addons (etcd) |
pg_ha, pg_addon |
| HAProxy in front of HA clusters | pg_ha_haproxy |
pg_ha_haproxy |
| Standalone S3-compatible stores for backups | pgcli_s3_* |
pg_s3 |
pg http file servers for offline asset distribution |
pgcli_http_servers |
pg_http |
Every mutating task is guarded by the current pgcli config and container
state, so an unchanged host reports ok rather than changed.
Business scenarios are separated by inventory group and group_vars file:
standalone, same-host replica, cross-host replica, instance plus add-ons,
Patroni HA, S3 storage, and per-type add-on groups. Enable one scenario group
at a time; Setup has the mapping table.
Repository layout
Pages
| Page | What it covers |
|---|---|
| Quick deploy | Copy-paste commands: one host, one standalone instance, from clone to pg list |
| Setup and example files | Which *.example file becomes which live file, hosts.ini groups, group_vars fields, first run |
| Offline and air-gapped installs | LAN HTTP server: image manifest and lazy loading, pg/podman binaries, runtime host binaries and DocumentDB DEBs |
| Offline image server | Export all images from pgcli_images with export-images.sh, serve them with pg http, wire up Ansible |
| HTTP file server | The pg_http role and deploy-http.yaml: every pg http parameter (TLS, auth, write modes, autostart) plus offline binary sync |
| Egress proxy | Forward proxy for isolated data centers: Privoxy add-on, global variables, NO_PROXY, manual SSH usage, verification |
| Playbooks | ping.yaml, apply.yaml, resources.yaml, deploy-s3.yaml, ha-status.yaml, passwords.yaml: tags, --limit, idempotency, lifecycle orders |
| Instances and replicas | The single/samehost/crosshost example files and every pgcli_instances field |
| Observability deployment | Monitoring and alerting for many machines: exporters, Prometheus, rules, Alertmanager, webhook daemon, Grafana |
| Add-ons | addon_<type>_<mode> entries: install/remove, instance-scoped add-ons, etcd |
| Add-on clusters | Multi-host add-on clusters: one inventory group per type, shared secrets/CA, quorum layouts, lifecycle |
| HA clusters | ha_etcd/ha_cluster example files, pg_ha_clusters, HAProxy, state-driven destroy |
| S3 storage | Store-type example files, deploy-s3.yaml options, using the store as a backup target |
Copy-paste commands to deploy one standalone PostgreSQL instance on one host
Turn the shipped *.example files into a working Ansible inventory and variable set, then verify connectivity
Serve container images, the pg binary, the podman launcher and runtime downloads (host binaries and DEBs) from a LAN HTTP server
Route installs, downloads and extension builds through a forward proxy in an isolated data center
Export every container image on a connected host and serve the tarballs over HTTP for air-gapped installs driven by pgcli_images
Manage pg http file servers declaratively with the pg_http role and deploy-http.yaml: directories, write modes, TLS, Basic Auth, autostart, and offline binary distribution
How to run apply.yaml, ping.yaml, resources.yaml, deploy-s3.yaml, ha-status.yaml and passwords.yaml — play order, tags, limits, idempotency and lifecycle orders
Configure the single, samehost and crosshost example files — every pgcli_instances field, namespaces and state semantics
Manage many machines with one declarative Ansible scenario: node and PostgreSQL exporters, Prometheus, alert rules, Alertmanager, and a pg daemon webhook receiver
Configure addon_
Deploy multi-host add-on clusters with one inventory group per type — shared secrets and TLS material, quorum layouts and lifecycle
Configure the ha_etcd and ha_cluster example files — shared etcd DCS, Patroni clusters, HAProxy, and state-driven destroy
Deploy a standalone MinIO, silo or rustfs store with deploy-s3.yaml and use it as the pgBackRest backup target