---
- name: Remove Service Catalog APIServer
  command: >
    {{ openshift_client_binary }} --config=/etc/origin/master/admin.kubeconfig delete apiservices.apiregistration.k8s.io/v1beta1.servicecatalog.k8s.io --ignore-not-found -n kube-service-catalog

# TODO: this module doesn't currently remove this
#- name: Remove service catalog api service
#  oc_obj:
#    state: absent
#    namespace: "kube-service-catalog"
#    kind: apiservices.apiregistration.k8s.io
#    name: v1beta1.servicecatalog.k8s.io

- name: Remove Service Catalog API Server route
  oc_obj:
    state: absent
    namespace: "kube-service-catalog"
    kind: route
    name: apiserver

- name: Remove Service Catalog API Server service
  oc_obj:
    state: absent
    namespace: "kube-service-catalog"
    kind: service
    name: apiserver

- name: Remove Service Catalog API Server daemonset
  oc_obj:
    state: absent
    namespace: "kube-service-catalog"
    kind: daemonset
    name: apiserver

- name: Remove Controller Manager service
  oc_obj:
    state: absent
    namespace: "kube-service-catalog"
    kind: service
    name: controller-manager

- name: Remove Controller Manager deployment
  oc_obj:
    state: absent
    namespace: "kube-service-catalog"
    kind: deployment
    name: controller-manager

- name: Remove Service Catalog kube-system Role Bindinds
  shell: >
    {{ openshift_client_binary }} --config=/etc/origin/master/admin.kubeconfig process kube-system-service-catalog-role-bindings -n kube-system | {{ openshift_client_binary }} --config=/etc/origin/master/admin.kubeconfig delete --ignore-not-found -f -

- oc_obj:
    kind: template
    name: "kube-system-service-catalog-role-bindings"
    namespace: kube-system
    state: absent

- name: Remove Service Catalog kube-service-catalog Role Bindinds
  shell: >
    {{ openshift_client_binary }} --config=/etc/origin/master/admin.kubeconfig process service-catalog-role-bindings -n kube-service-catalog | {{ openshift_client_binary }} --config=/etc/origin/master/admin.kubeconfig delete --ignore-not-found -f -

- oc_obj:
    kind: template
    name: "service-catalog-role-bindings"
    namespace: kube-service-catalog
    state: absent

- name: Remove Service Catalog namespace
  oc_project:
    state: absent
    name: "kube-service-catalog"
