Ansible

Ansible

Made by DeepSource

Shells that use pipes should set the pipefail option ANS-E3006

Bug risk
Major

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

Recommended

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