Configuration

Describe database and infra as code.

Pigsty treats Infra & Database as Code. You can describe the infrastructure & database clusters through a declarative interface. All your essential work is to describe your need in the inventory, then materialize it with a simple idempotent playbook.

Inventory

Each pigsty deployment has a corresponding config inventory. It could be stored in a local git-managed file in YAML format or dynamically generated from CMDB or any ansible compatible format. Pigsty uses a monolith YAML config file as the default config inventory, which is pigsty.yml, located in the pigsty home directory.

The inventory consists of two parts: global vars & multiple group definitions. You can define new clusters with inventory groups: all.children[array]. And describe infra and set global default parameters for clusters with global vars: all.vars[object]. Which may look like this:

  1. all: # Top-level object: all
  2. vars: {...} # Global Parameters
  3. children: # Group Definitions
  4. infra: # Group Definition: 'infra'
  5. hosts: {...} # Group Membership: 'infra'
  6. vars: {...} # Group Parameters: 'infra'
  7. etcd: {...} # Group Definition: 'etcd'
  8. pg-meta: {...} # Group Definition: 'pg-meta'
  9. pg-test: {...} # Group Definition: 'pg-test'
  10. redis-test: {...} # Group Definition: 'redis-test'
  11. # ...

Cluster

Each group may represent a cluster, which could be a Node cluster, PostgreSQL cluster, Redis cluster, Etcd cluster, or Minio cluster, etc… They all use the same format: group vars & hosts. You can define cluster members with all.children.<cls>.hosts[object] and describe cluster with cluster parameters in all.children.<cls>.vars[object]. Here is an example of 3 nodes PostgreSQL HA cluster named pg-test:

  1. pg-test: # Group Name
  2. vars: # Group Vars (Cluster Parameters)
  3. pg_cluster: pg-test
  4. hosts: # Group Host (Cluster Membership)
  5. 10.10.10.11: { pg_seq: 1, pg_role: primary } # Host1
  6. 10.10.10.12: { pg_seq: 2, pg_role: replica } # Host2
  7. 10.10.10.13: { pg_seq: 3, pg_role: offline } # Host3

You can also define parameters for a specific host, as known as host vars. It will override group vars and global vars. Which is usually used for assigning identities to nodes & database instances.

Parameter

Global vars, Group vars, and Host vars are dict objects consisting of a series of K-V pairs. Each pair is a named Parameter consisting of a string name as the key and a value of one of five types: boolean, string, number, array, or object. Check parameter reference for detailed syntax & semantics.

Every parameter has a proper default value except for mandatory IDENTITY PARAMETERS; they are used as identifiers and must be set explicitly, such as pg_cluster, pg_role, and pg_seq.

Parameters can be specified & overridden with the following precedence.

  1. Playbook Args > Host Vars > Group Vars > Global Vars > Defaults

For examples:

  • Force removing existing databases with Playbook CLI Args -e pg_clean=true
  • Override an instance role with Instance Level Parameter pg_role on Host Vars
  • Override a cluster name with Cluster Level Parameter pg_cluster on Group Vars.
  • Specify global NTP servers with Global Parameter node_ntp_servers on Global Vars
  • If no pg_version is set, it will use the default value from role implementation

Reference

Pigsty have 260+ parameters, check Parameter for details.

ModuleSectionDescriptionCount
INFRAMETAPigsty Metadata4
INFRACASelf-Signed CA3
INFRAINFRA_IDInfra Portals & Identity2
INFRAREPOLocal Yum Repo8
INFRAINFRA_PACKAGEInfra Packages2
INFRANGINXNginx Web Server6
INFRADNSDNSMASQ Nameserver3
INFRAPROMETHEUSPrometheus Stack16
INFRAGRAFANAGrafana Stack6
INFRALOKILoki Logging Service4
NODENODE_IDNode Identity Parameters5
NODENODE_DNSNode domain names & resolver5
NODENODE_PACKAGENode Repo & Packages5
NODENODE_TUNENode Tuning & Kernel features10
NODENODE_ADMINAdmin User & Credentials7
NODENODE_TIMENode Timezone, NTP, Crontabs5
NODEHAPROXYHAProxy the load balancer10
NODENODE_EXPORTERNode Monitoring Agent3
NODEPROMTAILPromtail logging Agent4
DOCKERDOCKERDocker Daemon4
ETCDETCDETCD DCS Cluster10
MINIOMINIOMINIO S3 Object Storage15
REDISREDISRedis the key-value NoSQL cache20
PGSQLPG_IDPG Identity Parameters11
PGSQLPG_BUSINESSPG Business Object Definition12
PGSQLPG_INSTALLInstall PG Packages & Extensions10
PGSQLPG_BOOTSTRAPInit HA PG Cluster with Patroni39
PGSQLPG_PROVISIONCreate in-database objects9
PGSQLPG_BACKUPSet Backup Repo with pgBackRest5
PGSQLPG_SERVICEExposing service, bind vip, dns9
PGSQLPG_EXPORTERPG Monitor agent for Prometheus15

Last modified 2023-02-27: add v2.0 images and docs (5b09f12)