---
- name: Generate service for hawkular-metrics
  template: src=service.j2 dest={{mktemp.stdout}}/templates/metrics-{{obj_name}}-svc.yaml
  vars:
    obj_name: hawkular-metrics
    ports:
    - {port: 443, targetPort: https-endpoint}
    selector:
      name: "{{obj_name}}"
    labels:
      metrics-infra: "{{obj_name}}"
      name: "{{obj_name}}"
  changed_when: no

- name: Generate services for cassandra
  template: src=service.j2 dest={{mktemp.stdout}}/templates/metrics-{{obj_name}}-svc.yaml
  vars:
    obj_name: hawkular-{{item}}
    ports:
    - {name: cql-port, port: 9042, targetPort: cql-port}
    - {name: thrift-port, port: 9160, targetPort: thrift-port}
    - {name: tcp-port, port: 7000, targetPort: tcp-port}
    - {name: ssl-port, port: 7001, targetPort: ssl-port}
    selector:
      type: hawkular-cassandra
    labels:
      metrics-infra: hawkular-cassandra
      name: hawkular-cassandra
    headless: "{{ item == 'cassandra-nodes' }}"
  with_items:
  - cassandra
  - cassandra-nodes
  changed_when: no
