---
- name: agent container delete - docker
  shell: /root/host-agent/default_stop.sh
  ignore_errors: true
  when:
    - delete_enabled
    - inventory_hostname in groups['docker']

- name: agent container delete - containerd
  shell: /root/host-agent/default_stop.sh
  ignore_errors: true
  when:
    - delete_enabled
    - inventory_hostname in groups['containerd']

- name: agent conatiner delete - podman
  shell: /root/host-agent/default_stop.sh
  ignore_errors: true
  when:
    - delete_enabled
    - inventory_hostname in groups['crio']

- name: old host-agent directory delete
  ignore_errors: true
  file:
    path: /root/host-agent
    state: absent
  when:
    - delete_enabled
    - inventory_hostname in groups['docker'] or inventory_hostname in groups['containerd'] or inventory_hostname in groups['crio']

- name: old host-agent.tar.gz delete
  ignore_errors: true
  file:
    path: /root/host-agent.tar.gz
    state: absent
  when:
    - delete_enabled
    - inventory_hostname in groups['docker'] or inventory_hostname in groups['containerd'] or inventory_hostname in groups['crio']