filebeat/playbooks/roles/filebeat/tasks/stop_old_filebeat.yml

23 lines
997 B
YAML

---
- name: Get Old Running Supervisor Processes {{ target }}
ansible.builtin.shell: "ps -ef | grep -v grep | grep -w /data/opt/filebeat/{{ instance_name }}/supervisor.yml | awk '{print $2}'"
register: supervisor_processes
changed_when: supervisor_processes.stdout != ''
- name: Get Old Running Filebeat Processes {{ target }}
ansible.builtin.shell: "ps -ef | grep -v grep | grep -w /data/opt/filebeat/{{ instance_name }}/filebeat | awk '{print $2}'"
register: filebeat_processes
changed_when: filebeat_processes.stdout != ''
- name: Stop Old Filebeat Processes {{ target }}
ansible.builtin.shell: "kill -9 {{ (supervisor_processes.stdout_lines + filebeat_processes.stdout_lines) | join(' ') }}"
when: supervisor_processes.stdout != '' or filebeat_processes.stdout != ''
- name: Remove Old Processes Residue
ansible.builtin.shell: "/bin/rm -vf /tmp/supervisord_{{ instance_name }}.* /tmp/filebeat_{{ target }}*.log"
register: residue
changed_when: residue.stdout != ''