salt icon indicating copy to clipboard operation
salt copied to clipboard

cmd.retcode Behaves Unexpectedly When Using Pipes

Open reverendj1 opened this issue 11 years ago • 3 comments

It seems that when cmd.retcode comes across a pipe, it does not use the return code of the final piped command, but instead, it uses the first one. i.e.

$ sudo salt 'myserver' cmd.retcode "true | false"
myserver:
    0

should return 1 (false), like this:

$ true | false
$ echo $?
1

Conversely,

$ sudo salt 'myserver' cmd.retcode "false | true"
myserver:
    1

should return 0 (true), like this:

$ false | true
$ echo $?
0

I think this was working before, since I use Jinja to run a piped command to see if I need to process certain states.

reverendj1 avatar Jun 01 '15 18:06 reverendj1

What salt version are you using? If it's 2015.5.* it might be related to python_shell now defaulting to False - see warning in

http://docs.saltstack.com/en/latest/topics/releases/2015.5.0.html

tbaker57 avatar Jun 02 '15 20:06 tbaker57

I'm using 2015.5.0, so that would appear to be the issue. I didn't see that announcement. In my case, it should be easy enough for me to fix. Thanks!

reverendj1 avatar Jun 02 '15 20:06 reverendj1

I have tried this on the latest version of the master and minion (both the same version 2015.8.3-1.el6), but the behavior is still wrong.

cmd.retcode 'true | false' still returns 0 instead 1

deyanx avatar Jan 10 '16 21:01 deyanx