Skip to content

This is the multi-page printable view of this section. .

Return to the regular view of this page.

Preparation

Prepare resources for a serious deployment
Hardware
    Nodes, specs, disks, network, VIP, domain ...
Linux OS
    List of supported Linux OS distributions
Software
    Locale, Firewall, Ansible, Pigsty...
Admin
    User, Sudo, SSH, Accessibility...

You can leverage IaC tools such as Terraform and Vagrant to help you prepare the environment and do the chore.

Ansible
    Ansible 101, basic knowledge for pigsty users
Sandbox
    The four-node sandbox for learning & testing
Vagrant
    Provision local virtual machine with vagrant
Terraform
    Provision cloud servers with terraform

Here’s a checklist to help you prepare the environment for a serious Pigsty deployment in production environment.

Item Requirement Item Requirement
Node 1C1G at least, 2C2G recommended, no upper limit Spec 1 node at least, 2 for semi-HA, 3+ for real HA
Disk /data, main mount point, ext4 or xfs Network static intranet, IPv4 address, nice to have Internet access
VIP Reserve an L2 IP for VIP (OPTIONAL) Domain Use local / public domain names (OPTIONAL)
Kernel Linux, MacOS can be used as admin controller Distro EL (8/9), Debian (12), Ubuntu (22/24), x86_64 / aarch64
Locale C.UTF-8 or C Firewall port: 80 / 443 / 22 / 5432
User avoid using root & postgres Sudo nopass sudo privilege
SSH nopass via public key Accessible ssh <ip|alias> sudo ls works

1 - Hardware

Nodes, specs, disks, network, VIP, domain …

Node

Pigsty currently runs on nodes with Linux kernel and x86_64 / aarch64 architecture.

A “node” refers to a resource that is SSH accessible and offers a bare Linux OS environment. It could be a physical machine, a virtual machine, or an OS-like container equipped with systemd, sudo and sshd.

It requires at least 1 node to deploy pigsty, You can prepare more and setup everything in one-pass, or add them later. The minimum node spec requirement is 1C1G, it is recommended to use at least 2C2G. Higher is better, with no upper limit. Parameters will be automatically tuned based on available resource.

Use multiple nodes for production deployment

A functioning HA setup requires at least 3 nodes to work, or use 2 for a semi-HA setup


Spec

How many nodes do you need? It depends on your resource and your requirements.

Single Node Setup

The simplest setup with everything running on a single node, with four essential modules installed:

ID NODE PGSQL INFRA ETCD
1 node-1 pg-meta-1 infra-1 etcd-1

This setup can be used for production if external S3/MinIO is configured for backup/PITR.

Two Node Setup

A two-node setup enables database replication and semi-HA capabilities:

ID NODE PGSQL INFRA ETCD
1 node-1 pg-meta-1 (primary) infra-1 etcd-1
2 node-2 pg-meta-2 (replica)

While more robust than a single node setup, HA has limitations:

  • No automatic failover if node-1 fails - manual promotion of node-2 required
  • Automatic failover works if node-2 fails - node-1 gets promoted automatically

This “semi-HA” setup can only auto-recover from specific node failures.

Three Node Setup

A true HA setup that can automatically recover from any single node failure:

ID NODE PGSQL INFRA ETCD
1 node-1 pg-meta-1 infra-1 etcd-1
2 node-2 pg-meta-2 infra-2 etcd-2
3 node-3 pg-meta-3 infra-3 etcd-3
Four Node Setup

The standard demonstration environment used by Pigsty’s sandbox:

ID NODE PGSQL INFRA ETCD
1 node-1 pg-meta-1 infra-1 etcd-1
2 node-2 pg-test-1 etcd-2
3 node-3 pg-test-2 etcd-3
4 node-4 pg-test-3

Disk

Pigsty will use /data as the default data directory, if you have a dedicated main data disk, it is recommended to mount it there, and use /data1, /data2, /dataN for extra disk drivers.

Mount disks elsewhere?

If you are mounting it elsewhere, you’ll have to change the following parameters accordingly:

