Customize Pigsty with Configuration
Besides using the configuration wizard to auto-generate configs, you can write Pigsty config files from scratch. This tutorial guides you through building a complex inventory step by step.
If you define NODE, INFRA, ETCD, MINIO, and PGSQL in the inventory upfront, deploy.yml can deploy this core path in one run—but it hides the details. Optional modules such as Docker, Redis, Kafka, native MySQL, JUICE, and VIBE require their own playbooks.
This doc breaks down all modules and playbooks, showing how to incrementally build from a simple config to a complete deployment.
Minimal Configuration
The simplest valid config only defines the admin_ip variable—the IP address of the node where Pigsty is installed (admin node):
This config deploys nothing, but running ./deploy.yml generates a self-signed CA in files/pki/ca for issuing certificates.
For convenience, you can also set region to specify which region’s software mirrors to use (default, china, europe).
Add Nodes
Pigsty’s NODE module manages cluster nodes. Any IP address in the inventory will be managed by Pigsty with the NODE module installed.
We added two global parameters:
node_repo_modules specifies repos to add;
region specifies which region’s mirrors to use.
These parameters enable the node to use correct repositories and install required packages. The NODE module offers many customization options: node names, DNS, repos, packages, NTP, kernel params, tuning templates, monitoring, log collection, etc. Even without changes, the defaults are sufficient.
Run deploy.yml or more precisely node.yml to bring the defined node under Pigsty management.
Add Infrastructure
A full-featured RDS cloud database service needs infrastructure support: monitoring (metrics/log collection, alerting, visualization), NTP, DNS, and other foundational services.
Define a special group infra to deploy the INFRA module:
We also assigned an identity parameter: infra_seq to distinguish nodes in multi-node HA INFRA deployments.
Run infra.yml to install INFRA **](/docs/infra/) and [**NODE modules on 10.10.10.10:
NODE module is implicitly defined as long as an IP exists. NODE is idempotent—re-running has no side effects.
After completion, you’ll have complete observability infrastructure and node monitoring, but PostgreSQL database service is not yet deployed.
If your goal is just to set up this monitoring system (Grafana + Victoria), you’re done! The infra template is designed for this.
Everything in Pigsty is modular: you can deploy only monitoring infra without databases;
or vice versa—run HA PostgreSQL clusters without infra—Slim Install.
Deploy Database Cluster
To provide PostgreSQL service, install the PGSQL` module and its dependency ETCD—just two lines of config:
We added two new groups: etcd and pg-meta, defining a single-node etcd cluster and a single-node PostgreSQL cluster.
Use ./deploy.yml to converge the defined modules in the core path again, or deploy incrementally:
PGSQL depends on ETCD for HA consensus, so install ETCD first. After completion, you have a working PostgreSQL service!
| ID | NODE | INFRA | ETCD | PGSQL | Description |
|---|---|---|---|---|---|
| 1 | 10.10.10.10 |
infra-1 |
etcd-1 |
pg-meta-1 |
Add etcd and PostgreSQL cluster |
We used node.yml, infra.yml, etcd.yml, and pgsql.yml to deploy all four core modules on a single machine.
Define Databases and Users
In Pigsty, you can customize PostgreSQL cluster internals like databases and users through the inventory:
pg_users: Defines a new userdbuser_metawith passwordDBUser.Metapg_databases: Defines a new databasemetawith Pigsty CMDB schema (optional) andvectorextension
Pigsty offers rich customization parameters covering all aspects of databases and users.
If you define these parameters upfront, they’re automatically created during ./pgsql.yml execution.
For existing clusters, you can incrementally create or modify users and databases:
Configure PG Version and Extensions
You can install different major versions of PostgreSQL, and up to 575 extensions. Let’s remove the current default PG 18 and install PG 16:
We can customize parameters to install and enable common extensions by default: timescaledb, postgis, and pgvector:
pg_extensions: Installtimescaledb,postgis,pgvectorextensions.pg_libs: Configure loadingtimescaledb,pg_stat_statements,auto_explaindynamic libraries.pg_databases: Create and enablevector,postgis,timescaledbextensions for themetadatabase.
Add More Nodes
Add more nodes to the deployment, bring them under Pigsty management, deploy monitoring, configure repos, install software…
Deploy HA PostgreSQL Cluster
Now deploy a new database cluster pg-test on the three newly added nodes, using a three-node HA architecture:
Deploy Redis Cluster
Pigsty provides optional Redis support as a caching service in front of PostgreSQL:
Redis HA requires cluster mode or sentinel mode. See Redis Configuration.
Deploy Silo Object Storage
Pigsty’s MINIO module currently deploys Silo S3-compatible object storage, which can serve as a PostgreSQL backup repository. The module, inventory group, and playbooks retain the compatible minio name.
Serious production Silo deployments typically require at least 4 nodes with 4 disks each (4N/16D).
Deploy Docker Module
If you want to use containers to run tools for managing PG or software using PostgreSQL, install the DOCKER module:
Use pre-made application templates to launch common software tools with one click, such as the GUI tool for PG management: Pgadmin:
You can even self-host enterprise-grade Supabase with Pigsty, using external HA PostgreSQL clusters as the foundation and running stateless components in containers.