Minor: Forced Translation

Earlier today, we ran into an unpleasant problem caused by the following shell message:

- name: get remote branches
  shell: git ls-remote -h git@bitbucket.org:orga/repo.git | sed 's_.*refs/heads/__g'
  register: branches_remote

The command gitfailed, but the return code of the entire channel is 0. This is the default behavior of bash / sh .

To fix this, in sh / bash you can set -o pipefailor set -e. Is it possible to do this in the inaccessible, preferably globally for all my teams shell?

+4
source share
1 answer

, , , , . , , . bash.

[user@ansible ~]$ ansible myhost -m shell -a "executable=/bin/bash set -o pipefail && false | echo hello there"
myhost | FAILED | rc=1 >>
hello there

[user@ansible ~]$ ansible myhost -m shell -a "executable=/bin/bash set -o pipefail && true | echo hello there"
myhost | success | rc=0 >>
hello there
+3

Source: https://habr.com/ru/post/1612924/


All Articles