Name Description Default
node_data node main data directory /data
pg_fs_main postgres main data directory /data
pg_fs_backup postgres backup data directory /data/backups
etcd_data etcd data directory /data/etcd
prometheus_data prometheus data directory /data/prometheus
loki_data loki data directory /data/loki
minio_data minio data directory /data/minio
redis_fs_main redis data directory /data/redis

We recommend using ext4 or xfs as the filesystem for data disks. They have the best performance for PostgreSQL.

While ext4 has more tools for data recovery, xfs is more efficient for small files. If you are running MinIO, It’s recommended to use xfs, otherwise, ext4 is recommended as the default option.


Network

Pigsty requires static network to work, you should explicitly assign a fixed IPv4 address for each node.

Don't have a fixed IP?

The 127.0.0.1 could be used as a workaround in case of no fixed IP address in one-node installation.

The IP address will be used as the node’s unique identifier, it should be the primary IP address bind to the primary network interface used for internal network communications.

Never use Public IP as identifier

Using public IP addresses as node identifiers can cause security and connectivity issues.

L2 VIP require L2 Networking

To use the optional Node VIP and PG VIP features, ensure all nodes are located within the same L2 network

Internet access is required when performing the standard (online) installation. But pigsty can be offline installed via offline package, which does not require Internet access in this case.


VIP

Pigsty supports optional L2 VIP for NODE clusters (keepalived) and PGSQL clusters (vip-manager).

To use L2 VIP features, You have to explicitly assign an L2 VIP for them. It’s not a big deal when running on your own hardware, but may become an issue when working in a public cloud environment.


Domain

Pigsty using local static domain names for the following service with WebUI. You can assign your custom domain names to these services, or use real domain names. Just change them in the infra_portal.

Domain Name Port Component Description
h.pigsty home 80/443 Nginx Default server, local repo
g.pigsty grafana 3000 Grafana Monitoring & visualization
p.pigsty prometheus 9058 Prometheus Time series DB
a.pigsty alertmanager 9059 AlertManager Alert aggregation & routing

Domain names are optional, to use them, it is user’s responsibility to add the following records to your /etc/hosts file (local static resolution), Or add them to your DNS server / public DNS vendor.

10.10.10.10 h.pigsty g.pigsty p.pigsty a.pigsty

2 - Linux OS

List of compatible linux OS Distributions

Pigsty works well on EL9, U24, D12, Recommended OS: RockyLinux 9.6, Ubuntu 24.04.2, Debian 12.11

Distribution Arch Code PG18 PG17 PG16 PG15 PG14 PG13
RHEL9 / Rocky9 / Alma9 x86_64 el9.x86_64
RHEL9 / Rocky9 / Alma9 aarch64 el9.aarch64
Ubuntu 24.04 (noble) x86_64 u24.x86_64
Ubuntu 24.04 (noble) aarch64 u24.aarch64
Debian 12 (bookworm) x86_64 d12.x86_64
Debian 12 (bookworm) aarch64 d12.aarch64
EL 9.6 Recommended
Debian 12.11 Recommended
Ubuntu 24.04.2 Recommended

EL

Pigsty works on RHEL / Rocky / Alma / Anolis / CentOS 8, 9, 10.

EL Distribution Arch Code PG18 PG17 PG16 PG15 PG14 PG13
RHEL10 / Rocky10 / Alma10 x86_64 el10.x86_64
RHEL10 / Rocky10 / Alma10 aarch64 el10.aarch64
RHEL9 / Rocky9 / Alma9 x86_64 el9.x86_64
RHEL9 / Rocky9 / Alma9 aarch64 el9.aarch64
RHEL8 / Rocky8 / Alma8 x86_64 el8.x86_64
RHEL8 / Rocky8 / Alma8 aarch64 el8.aarch64
RHEL7 / CentOS7 x86_64 el7.x86_64
RHEL7 / CentOS7 aarch64 -
RockyLinux 9.6 Recommended
EL 7 EOL, EL8 nearing EOL

For extended support on legacy os, consider our pro subscription.


Ubuntu

Pigsty works on Ubuntu 24.04 / 22.04:

Ubuntu Distribution 架构 系统代码 PG18 PG17 PG16 PG15 PG14 PG13
Ubuntu 24.04 (noble) x86_64 u24.x86_64
Ubuntu 24.04 (noble) aarch64 u24.aarch64
Ubuntu 22.04 (jammy) x86_64 u22.x86_64
Ubuntu 22.04 (jammy) aarch64 u22.aarch64
Ubuntu 24.04.2 LTS Recommended

