--- # Ensures all the operator artifacts are created and waits for CSV to succeed. # # The following variables must exist: # # added_operators: (list) # - catalog: the catalog of the manifest # package: the name of the packagemanifest # subscription: the name of the subscription (optional, defaults to package) # channel: which channel to install from # namespace: target namespace for subscription # desired_csv: for verification - wait for this CSV to appear # og_namespaces: (list) operatorgroup namespaces (XXX not currently used XXX) # # This role must then be applied as: # # - include_role: # name: deploy-operators # loop: "{{ added_operators }}" # 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. # # NOTE: Do NOT test by checking for presence of API resources - they do not always get cleaned up. # - name: Make sure the namespace is there k8s: kubeconfig: tmp/kubeconfig-ocp4 validate_certs: no api_version: v1 kind: namespace name: "{{ role.namespace }}" # TODO: Finish this at some point. # TODO: Just apply from role.og_namespaces - finding an OG or just applying a default name. #- name: Make sure the namespace has a properly configured OperatorGroup # k8s_info: # kubeconfig: tmp/kubeconfig-ocp4 # validate_certs: no # api_version: operators.coreos.com/v1 # kind: operatorgroup # namespace: "{{ op_nsp }}" # register: found_opgrp - name: Also make sure there is a subscription k8s: kubeconfig: tmp/kubeconfig-ocp4 validate_certs: no api_version: operators.coreos.com/v1alpha1 kind: subscription namespace: "{{ role.namespace }}" name: "{{ role.subscription | default(role.package) }}" definition: spec: source: "{{ role.catalog }}" sourceNamespace: openshift-marketplace name: "{{ role.package }}" channel: "{{ role.channel }}" startingCSV: "{{ role.desired_csv }}" installPlanApproval: Automatic # TODO: Finish this at some point. #- name: Wait for installPlan to show up # k8s_info: # kubeconfig: tmp/kubeconfig-ocp4 # validate_certs: no # api_version: operators.coreos.com/v1alpha1 # kind: installplan # namespace: "{{ op_nsp }}" # register: installplan # until: # - installplan.resources is defined # - (installplan.resources | length) > 0 # - installplan.resources[0].spec.approved # retries: 12 # delay: 10 - name: Wait for CSV to show up and complete k8s_info: kubeconfig: tmp/kubeconfig-ocp4 validate_certs: no api_version: operators.coreos.com/v1alpha1 kind: clusterserviceversion namespace: "{{ role.namespace }}" name: "{{ role.desired_csv }}" register: new_csv until: - new_csv.resources is defined - (new_csv.resources | length) > 0 - new_csv.resources[0].status is defined - new_csv.resources[0].status.phase == "Succeeded" retries: 30 delay: 10 # TODO: Finish this at some point. #- name: Finally, wait for the pod # k8s_info: # kubeconfig: tmp/kubeconfig-ocp4 # validate_certs: no # api_version: v1 # kind: pod # namespace: rhsso # label_selectors: # - name = rhsso-operator # register: sso_pod # until: # - sso_pod.resources is defined # - (sso_pod.resources | length) > 0 # - sso_pod.resources[0].status is defined # - sso_pod.resources[0].status.phase == "Running" # retries: 30 # delay: 10 ...