Skip to content

Replacing Vagrant in Pigsty: what Barn still needs

A source check of the Vagrant behavior Pigsty relies on, with priorities and acceptance criteria for readiness gates, forced power-off, VIP addresses, persistent disks, and fault injection.

Pigsty’s vagrant/ directory, Makefile, and public tutorials define the behavior Barn has to take over. The sandbox migration plan already covers resource scaling, local host names, and the entry-point switch, and Vagrant and the development loop lists candidates such as provisioning steps, file transfer, and snapshots. This page adds the remaining layer: it checks the Vagrant behavior Pigsty actually relies on, sets out what Barn must add before Vagrant can be retired, and then lists capabilities Vagrant never offered but that Pigsty’s high-availability tutorials need.

Status (2026-11-27): this is a design proposal based on a source check of Barn’s unreleased main (22f6a28), Pigsty main, and the pigsty.io documentation. None of the new capabilities is implemented, and the priorities are not tied to a release.

The Vagrant behavior Pigsty relies on

Pigsty todayBarn todayGap
vagrant/config and spec/*.rb: topology, image aliases, resource scale, architecturevm_*, vm_scale, -I/-A, short image aliasesNone; the specs move into Pigsty inventories
BOX_VERSION_PINS fixes box versionsExact versions in the inventory, resolved through the signed catalogNo exportable, verifiable lock record
Fixed private IPs and NAT NIC fixes (bin/el-fix)Two NICs; the private-network stage checks the guest NIC configurationHost and peer reachability is not verified, and a failure only reports limited
/data disk, four MinIO disks, root_diskvm_disks, vm_diskA persistent disk judged corrupt is reset
vagrant/ssh writes node-name and IP aliasesssh-config covers node names, IPs, and vm_aliasNone
vagrant/dns writes /etc/hostsvm_hosts and hosts install -f (since 1.2.0)The Pigsty-side name extractor is still missing
Subset operations such as up-testSelectors accept resolved node names onlyNo selection by group, IP, or alias
halt, destroy, nukestop, destroy, purgestop only sends an ACPI shutdown; nothing matches halt --force
suspend, resumeNoneMemory state is not promised; see scope
Windows hostsmacOS, LinuxNeeds a product decision; see scope

Two rows need context. ssh 10.10.10.11 reaches the management forward on 127.0.0.1 through Barn’s OpenSSH configuration; under the VirtualBox provider, Pigsty’s vagrant/ssh also copies the 127.0.0.1:2222 entry from vagrant ssh-config into an IP alias. That is not a regression, but a place where Barn can do better than Vagrant. Data disks go the other way: the Vagrant templates format a disk only when blkid finds no signature at all, and when a signature remains but the mount fails, mount -a || true fails silently. Barn rebuilds the filesystem once the checker confirms damage.

Required before retiring Vagrant

Strict readiness gate

The private-network, control-ssh, and data-disks guest setup stages are optional. A failure is written to nodes[].warnings, up summarizes the node as limited, and the command exits 0. private-network checks only the guest’s own NIC configuration — the right address, no default route, no DNS — and then sends one UDP packet to the host .1 without waiting for a reply. It does not show that the host can reach the private address directly, or that the control node can log in to its peers without a password, which is exactly what PostgreSQL streaming replication, etcd, and Silo depend on.

Proposal:

  • After the guests are ready, up runs three probes: the host connects directly to port 22 on each node’s private address, bypassing the OpenSSH configuration; the control node runs ssh -o BatchMode=yes <ip> sudo -n true against every peer; and each declared mount point is backed by its own block device and is writable.
  • A new --strict flag turns any guest warning into a non-zero exit. The VMs keep running, and the structured result names the cause per node and stage.
  • The same probes are available as a separate, repeatable command (name to be decided, for example barn verify) for use after a host reboot or a socket_vmnet reinstall.

Until Barn ships this, Pigsty can check the barn --json up result as the automation guide shows and reject nodes that report warnings or repairs.

Acceptance: a healthy four-node full lab returns 0 under --strict. Blocking the private network on the host or in a guest makes --strict return non-zero and name the node and stage, and so does a missing control-node private key.

Forced power-off

Linux stop sends system_powerdown over QMP and waits up to GracefulGuestShutdownTimeout (two minutes); there is no forced option. During a clean shutdown Patroni hands over leadership on its own, so the “node down” case in Pigsty’s failure model, which relies on passive detection, cannot be tested. The 2-of-3 failure drill also asks for an outright power or network cut. Pigsty’s MySQL hardware test also recorded a purge that failed because the shutdown grace period exceeded the test’s 120-second timeout.

Proposal:

  • stop --force verifies the process identity and then runs QMP quit, the same path start compensation already uses. The node is recorded as stopped and starts normally with start.
  • purge discards everything anyway, so it takes the forced path; destroy that keeps persistent disks still tries a clean shutdown first.

Acceptance: after a forced power-off of the primary in full, Patroni promotes a replica within the TTL, and the node rejoins the cluster after start. A four-node purge no longer waits for guest shutdown.

VIP address rule

The current rules contradict each other. The code rejects node addresses and vm_hosts in .2–.8, and the sandbox migration plan therefore asks Pigsty to move its VIPs off .2/.3/.4. The two-NIC design, however, lists that range as “available for L2 VIPs”. Moving is costly: as of 2026-11-27, 14 files in Pigsty’s conf/ and roles/ reference 10.10.10.2–10.10.10.4, and so do 25 pages each on pigsty.io and pigsty.cc.

OptionApproachCost and risk
A: Pigsty movesVIPs move to .100 and up14 configuration files and about 50 documentation pages, with their connection strings and examples; Barn is unchanged
B: Barn accepts declared service addressesA new service-address declaration (for example vm_vips) may use .2–.8; up and hosts install check for conflictsLinux barn0 runs no DHCP. The macOS vmnet pool serves only DHCP clients, and Barn guests use a static address on the private NIC. The risk comes from other clients on the same vmnet segment, which are likely to receive .2, so Barn has to check leases and probe ARP

Option B is recommended, provided two things are tested first: an EL guest’s private NIC does not try DHCP during first boot, and the macOS host refreshes its ARP cache after a gratuitous ARP. Whichever option is chosen, service addresses take part in address-conflict validation and hosts publishing, and the contradictory page is corrected.

Acceptance: on both macOS socket_vmnet and Linux barn0, after the pg-test VIP moves from node A to node B — once through a switchover and once through a forced power-off — the host and a third guest reconnect to the service on the original address, and the host’s ARP table points to the new MAC.

Keep evidence on persistent disks

When a data disk fails to mount and the checker confirms ext4 or XFS damage, the setup script rebuilds the filesystem, including on a disk marked persistent; storage and access documents the current rule. In a database failure drill this erases exactly the evidence that needs analysis. In addition, --delete-persistent works only for a whole-deployment destroy, so Pigsty’s MySQL whole-VM replacement test had to fall back to a new root disk with the old data disk detached.

Proposal:

  • Persistent disks are no longer reset automatically. Barn marks the disk as failed and reports the node, mount point, device, and checker output. Non-persistent disks keep the current behavior.
  • Two explicit operations: delete a node’s persistent disks, and reset one disk (name to be decided, for example barn disk reset NODE MOUNT). Both reuse the destroy scope confirmation.

Acceptance: after controlled damage to an ext4 and an XFS persistent disk, a second up leaves the disk file’s digest unchanged and the status points to the failed disk. An explicit reset produces an empty filesystem, and a single-node replacement deletes only that node’s persistent disks.

Smoother Pigsty labs

Select nodes by group, address, and alias

Selectors accept only resolved node names today. Barn already reads the group structure of the Ansible inventory, so the proposal is for plan, up, start, stop, restart, and destroy to also accept group names (such as pg-test and minio), private IPs, and unique vm_alias values, and to print the expanded node list before acting. A name that is both a group and a node is an error, and the destroy confirmation lists the expanded nodes.

Acceptance: in full, barn stop pg-test stops only the three nodes in the pg-test group, and an ambiguous selector returns a usage error.

Fault injection

Pigsty’s high-availability tutorials need three kinds of failure: a node going down, a hung process, and a network partition. All three can be produced through QMP without touching the guest configuration:

OperationQMP commandSimulated failure
Forced power-offquitNode down; see above
Pause, resumestop, contHung node: vCPUs freeze and memory is kept; after resume, barn time sync corrects the clock
Disconnect, reconnect the private networkset_link on the private NIC onlyNetwork partition; management SSH stays available for observation and recovery

Pausing also covers part of what Vagrant suspend was used for — temporarily giving CPU back — though it does not free memory. Asymmetric partitions, such as cutting only the link between A and B, remain the job of firewall rules that Pigsty scripts apply inside the guests.

Acceptance: pausing the primary for longer than the Patroni TTL promotes a replica, and after resume the old primary becomes a replica. Disconnecting the primary’s private network causes a failover, and the node rejoins after reconnecting; management SSH to that node works throughout.

Image release discipline and lock records

Replacing Vagrant does not depend on a lock file. Pigsty profiles can write exact versions in the inventory (for example vm_image: d13@20261123.2671.1), which matches the old BOX_VERSION_PINS. Two release rules are more urgent:

  • The Pigsty entry point checks a minimum Barn version. Barn 1.4.0 changes the catalog signing key, and 1.3.0 rejects catalog signatures from 2026112601 onward; see the 1.4.0 upgrade notes. Pigsty should switch after 1.4.0 is released.
  • The official image repository keeps every artifact that a published Pigsty release references.

After that, lock records follow the environment record in Vagrant and the development loop: export each node’s image, architecture, full version, digest, and catalog revision, and provide a replay mode that refuses drift.

Cold snapshots

Vagrant and the development loop already lists cold snapshots as P1. For Pigsty their main value is a saved baseline after deployment: each run of the PITR tutorial or an upgrade regression restores from it instead of spending ten or more minutes reinstalling. Taking the snapshot from a stopped VM also avoids the migration limits of 9p shares.

Out of scope for this round

  • Named parallel environments: in the Vagrant era, environments in different directories also shared the same 10.10.10.0/24 host-only network, so Pigsty could never run two at once, and Barn’s single deployment is not a regression. When switching profiles, up refuses with nodes_removed; the Pigsty entry point runs barn destroy --yes explicitly, matching the old del.
  • Deployment identity checks: nodes_removed already stops most cross-profile mistakes.
  • Built-in upload and download: both of Pigsty’s providers disable the default shared folder, and source and offline packages are delivered with scp, which the existing ssh-config already supports. Pigsty defaults to EL images, and whether RHEL-family kernels include 9p modules needs testing; if they do not, vm_shares cannot replace scp.
  • Vendor image variants: the Alma, Oracle, and RHEL aliases in the old config move to image import or a self-hosted repository.
  • Memory-state suspend: not promised. Pause covers temporarily giving CPU back.
  • Windows hosts: needs a product decision. One option is to keep a frozen vagrant/ as the Windows entry point during the transition and delete it after WSL2 acceptance; the other is to narrow the host platforms in Pigsty’s documentation.

Pigsty-side work

  • The entry script always passes -f, runs configure, plan, and up in order, and explicitly destroys the old lab when switching profiles. This keeps make -j from running destroy and up concurrently.
  • The entry script checks the minimum Barn version and moves or keeps VIPs according to the VIP address rule decision.
  • The migration plan records bin/sandbox-dns as implemented locally, but no commit in the Pigsty repository contains it; it needs to be recovered or rewritten.
  • bin/release still packages vagrant/; the release manifest and the English and Chinese documentation change with the switch.
  • Accept the release package once on Apple Silicon and once on Linux amd64: full covers the portal, switchover, and VIP reconnection; demo/minio covers four mounted disks and reads and writes after a restart; simu covers 20 nodes, partial-failure retries, and group operations; build/oss covers retrieving real build artifacts. Cover the default EL9 entry point separately.

Evidence

FindingSource
Private network, control SSH, and data disk stages only warnfinalize.sh, render.go, private-contract.sh
Host SSH aliases point to the loopback forwardaccess.go; Pigsty vagrant/ssh
stop only shuts down cleanlyvm/lifecycle.go, qmp.go
Reserved range and vm_hosts validationsubnet/layout.go, config/file.go; Pigsty vip.yml selects the NIC by inventory IP
Corrupt persistent disks are resetinit-disks.sh; Pigsty Vagrantfile.libvirt
No per-node persistent disk deletion; purge waits for shutdowncmd/barn/lifecycle.go; Pigsty MySQL hardware test record
Selectors and nodes_removedcmd/barn/lifecycle.go, diff.go
Pigsty entry points and default imagePigsty Makefile, vagrant/Makefile, vagrant/config

Table reader