Debian

Pigsty works on Debian 12 / 13, we recommend using the latest Debian 12.11

Debian Distribution Arch Code PG18 PG17 PG16 PG15 PG14 PG13
Debian 13 (trixie) x86_64 d13.x86_64
Debian 13 (trixie) aarch64 d13.aarch64
Debian 12 (bookworm) x86_64 d12.x86_64
Debian 12 (bookworm) aarch64 d12.aarch64
Debian 11 (bullseye) x86_64 d11.x86_64
Debian 11 (bullseye) aarch64 -
Debian 12.11 Recommended
Debian 11 nearing EOL

For extended support on legacy os, consider our pro subscription.

3 - Software

Locale, Firewall, Ansible, Pigsty…

Linux

Pigsty runs on Linux Operating System, it supports 14 mainstream Linux distros: Compatible OS List

We recommend using RockyLinux 9.6, Debian 12.11, or Ubuntu 24.04.5 as the default OS options.

Run pigsty on macOS?

You can install pigsty on macOS, and initiate control from your local laptop with ansible. (use as admin node) But the database / infra / node / etcd services are still running on Linux nodes.

We strongly recommend using a clean installed OS environment with en_US set as the primary language.

How to enable en_US locale?

To ensure the en_US locale is available when using other primary language:

localedef -i en_US -f UTF-8 en_US.UTF-8
localectl set-locale LANG=en_US.UTF-8

Pigsty DOES NOT use containers, main components are packed for specific distro major version.

Use the same OS version on all nodes

Please use the same major and minor version of the OS on all nodes in a single deployment.


File System

Pigsty suggests using ext4 or xfs file systems, both of which have the best performance for PostgreSQL use cases. If you know what you are doing, you can also consider using file systems like zfs, but never run database services on network file systems like nfs.

If you need to use MinIO, it is recommended to use the xfs file system, which is the only file system recommended by MinIO. It performs better in scenarios with a large number of small files, but the tool ecosystem (e.g., data recovery) is slightly inferior to ext4.

The default recommendation for running standard PostgreSQL services is to use the ext4 file system.


Firewall

Your security policy and firewall setup should allow access to the required ports.

To access the WebUI services, you’ll have to allow the HTTP (80) / HTTPS (443) access.

To access the PostgreSQL database services, you’ll have to allow the 5432 port for postgres.

You may access postgres services via other ports
  • 5432: PostgreSQL database
  • 6432: Pgbouncer Connection Pooler
  • 5433: PG Primary Service
  • 5434: PG Replica Service
  • 5436: PG Default Service
  • 5438: PG Offline Service

If you are accessing the postgres services via other ports, allow them accordingly

In a typical public cloud VPS setup, port 22/80/443/5432 are usually opened.

Expose database ports with caution

Exposing database service ports directly to the Internet is very dangerous. If you need to do this, consider consulting Security Best Practices and proceed with caution.

In a typical production setup, port 22/80/443 are opened to DBA/OPS from LAN / Jumpserver. And other ports are accessed from intranet. You have to make sure they are opened internally: used ports.


Ansible

Pigsty uses Ansible to initiate control from admin node to all managed nodes.

You don’t need to care about details, ansible is installed during the Bootstrap stage.

Install Ansible Manually
sudo apt install -y ansible python3-jmespath
sudo dnf install -y ansible python3-jmespath
sudo dnf install -y ansible python3.12-jmespath
sudo yum install -y ansible python-jmespath
brew install ansible
pip3 install jmespath

Ansible is only required on admin node, you can run ansible on macOS to use your laptop as admin node.


Pigsty

(RECOMMENDED) You can get & extract the latest stable version of pigsty source with:

curl -fsSL https://repo.pigsty.io/get | bash -s v3.7.0; cd ~/pigsty
curl -fsSL https://repo.pigsty.cc/get | bash -s v3.7.0; cd ~/pigsty   # china mirror

To install a specific version, pass the version string as the first parameter:

