Skip to content

Commit

Permalink
command-instead-of-module: improve documentation (#2356)
Browse files Browse the repository at this point in the history
* command-instead-of-module: improve documentation

* chore: auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
ssbarnea and pre-commit-ci[bot] committed Aug 29, 2022
1 parent 67b032c commit 69f27f1
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/ansiblelint/rules/command_instead_of_shell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# command-instead-of-shell

This rule identifies uses of `shell` modules instead of a `command` one when
this is not really needed. Shell is considerably slower than command and should
be avoided unless there is a special need for using shell features, like
environment variable expansion or chaining multiple commands using pipes.

## Problematic Code

```yaml
---
- name: Problematic example
hosts: localhost
tasks:
- name: Echo a message
ansible.builtin.shell: echo hello # <-- command is better in this case
changed_when: false
```

## Correct Code

```yaml
---
- name: Correct example
hosts: localhost
tasks:
- name: Echo a message
ansible.builtin.command: echo hello
changed_when: false
```

0 comments on commit 69f27f1

Please sign in to comment.