On Sun, 7 Oct 2012, Lorin Hochstein wrote:
> 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
I would go for:
- name: kill websocket server
action: shell pkill -f websockify
ignore_errors: True
> 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:
Might be a bug worth fixing, although I cannot reproduce this:
----
- hosts: all
gather_facts: False
tasks:
- name: 'Testing shell module #1'
action: shell true | false || true
- name: 'Testing shell module #2'
action: shell false | false || true
- name: 'Testing shell module #3'
action: shell false | true || true
----
gives me:
----
[root@moria ansible]# ansible-playbook -l localhost test9.yml
PLAY [all] *********************
TASK: [Testing shell module #1] *********************
changed: [localhost]
TASK: [Testing shell module #2] *********************
changed: [localhost]
TASK: [Testing shell module #3] *********************
changed: [localhost]
PLAY RECAP *********************
localhost : ok=3 changed=3 unreachable=0 failed=0
----
Kind regards,
--
-- dag wieers,
d...@wieers.com,
http://dag.wieers.com/
-- dagit linux solutions,
in...@dagit.net,
http://dagit.net/
[Any errors in spelling, tact or fact are transmission errors]