---
- name: remove Hawkular Agent (HOSA) components
  command: >
    {{ openshift_client_binary }} -n {{ openshift_metrics_hawkular_agent_namespace }} --config={{ mktemp.stdout }}/admin.kubeconfig
    delete --ignore-not-found --selector=metrics-infra=agent
    all,sa,secrets,templates,routes,pvc,rolebindings,clusterrolebindings,daemonsets,clusterroles,configmaps
  register: delete_metrics
  changed_when: delete_metrics.stdout != 'No resources found'

- name: remove rolebindings
  command: >
    {{ openshift_client_binary }} -n {{ openshift_metrics_hawkular_agent_namespace }} --config={{ mktemp.stdout }}/admin.kubeconfig
    delete --ignore-not-found
    clusterrolebinding/hawkular-openshift-agent-rb
  changed_when: delete_metrics.stdout != 'No resources found'
