guides
Profiles and presets (reuse create defaults)
Named create defaults in config, plus docker / k3s / act cloud-init presets.
Named profiles
Define reusable create defaults in ~/.grain/config.yaml. Built-in profiles are available without config; the same name in config overrides the builtin.
Builtin: remote-coding
Durable remote lab defaults (no host mounts — laptop paths are not on the daemon host; use grain sync):
| Field | Value |
|---|---|
persistent | true |
cpus | 4 |
memory_mb | 8192 |
disk_gb | 32 |
image | grain-ubuntu |
grain profile ls
grain new --profile remote-coding --wait agent -n alice-dev
grain sync push ~/proj alice-dev:/work/projConfig examples
profiles:
agent:
cpus: 4
memory_mb: 4096
disk_gb: 20
image: ubuntu-cloud
persistent: false
mounts:
- {host: ".", guest: "/work"}
forwards:
- {guest_port: 3000} # host port auto-allocated
k3s-lab:
cpus: 2
memory_mb: 4096
disk_gb: 20
persistent: true
preset: k3s
# optional override of the builtin:
# remote-coding:
# cpus: 8
# memory_mb: 16384
# persistent: truegrain profile ls
grain new --profile agent
grain new --profile k3s-lab -n lab
grain new --profile remote-coding -n lab --wait agentResolve order: CLI flags (only if explicitly set) → profile fields (config, else builtin) → global config defaults.
Created instances are tagged profile=<name> for inspect via the API / meta.
Presets
Embedded cloud-init fragments applied with grain new --preset NAME or profile.preset:
| Preset | Effect |
|---|---|
docker | Install Docker (cloud-init packages / install path) |
k3s | Single-node k3s; defaults toward 2 CPU / 4096 MiB when unset; auto-publishes guest 6443 |
act | Docker Engine + nektos/act; defaults toward 2 CPU / 4096 MiB when unset |
Presets merge into userdata with the structured cloud-init merge (safe with --userdata-file).
For long custom first-boot work that should block create until you say ready, implement the Readiness protocol and use grain new --wait bootstrap.
grain new --preset docker
grain new --preset k3s -n lab -p
grain new --preset act -v "$PWD:/work" -n act-lab --wait agent
# first boot can take several minutes — use:
grain logs -f labFor a one-shot GitHub Actions run (create → act → destroy), prefer the dedicated command:
grain act -- -l
grain act -- -j testSee the act recipe.
Combining
grain new --profile agent --preset docker # profile resources/mounts + docker userdata
grain new --profile agent -c 8 # flag overrides profile cpus