|
|
@@ -0,0 +1,117 @@
|
|
|
+---
|
|
|
+# Adds a new catalog source to the cluster.
|
|
|
+#
|
|
|
+# NOTE: If a catalog source is added to a namespace other than
|
|
|
+# openshift-marketplace, operators can only be installed in that same
|
|
|
+# namespace.
|
|
|
+#
|
|
|
+# REQUIRED:
|
|
|
+#
|
|
|
+# added_catalogs:
|
|
|
+# - image: the container image serving the catalog source
|
|
|
+# name: the name for the catalog
|
|
|
+# namespace: the namespace where it should be created
|
|
|
+# display_name: display name for the catalog
|
|
|
+# publisher: the name of the publisher
|
|
|
+# catalog_type: (optional) the type of catalog, defaults to grpc
|
|
|
+# verify_mft: (optional) the manifest to check for to verify content provisioning
|
|
|
+#
|
|
|
+# This role must be applied as:
|
|
|
+#
|
|
|
+# - include_role:
|
|
|
+# name: add-catalog
|
|
|
+# loop: "{{ added_catalogs }}"
|
|
|
+# loop_control:
|
|
|
+# loop_var: role
|
|
|
+#
|
|
|
+# What this means is that each item of added_operators is expected to be
|
|
|
+# placed in the "role" variable prior to iterating over this role.
|
|
|
+#
|
|
|
+# OPTIONAL:
|
|
|
+#
|
|
|
+# kubeadmin_config kubeadmin (or other admin) credentials (tmp/kubeconfig-ocp4)
|
|
|
+#
|
|
|
+# TODO: verify required variables are set
|
|
|
+- name: Wait for the marketplace-operator to be up
|
|
|
+ kubernetes.core.k8s_info:
|
|
|
+ kubeconfig: "{{ kubeadmin_config }}"
|
|
|
+ validate_certs: no
|
|
|
+ api_version: v1
|
|
|
+ kind: pod
|
|
|
+ namespace: openshift-marketplace
|
|
|
+ label_selectors:
|
|
|
+ - name=marketplace-operator
|
|
|
+ register: mktplc_pod
|
|
|
+ until:
|
|
|
+ - (mktplc_pod.resources | length) == 1
|
|
|
+ - mktplc_pod.resources[0].status.containerStatuses[0].ready
|
|
|
+ retries: 30
|
|
|
+ delay: 10
|
|
|
+
|
|
|
+- name: Make sure the target namespace exists
|
|
|
+ kubernetes.core.k8s:
|
|
|
+ kubeconfig: "{{ kubeadmin_config }}"
|
|
|
+ validate_certs: no
|
|
|
+ api_version: v1
|
|
|
+ kind: namespace
|
|
|
+ name: "{{ role.namespace }}"
|
|
|
+ resource_definition:
|
|
|
+ metadata:
|
|
|
+ annotations:
|
|
|
+ capability.openshift.io/name: marketplace
|
|
|
+ labels:
|
|
|
+ openshift.io/cluster-monitoring: "true"
|
|
|
+
|
|
|
+- name: Create the catalog source if not there yet, or patch it
|
|
|
+ kubernetes.core.k8s:
|
|
|
+ kubeconfig: "{{ kubeadmin_config }}"
|
|
|
+ validate_certs: no
|
|
|
+ api_version: operators.coreos.com/v1alpha1
|
|
|
+ kind: catalogsource
|
|
|
+ namespace: "{{ role.namespace }}"
|
|
|
+ name: "{{ role.name }}"
|
|
|
+ resource_definition:
|
|
|
+ spec:
|
|
|
+ sourceType: "{{ role.catalog_type | default('grpc') }}"
|
|
|
+ image: "{{ role.image }}"
|
|
|
+ displayName: "{{ role.display_name }}"
|
|
|
+ publisher: "{{ role.publisher }}"
|
|
|
+
|
|
|
+- name: Wait for the catalog source to be ready
|
|
|
+ kubernetes.core.k8s_info:
|
|
|
+ kubeconfig: "{{ kubeadmin_config }}"
|
|
|
+ validate_certs: no
|
|
|
+ api_version: operators.coreos.com/v1alpha1
|
|
|
+ kind: catalogsource
|
|
|
+ namespace: "{{ role.namespace }}"
|
|
|
+ name: "{{ role.name }}"
|
|
|
+ register: cat_stat
|
|
|
+ until:
|
|
|
+ - (cat_stat.resources | length) == 1
|
|
|
+ - cat_stat.resources[0].status is defined
|
|
|
+ - cat_stat.resources[0].status.connectionState is defined
|
|
|
+ - cat_stat.resources[0].status.connectionState.lastObservedState == "READY"
|
|
|
+ retries: 30
|
|
|
+ delay: 10
|
|
|
+
|
|
|
+- name: Verify correct deployment
|
|
|
+ block:
|
|
|
+ - name: Wait for the operator packagemanifest to appear
|
|
|
+ kubernetes.core.k8s_info:
|
|
|
+ kubeconfig: "{{ kubeadmin_config }}"
|
|
|
+ validate_certs: no
|
|
|
+ api_version: packages.operators.coreos.com/v1
|
|
|
+ kind: packagemanifest
|
|
|
+ namespace: "{{ role.namespace }}"
|
|
|
+ name: "{{ role.verify_mft }}"
|
|
|
+ register: vrfy_mft
|
|
|
+ until:
|
|
|
+ - (vrfy_mft.resources | length) == 1
|
|
|
+ - vrfy_mft.resources[0].status.catalogSource == role.name
|
|
|
+ - vrfy_mft.resources[0].status.packageName == role.verify_mft
|
|
|
+ retries: 60
|
|
|
+ delay: 10
|
|
|
+
|
|
|
+ when:
|
|
|
+ - role.verify_mft is defined
|
|
|
+...
|