Configuration
Pigsty uses configuration to control PostgreSQL behavior.
This configuration combines inventory files in ~/pigsty/conf/*.yml with PGSQL parameters.
After you write the configuration, you can reproduce a customized cluster in a few minutes.
The configuration includes instances, users, databases, access control, extensions, and tuning policies.
Configuration Entry
- Prepare Inventory: Copy a
pigsty/conf/*.ymltemplate or write an Ansible inventory. Put cluster groups (all.children.<cls>.hosts) and global variables (all.vars) in the same file. - Define Parameters: Override the required
PGSQLparameters invars. The override order is global → cluster → host. The last applicable setting determines the value. - Apply Configuration: Use
./configure -c <conf>,bin/pgsql-add <cls>, and other playbooks to apply the configuration. Pigsty generates the required Patroni, PgBouncer, and pgBackRest files from these parameters.
The default demonstration inventory, conf/pgsql.yml, provides a minimal example.
It defines one pg-meta cluster, global pg_version: 18, and a few application users and databases.
You can add more clusters to this configuration.
Focus Areas & Documentation Index
Use the following pages to configure each part of a PostgreSQL deployment:
- 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.
Use these parameters to declare infrastructure in the inventory for your application requirements. Pigsty performs the operations and ensures idempotency.
A Typical Example
This example defines topology, kernel version, extensions, users, and databases in one 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.
Adjust and apply this inventory to create 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)