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

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

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

- name: jaeger tpcc delete
  kubernetes.core.helm:
    chart_ref: "/root/jaeger-tpcc"
    name: jaeger-tpcc
    namespace: default
    state: absent
    wait: true
  when:
    - inventory_hostname == groups['agent-master'][0]

- name: jaeger client delete
  kubernetes.core.helm:
    chart_ref: "/root/jaeger-client"
    name: jaeger-client
    namespace: "{{ NAMESAPCE }}"
    state: absent
    wait: true
  when:
    - inventory_hostname == groups['agent-master'][0]

- 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 jaeger-client directory delete
  ignore_errors: true
  file:
    path: /root/jaeger-client
    state: absent
  when:
    - delete_enabled
    - inventory_hostname in groups['docker'] or inventory_hostname in groups['containerd'] or inventory_hostname in groups['crio']

- name: old jaeger-tpcc directory delete
  ignore_errors: true
  file:
    path: /root/jaeger-tpcc
    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']
