Skip to content

command

!command

Category: commands

Run a single command on the target directly, without a shell. Safer than !shell (no injection) but no pipes, redirection, or builtins unless unsafe: true.

Notes

  • Forbidden unless unsafe: ; < > & * ? { } [ ] $ backtick — and no pipes or shell builtins.
  • chdir is rendered per host/item after skip conditions and must be an absolute path in the execution target’s filesystem. Relative, empty, tilde, and NUL-containing paths are rejected. The path is passed literally, without controller-side resolution. Directory entry happens inside the sudo context and affects only this command. A missing or inaccessible directory fails before the command, regardless of failed_when. Plan validates path syntax without entering the directory.

Parameters

NameTypeRequiredDescription
cmdstringyesThe command line to execute (templated).
chdirpathnoAbsolute working directory on the execution target (templated). Omission preserves the target’s default directory.
savestringnoVariable name to save { rc, out } from the run.
failed_whenconditionnoExpression overriding the default fail-when-rc-nonzero.
changed_whenconditionnoExpression overriding the default always-changed.
unsafeboolnoAllow shell metacharacters in a templated cmd. Default false; auto-true when cmd has no templating.

Examples

- !command
  name: check disk usage
  cmd: df -h /
  save: disk_result