Playbooks

Built-in Ansible playbooks in Pigsty

Pigsty uses idempotent Ansible playbooks for management and control. Running playbooks requires ansible-playbook to be in the system PATH; users must first install Ansible before executing playbooks.

Available Playbooks

ModulePlaybookPurpose
INFRAinstall.ymlOne-click Pigsty installation
INFRAinfra.ymlInitialize Pigsty infrastructure on infra nodes
INFRAinfra-rm.ymlRemove infrastructure components from infra nodes
INFRAcache.ymlCreate offline installation packages from target nodes
INFRAcert.ymlIssue certificates using Pigsty self-signed CA
NODEnode.ymlInitialize nodes, configure to desired state
NODEnode-rm.ymlRemove nodes from Pigsty
PGSQLpgsql.ymlInitialize HA PostgreSQL cluster, or add new replica
PGSQLpgsql-rm.ymlRemove PostgreSQL cluster, or remove replica
PGSQLpgsql-db.ymlAdd new business database to existing cluster
PGSQLpgsql-user.ymlAdd new business user to existing cluster
PGSQLpgsql-pitr.ymlPerform point-in-time recovery (PITR) on cluster
PGSQLpgsql-monitor.ymlMonitor remote PostgreSQL using local exporters
PGSQLpgsql-migration.ymlGenerate migration manual and scripts for PostgreSQL
PGSQLslim.ymlInstall Pigsty with minimal components
REDISredis.ymlInitialize Redis cluster/node/instance
REDISredis-rm.ymlRemove Redis cluster/node/instance
ETCDetcd.ymlInitialize ETCD cluster, or add new member
ETCDetcd-rm.ymlRemove ETCD cluster, or remove existing member
MINIOminio.ymlInitialize MinIO cluster
MINIOminio-rm.ymlRemove MinIO cluster
DOCKERdocker.ymlInstall Docker on nodes
DOCKERapp.ymlInstall applications using Docker Compose
FERRETmongo.ymlInstall Mongo/FerretDB on nodes

Deployment Strategy

The install.yml playbook orchestrates specialized playbooks in the following group order for complete deployment:

  • infra: infra.yml (-l infra)
  • nodes: node.yml
  • etcd: etcd.yml (-l etcd)
  • minio: minio.yml (-l minio)
  • pgsql: pgsql.yml

Circular Dependency Note: There is a weak circular dependency between NODE and INFRA: to register NODE to INFRA, INFRA must already exist; while INFRA module depends on NODE to work. The solution is to initialize infra nodes first, then add other nodes. To complete all deployment at once, use install.yml.


Safety Notes

Most playbooks are idempotent, which means some deployment playbooks may wipe existing databases and create new ones when protection options are not enabled. Use extra caution with pgsql, minio, and infra playbooks. Read the documentation carefully and proceed with caution.

Best Practices

  1. Read playbook documentation carefully before execution
  2. Press Ctrl-C immediately to stop when anomalies occur
  3. Test in non-production environments first
  4. Use -l parameter to limit target hosts, avoiding unintended hosts
  5. Use -t parameter to specify tags, executing only specific tasks

Dry-Run Mode

Use --check --diff options to preview changes without actually executing:

# Preview changes without execution
./pgsql.yml -l pg-test --check --diff

# Check specific tasks with tags
./pgsql.yml -l pg-test -t pg_config --check --diff

Last modified 2026-01-06: batch update (cc9e058)