curl -fsSL https://repo.pigsty.io/get | bash -s v3.7.0; cd ~/pigsty
curl -fsSL https://repo.pigsty.cc/get | bash -s v3.7.0; cd ~/pigsty # china mirror

You can also use git to clone the Pigsty source repo from GitHub:

clone the latest
git clone https://github.com/pgsty/pigsty.git; cd ~/pigsty; git checkout v3.7.0
Checkout a specific version before using

The default main branch may in an unstable development status, git checkout v3.7.0 before using.

$ curl -fssL https://repo.pigsty.cc/get | bash -s v3.7.0
[v3.7.0] ===========================================
$ curl -fsSL https://repo.pigsty.cc/get | bash -s v3.7.0
[Docs] https://doc.pgsty.com
[Demo] https://g.pgsty.com
[Repo] https://github.com/pgsty/pigsty
[Download] ===========================================
[ OK ] version = v3.7.0 (from arg)
curl -fSL https://repo.pigsty.cc/src/pigsty-v3.7.0.tgz -o /tmp/pigsty-v3.7.0.tgz
[WARN] tarball = /tmp/pigsty-v3.7.0.tgz exists, size = 1472486, use it
[ OK ] md5sums = df64ac0c2b5aab39dd29698a640daf2e  /tmp/pigsty-v3.7.0.tgz
[Install] ===========================================
[ OK ] install = /home/vagrant/pigsty, from /tmp/pigsty-v3.7.0.tgz
[Bootstrap] ===========================================
[ OK ] ansible = ready
[ OK ] bootstrap = skip
you can run ./bootstrap to extrac offline package and install ansible
[TodoList] ===========================================
cd /home/vagrant/pigsty
./configure      # [OPTIONAL] preflight-check and config generation
./install.yml    # deployment everything described by your config

You can also download the pigsty src (pigsty-<version>.tar.gz) from GitHub Release Page manually:

wget https://repo.pigsty.io/src/pigsty-v3.7.0.tgz
wget https://pigsty.cc/pgsty/pigsty/releases/download/v3.7.0/pigsty-v3.7.0.tgz
wget https://github.com/pgsty/pigsty/releases/download/v3.7.0/pigsty-v3.7.0.tgz

If your environment does not have Internet access, consider downloading offline packages along with source tarball and upload them to your nodes.

Check Offline Installation for details.

4 - Admin

User, Locale, Sudo, SSH, accessibility…

User

Pigsty requires an OS user with passwordless ssh and sudo on all managed nodes.


Naming Convention

Usually we’ll choose a name such as dba or admin for this purpose, but avoid using root or postgres:

Avoid using root user

While possible, using root as admin user is not recommended for security reasons.

Don't use postgres dbsu as admin user

DBSU (postgres by default) should NOT be used as admin user. It will cause unexpected security issues.

If you are using a different dbsu user, avoid using it as admin user as well.


Provide Password

The nopass requirement is optional if you can accept the password prompt for every ssh and sudo command.

Run playbook with password prompt

You can use the -k|--ask-pass when running playbook to prompt for the ssh password.

And use -K|--ask-become-pass to prompt for the sudo password.

./install.yml -k -K

Create Admin User

It’s user/vendor’s responsibility to create & deliver such an admin user during server provisioning stage. But if you don’t have such an admin user, or that user is restricted, you can create one with pigsty itself:

Create admin user with pigsty

Assuming you have a root or existing admin user on the node, you can create an admin user with pigsty itself.

./node.yml -k -K -t node_admin -e ansible_user=[existing_admin_user]

It will leverage the existing admin to create a new admin user. It will create a dedicated dba (uid=88) user described by the following parameters, with sudo / ssh properly configured.

Name Description Default
node_admin_enabled enable node admin user true
node_admin_uid uid of node admin user 88
node_admin_username name of node admin user dba

Sudo Privileges

All the admin user should have passwordless sudo privileges on all managed nodes.

In case you want to configure an admin user with passwordless sudo privileges from scratch:

Allow sudo without password

To manually allow a user to execute sudo commands without password:

Create a sudoers file for your admin user (assume vagrant, replace with your name choice):

echo '%vagrant ALL=(ALL) NOPASSWD: ALL' | sudo tee /etc/sudoers.d/vagrant

