PIGSTY

Inventory

The main config file for Pigsty

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

The configure script will generate the pigsty.yml file scaffold with good defaults according to your env and input, but it's OPTIONAL: you can always edit the pigsty.yml file directly as the tutorial shows.


Structure

The inventory consists of two parts: global vars & multiple groups. You can define new clusters in all.children. And describe infra with global vars: all.vars. Which may look like this:

all:                  # Top-level object: all
  vars: {...}         # Global Parameters
  children:           # Group Definitions
    infra:            # Group Definition: 'infra'
      hosts: {...}        # Group Membership: 'infra'
      vars:  {...}        # Group Parameters: 'infra'
    etcd:    {...}    # Group Definition: 'etcd'
    pg-meta: {...}    # Group Definition: 'pg-meta'
    pg-test: {...}    # Group Definition: 'pg-test'
    redis-test: {...} # Group Definition: 'redis-test'
    # ...

There are plenty of examples under conf/, which can also be used as templates during configure.


Cluster

Each ansible group may represent a cluster, which could be a Node cluster, PostgreSQL cluster, Redis cluster, Etcd cluster, or Minio cluster, etc…

Cluster definition consists of two parts: hosts & vars. You can define cluster members in <cls>.hosts and describe cluster with parameters in <cls>.vars. Here's an example of a 3-node HA PG cluster:

all:
  children:    # All Groups
    pg-test:   # Group Name
      hosts:   # Group Host (Cluster Membership)
        10.10.10.11: { pg_seq: 1, pg_role: primary } # Host1
        10.10.10.12: { pg_seq: 2, pg_role: replica } # Host2
        10.10.10.13: { pg_seq: 3, pg_role: offline } # Host3
      vars:    # Group Vars (Cluster Parameters)
        pg_cluster: pg-test

The vars in cluster level will override the global vars, and vars in host level will override the cluster vars and global vars.


Parameter

Parameters are key-value pairs that define all entities in the deployment. The key is a string name, and the value can be one of five types: boolean, string, number, array, or object.

And parameters can be set at different levels with the following precedence:

LevelLocationDescriptionPrecedence
CLI ArgsCommand Linevia -e cli param argHighest (5)
Host Vars<group>.hosts.<host>Parameters specific to a single hostHigh (4)
Group Vars<group>.varsParameters shared by hosts in a group/clusterMedium (3)
Global Varsall.varsParameters shared by all hostsLow (2)
Defaults<roles>/default/main.ymlRole implementation default valuesLowest (1)

Here are some examples about parameter precedence:

  • Force removing existing databases with Playbook CLI Args -e pg_clean=true
  • Override pg instance role with Instance Level Parameter pg_role on Host Vars
  • Override pg 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, pigsty will use the default value from role implementation (17 by default)

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 in above snippet.

Available parameters vary according to the modules:


Reference

Pigsty have 280+ parameters, check module parameters for details.

ModuleSectionDescriptionCount
INFRAMETAPigsty Metadata4
INFRACASelf-Signed CA3
INFRAINFRA_IDInfra Portals & Identity2
INFRAREPOLocal Software Repo9
INFRAINFRA_PACKAGEInfra Packages2
INFRANGINXNginx Web Server7
INFRADNSDNSMASQ Nameserver3
INFRAPROMETHEUSPrometheus Stack18
INFRAGRAFANAGrafana Stack6
INFRALOKILoki Logging Service4
NODENODE_IDNode Identity Parameters5
NODENODE_DNSNode domain names & resolver6
NODENODE_PACKAGENode Repo & Packages5
NODENODE_TUNENode Tuning & Kernel features10
NODENODE_ADMINAdmin User & Credentials7
NODENODE_TIMENode Timezone, NTP, Crontabs5
NODENODE_VIPNode Keepalived L2 VIP8
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