Stacks
Overview
Stacks let you define multi-VM deployments as a single YAML template and manage them as a unit. Instead of launching VMs one at a time, you describe all the VMs you need in a template, then deploy and tear them down together.
A stack has three components:
- Name: a unique identifier for the stack (same rules as VM names)
- Template: a YAML document defining the VMs
- State: tracked automatically: undeployed, deployed, or partial
VM names are automatically prefixed with the stack name. For example, a stack called my-app with a VM named web creates a VM called my-app-web.
Template Format
Templates are YAML documents with a single top-level key vms containing a list of VM specifications:
vms:
- name: web-server
os: ubuntu-24.04
size: medium
disk: 100
user-script: |
apt-get update
apt-get install -y nginx
- name: database
os: ubuntu-24.04
size: large
disk: 200
user-script: |
apt-get update
apt-get install -y postgresql
Field Reference
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
name required |
string | Yes | None | VM name within the stack. Combined with the stack name to form the full VM name ({stack}-{name}). Must be unique within the template. |
os required |
string | Yes | None | OS image ID. Available options: ubuntu-26.04, ubuntu-24.04, ubuntu-22.04, fedora-43, amazon-2023. Append +desktop for a desktop environment (e.g. ubuntu-24.04+desktop). |
size required |
string | Yes | None | Instance size. One of:
micro (1 vCPU, 1 GB RAM, 50 GB disk),
small (1 vCPU, 2 GB RAM, 50 GB disk),
medium (2 vCPU, 4 GB RAM, 50 GB disk),
large (2 vCPU, 8 GB RAM, 100 GB disk),
xlarge (4 vCPU, 16 GB RAM, 100 GB disk),
2xlarge (8 vCPU, 24 GB RAM, 200 GB disk),
3xlarge (8 vCPU, 32 GB RAM, 200 GB disk),
4xlarge (16 vCPU, 64 GB RAM, 500 GB disk) |
disk optional |
int | No | from size | Override disk size in GB. When set, overrides the default disk size for the chosen instance size. |
user-script optional |
string | No | None | Shell commands to run on first boot (via cloud-init). Use YAML | for multi-line scripts. Also accepts user_script. |
post-tailscale-script optional |
string | No | None | Bash script that runs once after Tailscale connects, through a systemd one-shot unit that survives reboots. It sees TS_IP and TS_DNSNAME (empty if Tailscale is not configured), and ${vm.NAME.ip} and ${secret.NAME} work in it. Retried at the next boot if it fails, so make it safe to run twice. Also accepts post_tailscale_script. |
ssh-key optional |
string | No | None | SSH public key to inject into the VM. Also accepts ssh_key. |
vnc optional |
bool | No | false | Enable VNC graphics. Automatically enabled when desktop is true. |
desktop optional |
bool | No | false | Install a desktop environment. Implies vnc: true. Can also be set by appending +desktop to the os value. |
bridged optional |
bool | No | false | Use bridged networking instead of NAT. The VM gets an IP on the host's physical network. Requires a bridge interface (e.g. br0) on the host. |
depends_on optional |
list | No | [] | List of VM names (from this template) that must be launched and have an IP address before this VM starts. Used to ensure ${vm.X.ip} variables resolve to real IPs. Also accepts depends-on. |
provider optional |
string | No | libvirt | Infrastructure provider: libvirt (on-prem) or aws. Mix providers in the same stack. |
region optional |
string | No | default | AWS region (e.g. us-east-1). VPC and subnet are auto-provisioned. Only used when provider is aws. |
Template Variables
Use variables in user-script to reference other VMs in the same stack. Variables are resolved at deploy time.
| Variable | Resolves To | When |
|---|---|---|
${vm.SPECNAME.name} |
Full prefixed VM name (e.g. mystack-database) |
Deploy time (immediate) |
${vm.SPECNAME.ip} |
Actual IP address of the sibling VM (e.g. 192.0.2.237) |
Deploy time (requires depends_on: the dependency is launched first and its IP is collected before this VM starts) |
${secret.NAME} |
Decrypted value of the secret named NAME |
Deploy time (secret must exist in Profile > Secrets or as a per-stack secret) |
SPECNAME is the name field of a VM in the same stack template (not the full prefixed name).
Example: web server connecting to database
vms:
- name: database
os: ubuntu-24.04
size: medium
user-script: |
apt-get update
apt-get install -y postgresql
- name: web
os: ubuntu-24.04
size: small
depends_on: [database]
user-script: |
apt-get update
apt-get install -y nginx
# database IP is substituted directly by the host before cloud-init
echo "DB_HOST=${vm.database.ip}" >> /etc/environment
echo "DB_VM=${vm.database.name}" >> /etc/environment
${vm.X.ip}, add depends_on: [X] to the VM that needs the IP. The host launches dependencies first, waits for them to get an IP (up to 2 minutes), then substitutes the actual IP address directly into the user-script before the dependent VM is created. No guest-side DNS resolution is needed. Name variables (${vm.X.name}) are replaced instantly and don't require depends_on.
Secrets
Secrets let you inject sensitive values (database passwords, API keys, tokens) into VM user-scripts without hardcoding them in the YAML template. Secret values are encrypted at rest using AES-256-GCM and only decrypted at deploy time.
Scopes
- Global secrets: set in Profile > Secrets. Available to all your stacks.
- Per-stack secrets: set on the stack detail page > Secrets tab. Override global secrets of the same name for that specific stack.
At deploy time, global secrets are loaded first, then per-stack secrets overlay them. If a per-stack secret has the same name as a global secret, the per-stack value wins.
Usage
Reference secrets in user-script using ${secret.NAME} syntax:
vms:
- name: database
os: ubuntu-24.04
size: large
user-script: |
apt-get install -y postgresql
sudo -u postgres psql -c "ALTER USER postgres PASSWORD '${secret.DB_PASSWORD}';"
- name: web
os: ubuntu-24.04
size: medium
depends_on: [database]
user-script: |
echo "DB_HOST=${vm.database.ip}" >> /etc/environment
echo "DB_PASSWORD=${secret.DB_PASSWORD}" >> /etc/environment
Security Model
- Secret lists and stack pages show names only, never values. A value is returned only when you ask for it: the Reveal button, or
GET /api/v1/secrets/{id}/valuefor a global secret andGET /api/v1/stacks/{name}/secrets/{id}/valuefor a stack secret. Only the user who owns a global secret can reveal it. A stack secret can be revealed by an admin or the owner of the stack. Reveals are not written to a separate log, and no MCP tool reveals a secret. - Values are encrypted with AES-256-GCM using an auto-generated master key stored in the database.
- Decrypted values exist only in server memory during deployment and are substituted directly into cloud-init user-scripts.
- Secret names may contain letters, digits, hyphens, and underscores (max 128 characters).
- If a template references a secret that doesn't exist, the
${secret.NAME}placeholder is left as-is and a warning is logged.
Secrets API
List global secrets (metadata only, values not included).
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Secret name |
value | string | Yes | Secret value (encrypted at rest) |
Response 201 Created: {"ok": true, "name": "DB_PASSWORD"}
Retrieve the decrypted value of a global secret. Response: {"value": "the-secret-value"}
| Field | Type | Required | Description |
|---|---|---|---|
value | string | Yes | New secret value |
Update the value of an existing global secret.
Delete a global secret by ID.
List per-stack secrets (metadata only).
Create or update a per-stack secret. Same request body as global secrets.
Retrieve the decrypted value of a per-stack secret. Response: {"value": "the-secret-value"}
Update the value of a per-stack secret. Same request body as global update.
Delete a per-stack secret by ID.
Available OS Images
Use these values for the os field:
| OS ID | Name | Default User | Desktop Available |
|---|---|---|---|
ubuntu-26.04 |
Ubuntu 26.04 LTS | ubuntu |
Yes: ubuntu-26.04+desktop |
ubuntu-24.04 |
Ubuntu 24.04 LTS | ubuntu |
Yes: ubuntu-24.04+desktop |
ubuntu-22.04 |
Ubuntu 22.04 LTS | ubuntu |
Yes: ubuntu-22.04+desktop |
fedora-43 |
Fedora 43 | fedora |
Yes: fedora-43+desktop |
amazon-2023 |
Amazon Linux 2023 | ec2-user |
No |
ssh ubuntu@<ip>. For Fedora, use fedora. For Amazon Linux, use ec2-user. A random password is also generated for each VM at deploy time.
Examples
Minimal: two VMs with defaults
vms:
- name: app
os: ubuntu-24.04
size: small
- name: db
os: ubuntu-24.04
size: medium
Hybrid cloud: on-prem database + AWS web server
vms:
- name: db
os: ubuntu-24.04
size: medium
user-script: |
apt-get update && apt-get install -y postgresql
- name: web
os: ubuntu-24.04
size: small
provider: aws
region: us-east-1
depends_on: [db]
user-script: |
apt-get update && apt-get install -y nginx
Web application stack with provisioning
vms:
- name: nginx
os: ubuntu-24.04
size: small
user-script: |
apt-get update
apt-get install -y nginx
systemctl enable nginx
- name: app
os: ubuntu-24.04
size: medium
disk: 80
ssh-key: ssh-ed25519 AAAA... user@host
user-script: |
apt-get update
apt-get install -y nodejs npm
- name: postgres
os: ubuntu-24.04
size: large
disk: 200
user-script: |
apt-get update
apt-get install -y postgresql
systemctl enable postgresql
Desktop development environment
vms:
- name: dev-box
os: ubuntu-24.04+desktop
size: large
disk: 150
ssh-key: ssh-ed25519 AAAA... user@host
user-script: |
snap install code --classic
apt-get update
apt-get install -y git build-essential
Mixed OS testing
vms:
- name: ubuntu-test
os: ubuntu-24.04
size: micro
- name: fedora-test
os: fedora-43
size: micro
- name: amazon-test
os: amazon-2023
size: small
Lifecycle
A stack goes through these stages:
| Action | What happens |
|---|---|
| Create | The stack name and template are saved to the database. No VMs are launched yet. |
| Deploy | VMs are launched in dependency order. VMs with no depends_on start first (in parallel), then VMs that depend on them, and so on. Each VM gets an auto-generated password. Non-admin users are automatically granted access to the VMs. |
| Update Template | The template YAML is updated in the database. Already-deployed VMs are not affected. Changes take effect on the next deploy. |
| Tear Down | All VMs belonging to the stack are deleted (destroyed + disk removed). The stack itself remains so you can redeploy later. |
| Delete Stack | Tears down all VMs (if any) and then removes the stack from the database entirely. |
REST API
Stacks can be managed programmatically via the REST API. All endpoints require an API key (Authorization: Bearer vmk_...).
List Stacks
Returns all stacks visible to the authenticated user (admins see all, users see their own).
[{
"name": "my-app",
"vm_count": 3,
"deployed": 3,
"status": "deployed",
"created_by": 1,
"created_at": "2026-02-15 12:00:00",
"updated_at": "2026-02-15 12:00:00"
}]
Create Stack
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Stack name (unique, same rules as VM names) |
template | string | Yes | YAML template content |
Response 201 Created:
{"name": "my-app", "created_at": "2026-02-15 12:00:00"}
Get Stack
Returns the stack template and live VM status.
{
"name": "my-app",
"template": "vms:\n - name: web\n os: ubuntu-24.04\n size: small",
"vms": [
{"spec_name": "web", "full_name": "my-app-web", "state": "running", "ip": "192.0.2.10", "cloud_init": "done"}
],
"created_by": 1,
"created_at": "2026-02-15 12:00:00",
"updated_at": "2026-02-15 12:00:00"
}
Update Stack Template
| Field | Type | Required | Description |
|---|---|---|---|
template | string | Yes | Updated YAML template |
Response 200 OK: {"ok": true}
Deploy Stack
Launches all VMs defined in the template. Returns immediately with 202 Accepted while VMs are created in the background.
{
"stack": "my-app",
"vms": [
{"name": "my-app-web", "password": "aBcDeFgH", "status": "creating"}
]
}
Tear Down Stack
Deletes all VMs belonging to the stack. The stack itself is preserved.
Response 200 OK: {"ok": true}
Delete Stack
Tears down all VMs and removes the stack from the database.
Response 200 OK: {"ok": true}
Template Library
The template library lets you save stack templates for reuse. Saved templates persist independently of stacks, so you can delete a stack and still reuse its template later.
Saving a Template
On any stack detail page, use the Save as Template form below the YAML editor. Enter a name for the template and click save. The stack's current YAML is saved to your personal library.
Loading a Saved Template
When creating a new stack, a dropdown appears above the YAML editor if you have saved templates. Select a template and click Load to populate the editor with the saved YAML. You can edit it before creating the stack.
Deleting a Saved Template
On the new stack page, select a template from the dropdown and click the Delete button to remove it from your library.
Template Library API
Returns all saved templates belonging to the authenticated user.
[{"id": 1, "name": "web-app", "template": "vms:\n ...", "created_at": "2026-02-15 12:00:00"}]
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Template name (unique per user) |
template | string | Yes | YAML template content |
Response 201 Created: {"ok": true, "name": "web-app"}
Deletes a saved template by ID. Only the owner can delete their templates.
Response 200 OK: {"ok": true}
Access Control
- Admin users can see and manage all stacks.
- Regular users can only see and manage stacks they created.
- When a non-admin deploys a stack, they are automatically granted access to the created VMs.
- Deployed VMs appear on the Dashboard like any other VM. They can be individually started, stopped, and accessed via shell/VNC.