---
- name: Generating hawkular serviceaccount
  template: src=serviceaccount.j2 dest={{mktemp.stdout}}/templates/metrics-{{obj_name}}-sa.yaml
  vars:
    obj_name: hawkular
    labels:
      metrics-infra: support
    secrets:
    - hawkular-metrics-account
    - hawkular-metrics-certs
  changed_when: no

- name: Generating cassandra serviceaccount
  template: src=serviceaccount.j2 dest={{mktemp.stdout}}/templates/metrics-{{obj_name}}-sa.yaml
  vars:
    obj_name: cassandra
    labels:
      metrics-infra: support
    secrets:
    - hawkular-cassandra-certs
  changed_when: no

- name: Set serviceaccounts for hawkular metrics/cassandra
  oc_obj:
    name: "{{ item }}"
    kind: serviceaccount
    namespace: "{{ openshift_metrics_project }}"
    files:
    - "{{ mktemp.stdout }}/templates/metrics-{{ item }}-sa.yaml"
    delete_after: true
  with_items:
  - hawkular
  - cassandra
