maand run_command
run_command runs an arbitrary shell command on one or more workers over SSH from the maand CLI host.
CLI
maand run_command [command] [flags]
| Flag | Description |
|---|---|
--workers |
-w |
--labels |
-l |
--concurrency |
-c |
--health_check |
|
--ignore-failure |
Examples:
maand run_command "uptime"
maand run_command "df -h /opt/worker" --workers 10.0.0.1,10.0.0.2
maand run_command "hostname" --concurrency 4
maand run_command "uptime" --ignore-failure
Exit code
Exit 0 when every selected worker succeeds. Exit 1 when any worker fails (including with --ignore-failure, which still runs reachable workers and writes their logs before reporting failures).
Prerequisites
- Initialized bucket with workers in
workspace/workers.jsonand a priormaand build. - SSH key at
secrets/<ssh_key>(frommaand.conf) authorized on workers. - Host tools:
bash,ssh(checked before SSH). - Target workers must have
bashandtimeoutonPATH(sudowhenuse_sudo = true).
Notes
- Commands run on workers as the configured
ssh_user(defaultagent). - Working directory: scripts start in the worker's bucket directory
/opt/worker/$BUCKET_ID, so relative paths likejobs/<job>/...resolve directly. If the bucket has not been deployed yet (no such directory), it falls back to the SSH login directory so host-bootstrap commands still work. BUCKET_IDandWORKER_IPare exported into every script.- Concurrency: without
--health_check, at most-cworkers run at once; the next worker starts as soon as a slot frees (command output streams to the terminal as each worker runs). With--health_check, workers run in fixed batches of-cand jobs are health-checked after each batch. - With
--ignore-failure, worker command output still streams for reachable workers; each failure is printed to stderr as it happens, and failures are reported again at exit.--ignore-failureand--health_checkcannot be used on the same command. - This is separate from hooks (
pre_deploy,job_control, etc.) which use the runtime API and job workspaces.