---
- name: Setup OperatorHub dependencies
  k8s:
    definition:
      apiVersion: config.openshift.io/v1
      kind: OperatorHub
      metadata:
        name: cluster
      spec:
        disableAllDefaultSources: true
        sources:
        - disabled: false
          name: certified-operators
        - disabled: false
          name: redhat-operators

- name: Create OperatorGroup
  k8s:
    definition:
      apiVersion: operators.coreos.com/v1
      kind: OperatorGroup
      metadata:
        name: service-telemetry-operator-group
        namespace: "{{ namespace }}"
      spec:
        targetNamespaces:
        - "{{ namespace }}"

- name: Enable AMQ Certificate Manager CatalogSource (redhat-operators-stf)
  k8s:
    definition:
      apiVersion: operators.coreos.com/v1alpha1
      kind: CatalogSource
      metadata:
        name: redhat-operators-stf
        namespace: openshift-marketplace
      spec:
        displayName: Red Hat STF Operators
        image: quay.io/redhat-operators-stf/stf-catalog:stable
        publisher: Red Hat
        sourceType: grpc
        updateStrategy:
          registryPoll:
            interval: 30m

- name: Subscribe to AMQ Certificate Manager Operator
  k8s:
    definition:
      apiVersion: operators.coreos.com/v1alpha1
      kind: Subscription
      metadata:
        name: amq7-cert-manager-operator
        namespace: openshift-operators
      spec:
        channel: alpha
        installPlanApproval: Automatic
        name: amq7-cert-manager-operator
        source: redhat-operators-stf
        sourceNamespace: openshift-marketplace
        targetNamespaces: global

- name: Enable OperatorHub.io for Elastic Cloud on Kubernetes
  k8s:
    definition:
      apiVersion: operators.coreos.com/v1alpha1
      kind: CatalogSource
      metadata:
        name: operatorhubio-operators
        namespace: openshift-marketplace
      spec:
        sourceType: grpc
        image: quay.io/operator-framework/upstream-community-operators:latest
        displayName: OperatorHub.io Operators
        publisher: OperatorHub.io

- name: Subscribe to Elastic Cloud on Kubernetes Operator
  k8s:
    definition:
      apiVersion: operators.coreos.com/v1alpha1
      kind: Subscription
      metadata:
        name: elastic-cloud-eck
        namespace: "{{ namespace }}"
      spec:
        channel: stable
        installPlanApproval: Automatic
        name: elastic-cloud-eck
        source: operatorhubio-operators
        sourceNamespace: openshift-marketplace

- name: Subscribe to AMQ Interconnect Operator
  k8s:
    definition:
      apiVersion: operators.coreos.com/v1alpha1
      kind: Subscription
      metadata:
        name: amq7-interconnect-operator
        namespace: "{{ namespace }}"
      spec:
        channel: 1.2.0
        installPlanApproval: Automatic
        name: amq7-interconnect-operator
        source: redhat-operators
        sourceNamespace: openshift-marketplace

- name: Subscribe to Prometheus Operator
  k8s:
    definition:
      apiVersion: operators.coreos.com/v1alpha1
      kind: Subscription
      metadata:
        name: prometheus
        namespace: "{{ namespace }}"
      spec:
        channel: beta
        installPlanApproval: Automatic
        name: prometheus
        source: operatorhubio-operators
        sourceNamespace: openshift-marketplace
