Skip to main content

Macros (honeyfile)

Honey macros let you define reusable named operations in a honeyfile manifest and run them with a single command. A honeyfile bundles common tasks — remote exec, recipe runs, log tailing, app proxy opens — so your team shares the same runbook without memorizing flags.

Quick start

# List macros in the nearest honeyfile.yaml
honey macros --list

# Execute a macro
honey macros restart-nginx

# Dry-run: print resolved configuration without executing
honey macros restart-nginx --dry-run

# Use an explicit file
honey macros --file ops/honeyfile.yaml restart-nginx

CLI reference: honey macros

Manifest format

A honeyfile uses Kubernetes-style YAML:

apiVersion: honey.shareed2k.io/v1alpha1
kind: MacroSet
metadata:
name: ops-macros
spec:
macros:
<macro-name>:
kind: exec|recipe|logs|app|tunnel
# ... kind-specific fields

Honey looks for honeyfile.yaml or honeyfile.yml in the current directory. Override with --file <path> or the HONEY_MACROS_FILE environment variable.

Macro kinds

KindWhat it does
execRun shell commands on matching hosts in parallel
recipeExecute a CUE recipe file
logsStream logs from matching hosts
appOpen an HTTP app proxy in the browser
tunnelStart a TCP proxy tunnel for an app

exec

Runs one or more shell commands on hosts that match the target pattern.

spec:
macros:
restart-nginx:
kind: exec
target: "web-*"
command: "systemctl restart nginx"
parallel: 50
retry: 3
timeout: 10s
shell: auto
runAs: root
output: text

For multiple commands in sequence, use commands instead of command:

restart-and-check:
kind: exec
target: "web-*"
commands:
- "systemctl restart nginx"
- "systemctl is-active nginx"
- "ss -ltnp | grep :80"
parallel: 20
retry: 2
timeout: 20s

Fields:

FieldTypeDefaultDescription
targetstringHost name pattern (same syntax as honey exec <target>)
commandstringSingle command to run
commandslistSequential commands (mutually exclusive with command)
parallelint20Max concurrent executions
retryint1Retry attempts per host (1 = no retry)
timeoutduration0Per-host timeout (e.g. 10s, 2m); 0 disables
shellstringautoShell mode — see Shell modes
runAsstringRun via sudo -n as this user
outputstringtextOutput format: text or json
quietboolfalseSuppress stdout, show status lines only

recipe

Executes a CUE recipe file. See CUE Recipes for recipe authoring.

deploy-staging:
kind: recipe
target: "web-*"
provider: "gcp"
backends: "gcp-stg2"
recipePath: "examples/recipe/with_run_as.cue"
execute: false
env:
- "APP_ENV=staging"
- "IMAGE_TAG=latest"

Fields:

FieldTypeDefaultDescription
targetstringHost name pattern
recipePathstringPath to .cue recipe file
executeboolfalsefalse = dry-run plan; true = execute
envlistExtra environment variables (KEY=value)

logs

Streams logs from matching hosts. All options mirror honey logs flags.

tail-nginx:
kind: logs
target: "web-*"
unit: "nginx"
follow: true
tail: 200
since: 10m
grep: "error|warn"

Fields:

FieldTypeDescription
targetstringHost name pattern
sourcestringLog source: journald, file, docker, cmd
unitstringsystemd unit name
filestringPath to log file (for source: file)
cmdstringCommand whose output to tail (for source: cmd)
followboolKeep streaming (-f)
tailintLast N lines to show on connect
sincedurationShow logs since this duration ago
grepstringRegex filter (grep before display)
timestampsboolPrefix lines with timestamps
tuiboolUse terminal UI
outputFilestringWrite log output to this file
maxConcurrencyintMax hosts to tail concurrently
runAsstringRun log command as this user

app

Opens an HTTP app proxy session in the browser.

open-admin:
kind: app
app: "admin-ui"
openBrowser: true

Fields:

FieldTypeDefaultDescription
appstringApp name from apps.* in honey config
openBrowserbooltrueOpen the URL in the default browser

tunnel

Starts a TCP proxy tunnel for a configured app and keeps it running.

tunnel-postgres:
kind: tunnel
app: "postgres-tcp"

Fields:

FieldTypeDescription
appstringApp name from apps.* in honey config

Host targeting

All exec/recipe/logs macros support these additional filter fields alongside target:

FieldDescription
providerComma-separated provider IDs (e.g. gcp,k8s)
backendsComma-separated backend names (e.g. gcp-stg2,k8s-stg)
nameExact host name match
nameRegexGo RE2 regex match on host name

Shell modes

ModeBehavior
autoDetects shell from remote environment; falls back to sh
shForce POSIX /bin/sh
bashForce /bin/bash
rawDirect execution — no shell wrapper
powershellWindows PowerShell with job-based timeout

Full example

apiVersion: honey.shareed2k.io/v1alpha1
kind: MacroSet
metadata:
name: ops-macros
spec:
macros:
restart-nginx:
kind: exec
target: "web-*"
provider: "gcp,k8s"
backends: "gcp-stg2,k8s-stg"
command: "systemctl restart nginx"
parallel: 50
retry: 3
timeout: 10s
shell: auto
runAs: root

restart-and-check-nginx:
kind: exec
target: "web-*"
commands:
- "systemctl restart nginx"
- "systemctl is-active nginx"
- "ss -ltnp | grep :80"
parallel: 20
retry: 2
timeout: 20s

tail-nginx:
kind: logs
target: "web-*"
unit: "nginx"
follow: true
tail: 200
since: 10m
grep: "error|warn"

deploy-recipe:
kind: recipe
target: "web-*"
provider: "gcp"
backends: "gcp-stg2"
recipePath: "examples/recipe/with_run_as.cue"
execute: false
env:
- "APP_ENV=staging"
- "IMAGE_TAG=latest"

open-admin-app:
kind: app
app: "admin-ui"
openBrowser: true

tunnel-postgres:
kind: tunnel
app: "postgres-tcp"

More examples in examples/macros/ on GitHub.