Skip to main content

command

command module

Execute commands directly without going through a shell. This means shell features like pipes (|), redirects (>, <), variable expansion ($VAR), and command substitution will not work. Use the shell module if you need these features.

Examples

- name: Run a simple command
command: ls -la /tmp

- name: Execute with arguments
command: /usr/bin/whoami

- name: Command with explicit path
command: /bin/date +%Y-%m-%d

Note: The command module is safer than shell as it prevents shell injection, but it's more limited in functionality.

Module Capabilities

  • Has Revert: false
  • Provides Variables: None

Inputs

ParameterTypeDescriptionRequiredDefaultChoices
executestringThe command to execute directly without shell interpretation. Shell features like pipes and redirects will not work.false
revertstringThe command to execute when reverting changes made by the execute command.false

Outputs

FieldTypeDescription
commandstringThe actual command executed after templating.
rcint
stderrstring
stdoutstring

Parameter aliases

  • cmd → execute