This Ansible collection includes Ansible modules for managing processes with the psutils package.
- psutil_kill
ansible-galaxy collection install moreati.psutil
- name: Exercise psutil
hosts: localhost
gather_facts: false
tasks:
- shell:
cmd: |
echo $$
sleep 20 &
echo $!
register: sleepers
- moreati.psutil.psutil_kill:
pids: "{{ sleepers.stdout_lines }}"
register: killers