---
- name: Set default Interconnect manifest
  set_fact:
    interconnect_manifest: |
      apiVersion: interconnectedcloud.github.io/v1alpha1
      kind: Interconnect
      metadata:
        name: '{{ meta.name }}-interconnect'
        namespace: '{{ meta.namespace }}'
      spec:
        deploymentPlan:
          size: {{ servicetelemetry_vars.transports.qdr.deployment_size }}
          role: interior
          livenessPort: 8888
          placement: AntiAffinity
        addresses:
          - distribution: closest
            prefix: closest
          - distribution: multicast
            prefix: multicast
          - distribution: closest
            prefix: unicast
          - distribution: closest
            prefix: exclusive
          - distribution: multicast
            prefix: broadcast
          - distribution: multicast
            prefix: collectd
          - distribution: multicast
            prefix: ceilometer
        edgeListeners:
          - expose: true
            host: 0.0.0.0
            port: 5671
            saslMechanisms: ANONYMOUS
            sslProfile: openstack
          - port: 5673
            linkCapacity: 25000
        interRouterListeners:
          - authenticatePeer: true
            expose: true
            port: 55671
            saslMechanisms: EXTERNAL
            sslProfile: inter-router
        listeners:
          - port: 5672
          - expose: {{ servicetelemetry_vars.transports.qdr.web.enabled }}
            http: true
            port: 8672
        sslProfiles:
          - caCert: {{ meta.name }}-interconnect-openstack-ca
            credentials: {{ meta.name }}-interconnect-openstack-credentials
            generateCaCert: true
            generateCredentials: true
            name: openstack
          - caCert: {{ meta.name }}-interconnect-inter-router-ca
            credentials: {{ meta.name }}-interconnect-inter-router-credentials
            generateCaCert: true
            generateCredentials: true
            mutualAuth: true
            name: inter-router
  when: interconnect_manifest is not defined

- name: Create QDR instance
  k8s:
    state: '{{ "present" if servicetelemetry_vars.transports.qdr.enabled else "absent" }}'
    definition:
      '{{ interconnect_manifest }}'
