cleanup_logging.yaml 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. ---
  2. - name: "Checking for logging project"
  3. command: oc get project logging
  4. register: logging_project
  5. failed_when: "'FAILED' in logging_project.stderr"
  6. - name: "Changing projects"
  7. command: "{{ openshift.common.client_binary }} project logging"
  8. - name: Create temp directory for kubeconfig
  9. command: mktemp -d /tmp/openshift-ansible-XXXXXX
  10. register: mktemp
  11. changed_when: False
  12. - name: Copy the admin client config(s)
  13. command: >
  14. cp {{ openshift_master_config_dir }}/admin.kubeconfig {{ mktemp.stdout }}/admin.kubeconfig
  15. changed_when: False
  16. - name: "Changing projects"
  17. command: oc project logging
  18. - name: "Cleanup any previous logging infrastructure"
  19. command: "{{ openshift.common.client_binary }} delete --ignore-not-found all --selector logging-infra={{ item }}"
  20. with_items:
  21. - kibana
  22. - fluentd
  23. - elasticsearch
  24. ignore_errors: yes
  25. - name: "Cleanup existing support infrastructure"
  26. command: "{{ openshift.common.client_binary }} delete --ignore-not-found all,sa,oauthclient --selector logging-infra=support"
  27. ignore_errors: yes
  28. - name: "Cleanup existing secrets"
  29. command: "{{ openshift.common.client_binary }} delete secret logging-fluentd logging-elasticsearch logging-es-proxy logging-kibana logging-kibana-proxy logging-kibana-ops-proxy"
  30. ignore_errors: yes
  31. register: clean_result
  32. failed_when: clean_result.rc == 1 and 'not found' not in clean_result.stderr
  33. - name: "Cleanup existing logging deployers"
  34. command: "{{ openshift.common.client_binary }} delete pods --all"
  35. - name: "Cleanup logging project"
  36. command: "{{ openshift.common.client_binary }} delete project logging"
  37. - name: "Remove deployer template"
  38. command: "{{ openshift.common.client_binary }} delete template logging-deployer-template -n openshift"
  39. register: delete_ouput
  40. failed_when: delete_ouput.rc == 1 and 'exists' not in delete_ouput.stderr
  41. - name: Delete temp directory
  42. file:
  43. name: "{{ mktemp.stdout }}"
  44. state: absent
  45. changed_when: False
  46. - debug: msg="Success!"