cmd.retcode Behaves Unexpectedly When Using Pipes
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.
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
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!
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