---
- name: remove metrics-server components
  command: >
    {{ openshift_client_binary }} -n {{ openshift_metrics_server_project }} --config={{ mktemp.stdout }}/admin.kubeconfig
    delete --ignore-not-found --selector=metrics-server-infra
    all,sa,secrets,rolebindings,clusterrolebindings,clusterrole,apiservice,deployment
  register: delete_metrics_server
  changed_when: delete_metrics_server.stdout != 'No resources found'

- name: remove metrics-server system components
  command: >
    {{ openshift_client_binary }} -n kube-system --config={{ mktemp.stdout }}/admin.kubeconfig
    delete --ignore-not-found --selector=metrics-server-infra
    rolebindings
  register: delete_metrics_server
  changed_when: delete_metrics_server.stdout != 'No resources found'
