You ansible shell command is executed slightly differently from what you could write manually inside your linux console.
For instance the following command executed manually will display nothing.
ps -ef | grep java | grep nicotest1 | grep testmode=false
But the same command with ansible will display itself:
root 1040991 943024 0 14:55 pts/0 00:00:00 /bin/bash -c ps -ef | grep java | grep nicotest1 | grep testmode=false
The reason is that ansible execute your shell instructions as a unique command:
/bin/sh -c "ps -ef | grep java | grep nicotest1 | grep testmode=false"
Then the process created by /bin/sh -c will be displayed by ps -ef.
It’s a detail, but can be surprising sometimes for instance:
ps -ef | grep java | grep nicotest1 | grep testmode=false | wc -l
it will display 0 inside your linux console, but 1 when executed by ansible.
Leave a Reply