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
Parameter | Type | Description | Required | Default | Choices |
---|---|---|---|---|---|
execute | string | The command to execute directly without shell interpretation. Shell features like pipes and redirects will not work. | false | ||
revert | string | The command to execute when reverting changes made by the execute command. | false |
Outputs
Field | Type | Description |
---|---|---|
command | string | The actual command executed after templating. |
rc | int | |
stderr | string | |
stdout | string |
Parameter aliases
- cmd → execute