Documentation
PLEASE NOTE: This document applies to latest version and not to the latest stable release v2.21
Documentation for other releases can be found by using the version selector in the top right of any doc page.shell
Execute shell commands with pipe support, redirections, and environment variables. This module extends the command module by providing full shell features including pipes, redirections, environment variable expansion, shell glob expansion, and subshell execution.
Attributes
check_mode:
support: full
Parameters
| Parameter | Required | Type | Values | Description |
|---|---|---|---|---|
| cmd | true | string | The shell command to execute. | |
| executable | string | Shell to use for command execution. [default: "/bin/sh"] |
||
| chdir | string | Change into this directory before running the command. | ||
| creates | string | A filename, when it already exists, this step will not be run. | ||
| removes | string | A filename, when it does not exist, this step will not be run. | ||
| stdin | string | Set stdin for the command. |
{$include_doc /// ## Example
///
/// yaml
/// - shell:
/// cmd: cat /var/log/app.log | grep ERROR | wc -l
/// register: error_count
///
/// - shell: echo "hello world" | tr a-z A-Z
/// register: upper
///
/// - shell:
/// cmd: find . -name "*.log" -mtime +7 -delete
/// chdir: /var/log
///
/// - shell:
/// cmd: process_data.sh < input.txt > output.txt
/// executable: /bin/bash
///
/// - shell:
/// cmd: echo "file exists"
/// creates: /tmp/marker
///
/// - shell:
/// cmd: echo "file removed"
/// removes: /tmp/cleanup-target
///}