Assume your admin user name choice is dba, then /etc/sudoers.d/dba content would be

%dba ALL=(ALL) NOPASSWD: ALL

Ansible relies on sudo to execute commands with root privileges on managed nodes. So on environments where sudo is not available (like inside a slim container), you may have to install sudo first.


SSH

Your current user should have nopass ssh access to all managed nodes as corresponding admin user.

Your current user can be the admin user itself, but not required as long as you can ssh as the admin user.

SSH configuration is Linux 101, but we will cover the basics here in case you are not familiar with it:


Generate SSH Key

Generate an SSH key pair if you don’t have one

Generate SSH Key
ssh-keygen -t rsa -b 2048 -N '' -f ~/.ssh/id_rsa -q

Pigsty will do that for you if you don’t have a key pair, during the bootstrap stage.


Copy SSH Key

You’ll need to distribute your generated public key remote (and local) servers, and put it into the ~/.ssh/authorized_keys file of the admin user on all nodes. The ssh-copy-id util can be used.

Distribute your ssh key to other nodes

Copy the public key to all managed nodes, ssh-copy-id or add to ~/.ssh/authorized_keys manually.

ssh-copy-id <ip>                        # Interactive password entry

You can use sshpass tool to pass the password directly without prompting, but it’s dangerous:

sshpass -p <password> ssh-copy-id <ip>  # Non-interactive (use with caution)

Using Alias

When direct ssh access is not available (due to jumpserver, other port, credentials, etc…), consider:

Using SSH aliases

Configure SSH aliases in ~/.ssh/config, and put custom parameters for the alias there.

Host meta
    HostName 10.10.10.10
    User dba                      # <--- not the same user on remote
    IdentityFile /etc/dba/id_rsa  # <--- not the ordinary key
    Port 24                       # <--- not the well-known port

And reference the alias in the inventory, use ansible_host to specify the real ssh alias.

nodes:
  hosts:          # if node `10.10.10.10` requires an SSH alias `meta`
    10.10.10.10: { ansible_host: meta }  # <---- access via `ssh meta`

SSH parameters can be used directly in ansible, Check Ansible Inventory Guide for details.


Check Accessibility

Your should be able to access all managed nodes with nopass ssh via your current user from admin node. And the remote user (admin user) should have the privilege to run nopass sudo commands.

Verify nopass ssh sudo is working

Run this command on admin node to all managed nodes:

ssh <ip|alias> 'sudo ls'

if there’s no password prompt or error raised, nopass ssh/sudo is working as expected.

5 - Sandbox

The 4-node env for learning & testing

Pigsty has a sandbox, which is a 4-node deployment with fixed IP addresses and other identifiers.

We will use this as a standard demonstration environment for learning and testing purposes.

pigsty-sandbox.jpg

Description

The sandbox consists of 4 nodes with fixed IP addresses and identities:

ID IP Address NODE PGSQL INFRA ETCD MINIO
1 10.10.10.10 meta pg-meta-1 infra-1 etcd-1 minio-1
2 10.10.10.11 node-1 pg-test-1
3 10.10.10.12 node-2 pg-test-1
4 10.10.10.13 node-3 pg-test-1

There’s a primary singleton PostgreSQL cluster: pg-meta on the meta node, which can be used standalone, and there’s also an optional L2 VIP 10.10.10.2 and cluster DNS pg-meta bind to it.

10.10.10.10 meta pg-meta-1
10.10.10.2  pg-meta

There are three additional nodes in the sandbox, form a 3-instance PostgreSQL HA cluster pg-test. With an optional L2 VIP 10.10.10.3 and cluster DNS pg-test bind to the cluster leader.

10.10.10.11 node-1 pg-test-1
10.10.10.12 node-2 pg-test-2
10.10.10.13 node-3 pg-test-3
10.10.10.3  pg-test

There’s also a 1-node etcd cluster, and 1-node minio cluster on the meta node, too.

10.10.10.10 minio-1
10.10.10.10 etcd-1

Implementation

You can create a local sandbox with Vagrant, or a cloud sandbox with Terraform.

To utilize local vagrant templates:

make full9     # create 4-node sandbox with RockyLinux 9
make full12     # create 4-node sandbox with Debian 12
make full24     # create 4-node sandbox with Ubuntu 24.04

