cleanup_logging.yaml 2.4 KB

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