Run Playbooks with Ansible
Pigsty uses Ansible to deploy and manage clusters. Ansible applies declarative configuration through playbooks. Pigsty module playbooks use idempotent tasks to reach the specified configuration.
For a single-node installation, use deploy.yml.
Other built-in playbooks perform specific module operations.
Ansible knowledge helps you manage Pigsty, but the single-node procedure does not require it.
Deploy Playbook
The deploy.yml playbook applies the core deployment configuration.
It includes the CA, software repository, NODE, INFRA, ETCD, PGSQL, and MINIO when the inventory enables them.
Optional modules such as Redis, Kafka, and native MySQL require their own playbooks.
Defining these optional modules in the inventory does not add them to deploy.yml.
The table shows the module deployment targets:
| Playbook | Command | Group | infra | [nodes] | etcd | minio | [pgsql] |
|---|---|---|---|---|---|---|---|
infra.yml | ./infra.yml | -l infra | ✓ | ✓ | |||
node.yml | ./node.yml | ✓ | ✓ | ✓ | ✓ | ||
etcd.yml | ./etcd.yml | -l etcd | ✓ | ||||
minio.yml | ./minio.yml | -l minio | ✓ | ||||
pgsql.yml | ./pgsql.yml | ✓ |
You can apply the core configuration in one run with deploy.yml.
For deployment in stages, follow the Customization Guide.
Install Ansible
The Pigsty installation script installs Ansible and its dependencies. The offline bootstrap procedure can also install them.
To install Ansible manually, use the command for your operating system.
The minimum supported Ansible version is 2.9.
The EL 10 EPEL repository does not yet supply all required Ansible packages. The Pigsty PGSQL repository supplies the additional packages.
On macOS, install Ansible with Homebrew. You can use the Mac as an administration node for remote cloud servers. This method is suitable for personal single-node deployments. For production, use a Linux administration node.
Execute Playbook
Ansible playbooks are executable YAML files with task definitions.
Make sure that ansible-playbook is available through your PATH environment variable.
The command ./node.yml runs ansible-playbook node.yml.
Use these four arguments to control execution:
| Purpose | Parameter | Description |
|---|---|---|
| Target | -l|--limit <pattern> | Limit execution to specific groups/hosts/patterns |
| Tasks | -t|--tags <tags> | Only run tasks with specific tags |
| Params | -e|--extra-vars <vars> | Extra command-line parameters |
| Config | -i|--inventory <path> | Use a specific inventory file |
Limit Hosts
Use -l|--limit <selector> to select the target hosts or groups.
The selector can contain an IP address, group name, or pattern.
See the Ansible host and group patterns for the selection rules.
Most playbooks target all applicable inventory hosts if you omit --limit.
Specify the target before you run a playbook that changes an existing deployment.
Limit Tasks
Use -t|--tags <tags> to select tasks by tag.
This limits execution to the selected tasks instead of the complete playbook:
To select multiple tags, separate them with commas:
Extra Vars
Use -e|--extra-vars KEY=VALUE to override configuration parameters for one run.
These variables have the highest variable precedence.
You can supply -e more than once:
For lists, objects, or multiple variables, supply a JSON string:
Specify Inventory
The default inventory is pigsty.yml in the Pigsty source directory.
Use -i <path> to select a different inventory file:
To change the default permanently, edit inventory in ansible.cfg.
Convenience Scripts
The bin/ directory contains scripts for common operations.
Each script calls an Ansible playbook with the necessary arguments:
Use these scripts when their operation matches your task.
Playbook List
The table lists the built-in playbooks. You can add your own playbooks or change their tasks for your deployment requirements.
| Module | Playbook | Function |
|---|---|---|
| INFRA | deploy.yml | One-click deploy Pigsty on current node |
| INFRA | infra.yml | Initialize Pigsty infrastructure on infra nodes |
| INFRA | infra-rm.yml | Remove infrastructure components from infra nodes |
| INFRA | cache.yml | Create offline packages from target node |
| INFRA | cert.yml | Issue certificates using Pigsty self-signed CA |
| NODE | node.yml | Initialize node, adjust to desired state |
| NODE | node-rm.yml | Remove node from Pigsty |
| PGSQL | pgsql.yml | Initialize HA PostgreSQL cluster or add replica |
| PGSQL | pgsql-rm.yml | Remove PostgreSQL cluster or replica |
| PGSQL | pgsql-db.yml | Add new business database to existing cluster |
| PGSQL | pgsql-user.yml | Add new business user to existing cluster |
| PGSQL | pgsql-pitr.yml | Perform point-in-time recovery on cluster |
| PGSQL | pgsql-monitor.yml | Monitor remote PostgreSQL with local exporter |
| PGSQL | pgsql-migration.yml | Generate migration manual and scripts |
| PGSQL | slim.yml | Install Pigsty with minimal components |
| REDIS | redis.yml | Initialize Redis cluster/node/instance |
| REDIS | redis-rm.yml | Remove Redis cluster/node/instance |
| ETCD | etcd.yml | Initialize ETCD cluster or add new member |
| ETCD | etcd-rm.yml | Remove ETCD cluster/data or shrink member |
| MINIO | minio.yml | Initialize a Silo object-storage cluster |
| MINIO | minio-rm.yml | Remove Silo, its configuration, and optional data |
| DOCKER | docker.yml | Install Docker on nodes |
| DOCKER | app.yml | Install applications using Docker Compose |
| JUICE | juice.yml | Install and configure JuiceFS |
| VIBE | vibe.yml | Install the Vibe coding environment |
| KAFKA | kafka.yml | Create or converge a Kafka dynamic KRaft cluster |
| KAFKA | kafka-rm.yml | Remove a Kafka cluster or member |
| MYSQL (Pilot) | mysql.yml | Deploy native MySQL 8.4 standalone or three-node clusters |
| MYSQL (Pilot) | mysql-rm.yml | Stop and retire native MySQL while retaining local state |
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)