To utilize cloud terraform templates, use the spec/aliyun-full.tf as an example, Aliyun 4-node sandbox template for all distro & amd/arm.

make tu     # terraform up
make td     # terraform destroy
make tssh   # write ssh alias to ~/.ssh/pigsty_config

6 - Vagrant

Provision local VM with vagrant

Pigsty requires Linux environment, you can easily create local linux VMs with Vagrant.

You’ll also need a virtual machine provider, (like VirtualBox for laptops and libvirt for servers)


Get Started

You can install vagrant, virtualbox, ansible on macOS with homebrew:

install on macos
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install vagrant virtualbox ansible

You are all set! use the make shortcuts to create VMs:

~/pigsty
make meta       # 1-node devbox for quick start, dev, test & playground
make full       # 4-node sandbox for HA-testing & feature demonstration
make simu       # 36-node simubox for production environment simulation
...
make meta9      # create singleton-meta node with bento/rockylinux-9 image
make full22     # create 4-node sandbox with generic/ubuntu2204 image
make simu12     # create 36-node simulation env with generic/debian12 image

Configuration

You have to define VMs in the Vagrantfile before launch. The default Vagrantfile defines a el9 (bento/rockylinux-9) 1-node virtual machine with the local virtualbox VM provider.

We have a list of pre-defined VM specs available in the vagrant/spec Folder

Templates Nodes Spec Comment Alias
meta.rb 1 node 2c4g x 1 Single Node Meta Devbox
dual.rb 2 node 1c2g x 2 Dual Nodes
trio.rb 3 node 1c2G x 3 Three Nodes
full.rb 4 node 2c4g + 1c2g x 3 Full-Featured 4 Node Sandbox
simu.rb 36 node misc Prod Env Simulation Simubox
oss.rb 3 node 1c2g x 3 3-Node OSS Building Env
pro.rb 5 node 1c2g x 5 5-Node PRO Building Env

Each spec file contains a Specs variable describe VM nodes. For example, the full.rb contains:

# full: pigsty full-featured 4-node sandbox for HA-testing & tutorial & practices

Specs = [
  { "name" => "meta"   , "ip" => "10.10.10.10" ,  "cpu" => "2" ,  "mem" => "4096" ,  "image" => "bento/rockylinux-9"  },
  { "name" => "node-1" , "ip" => "10.10.10.11" ,  "cpu" => "1" ,  "mem" => "2048" ,  "image" => "bento/rockylinux-9"  },
  { "name" => "node-2" , "ip" => "10.10.10.12" ,  "cpu" => "1" ,  "mem" => "2048" ,  "image" => "bento/rockylinux-9"  },
  { "name" => "node-3" , "ip" => "10.10.10.13" ,  "cpu" => "1" ,  "mem" => "2048" ,  "image" => "bento/rockylinux-9"  },
]

You can use specs with the config script, it will render the Vagrantfile according to spec and environment variables (resouce, image, vm provider, etc…).

cd ~/pigsty
vagrant/config [spec] [image] [scale] [provider]

vagrant/config meta                # use the 1-node spec, default el8 image
vagrant/config dual el9            # use the 2-node spec, use el9 image instead
vagrant/config trio d12 2          # use the 3-node spec, use debian12 image, double the cpu/mem resource
vagrant/config full u22 4          # use the 4-node spec, use ubuntu22 image instead, use 4x cpu/mem resource
vagrant/config simu u24 1 libvirt  # use the 36-node spec, use ubuntu24 image instead, use libvirt as provider instead of virtualbox

You can scale the resource unit with environment variable VM_SCALE, the default value is 1.

For example, VM_SCALE=2 vagrant/config meta will double the cpu / mem resources of the meta spec

Specs = [
  { "name" => "meta" , "ip" => "10.10.10.10", "cpu" => "8" , "mem" => "16384" , "image" => "bento/rockylinux-9" },
]

Shortcuts

You can create the VMs with vagrant up command after configuration.

Pigsty templates will use your ~/.ssh/id_rsa[.pub] as the default ssh key for vagrant provisioning. Make sure you have a valid ssh key pair before you start, you can generate one by: ssh-keygen -t rsa -b 2048

