---
- name: Check if cluster rolebinding {{ clusterrole_name }}-{{ enmasse_serviceaccount }} exists
  shell: oc get clusterrolebinding {{ clusterrole_name}}-{{ enmasse_serviceaccount }}
  register: rolebinding_exists
  ignore_errors: true

- name: Grant clusterrole {{ clusterrole_name}} privileges to service account
  when: rolebinding_exists.failed
  shell: oc create clusterrolebinding {{ clusterrole_name }}-{{ enmasse_serviceaccount }} --clusterrole={{ clusterrole_name }} --serviceaccount={{ namespace }}:{{ enmasse_serviceaccount }}


---
- name: Check if cluster rolebinding {{ clusterrole_name }}-{{ namespace }}-{{ enmasse_serviceaccount }} exists
  shell: oc get clusterrolebinding {{ clusterrole_name}}-{{ namespace }}-{{ enmasse_serviceaccount }}
  register: rolebinding_exists
  ignore_errors: true

- name: Grant clusterrole {{ clusterrole_name}} privileges to service account
  when: rolebinding_exists.failed
  shell: oc create clusterrolebinding {{ clusterrole_name }}-{{ namespace }}-{{ enmasse_serviceaccount }} --clusterrole={{ clusterrole_name }} --serviceaccount={{ namespace }}:{{ enmasse_serviceaccount }}


Create clusterrolebindings that allow multiple instances of EnMasse
Create clusterrolebindings that allow multiple instances of EnMasse
