Configuration
Pigsty is a “configuration-driven” PostgreSQL platform: all behaviors come from the combination of inventory files in ~/pigsty/conf/*.yml and PGSQL parameters.
Once you’ve written the configuration, you can replicate a customized cluster with instances, users, databases, access control, extensions, and tuning policies in just a few minutes.
Configuration Entry
- Prepare Inventory: Copy a
pigsty/conf/*.ymltemplate or write an Ansible Inventory from scratch, placing cluster groups (all.children.<cls>.hosts) and global variables (all.vars) in the same file. - Define Parameters: Override the required
PGSQLparameters in thevarsblock. The override order from global → cluster → host determines the final value. - Apply Configuration: Run
./configure -c <conf>orbin/pgsql-add <cls>and other playbooks to apply the configuration. Pigsty will generate the configuration files needed for Patroni/pgbouncer/pgbackrest based on the parameters.
Pigsty’s default demo inventory conf/pgsql.yml is a minimal example: one pg-meta cluster, global pg_version: 18, and a few business user and database definitions. You can expand with more clusters from this base.
Focus Areas & Documentation Index
Pigsty’s PostgreSQL configuration can be organized from the following dimensions. Subsequent documentation will explain “how to configure” each:
- Cluster & Instances: Define instance topology (standalone, primary-replica, standby cluster, delayed cluster, Citus, etc.) through
pg_cluster / pg_role / pg_seq / pg_upstream. - Kernel Version: Select the core version, flavor, and tuning templates using
pg_version,pg_mode,pg_packages,pg_extensions,pg_conf, and other parameters. - Users/Roles: Declare system roles, business accounts, password policies, and connection pool attributes in
pg_default_rolesandpg_users. - Database Objects: Create databases as needed using
pg_databases,baseline,schemas,extensions,pool_*fields and automatically integrate with pgbouncer/Grafana. - Access Control (HBA): Maintain host-based authentication policies using
pg_default_hba_rulesandpg_hba_rulesto ensure access boundaries for different roles/networks. - Privilege Model (ACL): Converge object privileges through
pg_default_privileges,pg_default_roles,pg_revoke_publicparameters, providing an out-of-the-box layered role system.
After understanding these parameters, you can write declarative inventory manifests as “configuration as infrastructure” for any business requirement. Pigsty will handle execution and ensure idempotency.
A Typical Example
The following snippet shows how to control instance topology, kernel version, extensions, users, and databases in the same configuration file:
- The
pg-analyticscluster contains one primary and one offline replica. - Global settings specify
pg_version: 18with a set of extension examples and loadolap.ymltuning. - Declare business objects in
pg_databasesandpg_users, automatically generating schema/extension and connection pool entries. - Additional
pg_hba_rulesrestrict access sources and authentication methods.
Modify and apply this inventory to get a customized PostgreSQL cluster without manual configuration.
Choose the appropriate instance and cluster types based on your requirements to configure PostgreSQL database clusters that meet your needs.
How to choose the appropriate PostgreSQL kernel and major version.
Pigsty provides a package alias translation mechanism that shields the differences in binary package details across operating systems, making installation easier.
How to define and customize PostgreSQL users and roles through configuration?
How to define and customize PostgreSQL databases through configuration?
Configuration reference for PostgreSQL and PgBouncer Host-Based Authentication (HBA) rules in Pigsty.
Configuration reference for Pigsty built-in roles, users, default privileges, and database ACLs.
Configure PostgreSQL parameters at cluster, instance, database, and user levels
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)