Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/ansiblelint/rules/risky_shell_pipe.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ The return status of a pipeline is the exit status of the command. The
`pipefail` option ensures that tasks fail as expected if the first command
fails.

This does not work in the standard (POSIX) shell. You will need to set the executable
to a different shell, such as bash. See the example below.

As this requirement does not apply to PowerShell, for shell commands that have
`pwsh` inside `executable` attribute, this rule will not trigger.

Expand Down
5 changes: 3 additions & 2 deletions src/ansiblelint/rules/risky_shell_pipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


class ShellWithoutPipefail(AnsibleLintRule):
"""Shells that use pipes should set the pipefail option."""
"""Shells that use pipes should set the pipefail option. NB: This requires changing the shell, see the docs."""

id = "risky-shell-pipe"
description = (
Expand All @@ -24,7 +24,8 @@ class ShellWithoutPipefail(AnsibleLintRule):
"any part of the pipeline other than the terminal command "
"fails, the whole pipeline will still return 0, which may "
"be considered a success by Ansible. "
"Pipefail is available in the bash shell."
"Pipefail is not available in the default (POSIX) shell, "
"consider bash."
)
severity = "MEDIUM"
tags = ["command-shell"]
Expand Down