Using Ansible i have this simple task :
- name: kill selected APIS processes on API SERVER
shell: kill $(pgrep -f {{item}})
This process would be well killed but the task throws an error :
failed: "msg": "non-zero return code",
As indicated , maybe i should force my shell script to return 0 value (success)
kill $(pgrep -f {{item}})
how to do it ?
The typical idiom to always return 0 is kill $(pgrep -f {{item}}) || true
kill $(pgrep -f {{item}}) || true
But in ansible, it would seem sensible to use ignore_errors
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.