Playbooks

Overview and navigation of Pigsty preset playbooks

Pigsty provides a series of Ansible playbooks for automated deployment and management of various modules. This page provides navigation and summary of all playbooks.


Module Navigation

ModuleDescription
INFRA3Infrastructure module playbooks
NODE2Node management module playbooks
ETCD2ETCD cluster management playbooks
PGSQL7PostgreSQL cluster management playbooks
REDIS2Redis cluster management playbooks
MINIO2MinIO object storage management playbooks
FERRET1FerretDB management playbook
DOCKER1Docker management playbook

Playbook Summary

The following table lists all available preset playbooks in Pigsty:

PlaybookModuleFunction
deploy.ymlADMINDeploy pigsty on current environment
infra.ymlINFRAInitialize pigsty infrastructure on infra nodes
infra-rm.ymlINFRARemove infrastructure components from infra nodes
node.ymlNODEManage nodes, adjust nodes to desired state
node-rm.ymlNODERemove managed nodes from Pigsty
etcd.ymlETCDInstall and configure Etcd cluster
etcd-rm.ymlETCDRemove Etcd cluster or members
pgsql.ymlPGSQLInitialize PostgreSQL cluster or add new replicas
pgsql-rm.ymlPGSQLRemove PostgreSQL cluster or instance
pgsql-user.ymlPGSQLAdd new business users to existing PostgreSQL cluster
pgsql-db.ymlPGSQLAdd new business databases to existing PostgreSQL cluster
pgsql-monitor.ymlPGSQLMonitor remote PostgreSQL instances
pgsql-migration.ymlPGSQLGenerate migration manuals and scripts for existing PostgreSQL clusters
pgsql-pitr.ymlPGSQLExecute PostgreSQL Point-in-Time Recovery (PITR)
redis.ymlREDISInitialize Redis cluster/node/instance
redis-rm.ymlREDISRemove Redis cluster/node/instance
minio.ymlMINIOInstall MinIO cluster
minio-rm.ymlMINIORemove MinIO cluster
mongo.ymlFERRETInstall FerretDB on nodes
docker.ymlDOCKERInstall Docker Daemon and Docker Compose

Playbook Usage Notes

Protection Mechanism

Multiple modules provide deletion protection through *_safeguard parameters:

  • PGSQL: pg_safeguard prevents accidental deletion of PostgreSQL clusters
  • ETCD: etcd_safeguard prevents accidental deletion of Etcd clusters
  • MINIO: minio_safeguard prevents accidental deletion of MinIO clusters

By default, these safeguard parameters are not enabled (undefined). It’s recommended to explicitly set them to true for initialized clusters in production environments.

When the protection switch is set to true, the corresponding *-rm.yml playbook will abort immediately. You can force override through command-line parameters:

./pgsql-rm.yml -l pg-test -e pg_safeguard=false
./etcd-rm.yml -e etcd_safeguard=false
./minio-rm.yml -l minio -e minio_safeguard=false

Limiting Execution Scope

When executing playbooks, it’s recommended to use the -l parameter to limit the execution scope:

./pgsql.yml -l pg-meta            # Limit execution to pg-meta cluster
./node.yml -l 10.10.10.10         # Limit execution to specific node
./redis.yml -l redis-test         # Limit execution to redis-test cluster

Idempotency

Most playbooks are idempotent and can be executed repeatedly. However, note:

  • infra.yml does not clear data by default and can be safely re-executed. All clean parameters (vmetrics_clean, vlogs_clean, vtraces_clean, grafana_clean, nginx_clean) default to false
  • To clear infrastructure data for rebuild, you need to explicitly set the corresponding clean parameter to true
  • Be extra careful when repeatedly executing *-rm.yml deletion playbooks

Task Tags

You can use the -t parameter to execute only specific task subsets:

./pgsql.yml -l pg-test -t pg_service    # Only refresh pg-test cluster services
./node.yml -t haproxy                   # Only set up haproxy on nodes
./etcd.yml -t etcd_launch               # Only restart etcd service

Quick Command Reference

./deploy.yml                     # One-pass deployment

INFRA Module

./infra.yml                      # Initialize infrastructure
./infra-rm.yml                   # Remove infrastructure

NODE Module

./node.yml -l <cls|ip>           # Add node
./node-rm.yml -l <cls|ip>        # Remove node
bin/node-add <cls|ip>            # Add node (wrapper script)
bin/node-rm <cls|ip>             # Remove node (wrapper script)

ETCD Module

./etcd.yml                       # Initialize etcd cluster
./etcd-rm.yml                    # Remove etcd cluster
bin/etcd-add <ip>                # Add etcd member (wrapper script)
bin/etcd-rm <ip>                 # Remove etcd member (wrapper script)

PGSQL Module

./pgsql.yml -l <cls>                            # Initialize PostgreSQL cluster
./pgsql-rm.yml -l <cls>                         # Remove PostgreSQL cluster
./pgsql-user.yml -l <cls> -e username=<user>    # Create business user
./pgsql-db.yml -l <cls> -e dbname=<db>          # Create business database
./pgsql-monitor.yml -e clsname=<cls>            # Monitor remote cluster
./pgsql-pitr.yml -l <cls> -e '{"pg_pitr": {}}'  # Execute PITR recovery
bin/pgsql-add <cls>              # Initialize cluster (wrapper script)
bin/pgsql-rm <cls>               # Remove cluster (wrapper script)
bin/pgsql-user <cls> <user>      # Create user (wrapper script)
bin/pgsql-db <cls> <db>          # Create database (wrapper script)

REDIS Module

./redis.yml -l <cls>             # Initialize Redis cluster
./redis-rm.yml -l <cls>          # Remove Redis cluster

MINIO Module

./minio.yml -l <cls>             # Initialize MinIO cluster
./minio-rm.yml -l <cls>          # Remove MinIO cluster

FERRET Module

./mongo.yml -l ferret            # Install FerretDB

DOCKER Module

./docker.yml -l <host>           # Install Docker

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