Ansible logoAnsible/
ANS-E3006

Shells that use pipes should set the `pipefail` optionANS-E3006

Major severityMajor
Bug Risk categoryBug Risk

Without the pipefail option set, a shell command that implements a pipeline can fail and still return 0.

If 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.

Bad practice

- name: Example task
 shell: ls -ld /tmp | tr -d tmp
 args:
   executable: /usr/bin/bash

It is recommended to use pipefail with shell commands that use pipes.

- name: Example task
  shell: set -o pipefail && ls -ld /tmp | tr -d tmp
  args:
    executable: /usr/bin/bash