Skip to content

Commit

Permalink
use pipefail if shell uses pipes (#189)
Browse files Browse the repository at this point in the history
Signed-off-by: Rich Megginson <[email protected]>
  • Loading branch information
richm authored Apr 10, 2023
1 parent 5fc6735 commit d83490e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
7 changes: 6 additions & 1 deletion tests/tests_ntp_provider3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,10 @@
timeout: 2

- name: Check ntpd service
shell: ntpq -c rv | grep 'associd=0'
shell: |
set -eu
if set -o | grep -q pipefail; then
set -o pipefail # no pipefail on debian, some ubuntu
fi
ntpq -c rv | grep 'associd=0'
changed_when: false
7 changes: 6 additions & 1 deletion tests/tests_ntp_provider5.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,10 @@
timeout: 2

- name: Check ntpd service
shell: ntpq -c rv | grep 'associd=0'
shell: |
set -eu
if set -o | grep -q pipefail; then
set -o pipefail # no pipefail on debian, some ubuntu
fi
ntpq -c rv | grep 'associd=0'
changed_when: false
14 changes: 12 additions & 2 deletions tests/tests_ntp_provider6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@
changed_when: false

- name: Check ntpd service
shell: ntpq -c rv | grep 'associd=0'
shell: |
set -eu
if set -o | grep -q pipefail; then
set -o pipefail # no pipefail on debian, some ubuntu
fi
ntpq -c rv | grep 'associd=0'
when: not is_ntp_default
changed_when: false

Expand All @@ -88,7 +93,12 @@
timeout: 2

- name: Check ntpd service
shell: ntpq -c rv | grep 'associd=0'
shell: |
set -eu
if set -o | grep -q pipefail; then
set -o pipefail # no pipefail on debian, some ubuntu
fi
ntpq -c rv | grep 'associd=0'
when: is_ntp_default | bool
changed_when: false

Expand Down

0 comments on commit d83490e

Please sign in to comment.