I’m trying to kill a bunch of processes using an ansible task, but I don’t want the task to fail if there are no processes of interest.
I created a task that looks like this:
- name: kill websocket server
action: shell pgrep -f websockify | xargs kill || true
The problem is that this returns with a -15 return value, despite the || true at the end. Here’s what it looks like if I use the ansible command:
$ ansible vnc -m shell -a “pgrep -f websockify | xargs kill || true” -s
192.168.108.102 | FAILED | rc=-15 >>
Anybody know why I’d get a non-zero return code? If I just run the command as root, when it fails, I do get the 0 return value:
root@precise64:~# pgrep -f websockify | xargs kill || true
Usage:
kill pid … Send SIGTERM to every process listed.
kill signal pid … Send a signal to every process listed.
kill -s signal pid … Send a signal to every process listed.
kill -l List all signal names.
kill -L List all signal names in a nice table.
kill -l signal Convert between signal numbers and names.
root@precise64:~# echo $?
0
Here’s ansible version deatils
$ ansible --version
ansible 0.8 (devel c8854a23ea) last updated 2012/10/07 21:16:36 (GMT -400)