There are some shortcuts that wrap the vagrant commands, you can use them to manage the VMs.

~/pigsty/vagrant
make         # = make start
make new     # destroy existing vm and create new ones
make ssh     # write VM ssh config to ~/.ssh/     (required)
make dns     # write VM DNS records to /etc/hosts (optional)
make start   # launch VMs and write ssh config    (up + ssh)
make up      # launch VMs with vagrant up
make halt    # shutdown VMs (down,dw)
make clean   # destroy VMs (clean/del/destroy)
make status  # show VM status (st)
make pause   # pause VMs (suspend,pause)
make resume  # pause VMs (resume)
make nuke    # destroy all vm & volumes with virsh (if using libvirt)

Version

Pigsty currently uses the following vagrant boxes for testing:

x86_64
$ vagrant box list

el8 :  bento/rockylinux-8     (libvirt, 202502.21.0, (amd64))
el9 :  bento/rockylinux-9     (libvirt, 202502.21.0, (amd64))

d11 :  generic/debian11       (libvirt, 4.3.12, (amd64))
d12 :  generic/debian12       (libvirt, 4.3.12, (amd64))

u20 :  generic/ubuntu2004     (libvirt, 4.3.12, (amd64))
u22 :  generic/ubuntu2204     (libvirt, 4.3.12, (amd64))
u24 :  bento/ubuntu-24.04     (libvirt, 20250316.0.0, (amd64))

Not all of them have arm64 arch support, so beware when using Apple Silicon MacOS.

aarch64
bento/rockylinux-9 (virtualbox, 202502.21.0, (arm64))
bento/ubuntu-24.04 (virtualbox, 202502.21.0, (arm64))

You can find the supported Box Image on https://app.vagrantup.com/bento/boxes


Caveat

Virtualbox Network Configuration

It require extra setup to use the default 10.x.x.x CIDR as host-only networks when using older version of virtualbox as vagrant provider: add it to /etc/vbox/networks.conf

echo "10.0.0.0/8" | sudo tee -a /etc/vbox/networks.conf

7 - Terraform

Provision cloud VM with terraform

Terraform is a popular IaC tool. You can create VMs on public cloud with one command.

Aliyun & AWS templates are used as example providers. You can take terraform.tf as an example.


Get Started

You can install terraform with homebrew on macOS

install homebrew and terraform
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install terraform

Then init terraform cloud provider, adjust the terraform.tf config file and apply it:

cd ~/pigsty/terraform
terraform init
terraform apply #-auto-approve

Print public IP Address:

terraform output | grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'

AWS Setup

You have to set up aws config & credential to use AWS provider.

# ~/.aws

# ~/.aws/config
[default]
region = cn-northwest-1

# ~/.aws/credentials
[default]
aws_access_key_id = <YOUR_AWS_ACCESS_KEY>
aws_secret_access_key =  <AWS_ACCESS_SECRET>

# ~/.aws/pigsty-key
# ~/.aws/pigsty-key.pub

There’s a contrib example for AWS (Amazon Web Services), but it’s not actively maintained.


Aliyun Setup

You can add your aliyun credentials to the environment file, such as ~/.bash_profile

export ALICLOUD_ACCESS_KEY="<your_access_key>"
export ALICLOUD_SECRET_KEY="<your_secret_key>"
export ALICLOUD_REGION="cn-beijing"

Example config files:

Here are example ECS public OS images used in Aliyun:

Distribution Image Prefix Image Prefix
CentOS 7.9 centos_7_9_x64 rockylinux_8_10_arm6
Rocky 8.10 rockylinux_8_10_x64 rockylinux_9_6_arm64
Rocky 9.6 rockylinux_9_5_x64
Debian 11.11 debian_11_11_x64
Debian 12.11 debian_12_11_x64 debian_12_11_arm64
Ubuntu 20.04 ubuntu_20_04_x64
Ubuntu 22.04 ubuntu_22_04_x64 ubuntu_22_04_arm64
Ubuntu 24.04 ubuntu_24_04_x64 ubuntu_24_04_arm64
Anolis 8.8 anolisos_8_9_x64

QCloud Setup

There’s a contrib example for QCloud (Tencent Cloud), but it’s not actively maintained.