|
| 1 | +--- |
| 2 | +# Copyright Red Hat, Inc. |
| 3 | +# All Rights Reserved. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 6 | +# not use this file except in compliance with the License. You may obtain |
| 7 | +# a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 13 | +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 14 | +# License for the specific language governing permissions and limitations |
| 15 | +# under the License. |
| 16 | + |
| 17 | +- name: Deploy OpenStack Lightspeed operator |
| 18 | + hosts: "{{ cifmw_target_hook_host | default('localhost') }}" |
| 19 | + connection: local |
| 20 | + vars: |
| 21 | + # OpenStack Lightspeed configuration |
| 22 | + # Note: Installing in openshift-lightspeed namespace to ensure compatibility |
| 23 | + openstack_lightspeed_namespace: "{{ cifmw_openstack_lightspeed_namespace | default('openshift-lightspeed') }}" |
| 24 | + openstack_lightspeed_operator_group: "{{ cifmw_openstack_lightspeed_operator_group | default('openstack-lightspeed-operator-group') }}" |
| 25 | + openstack_lightspeed_catalog_image: "{{ cifmw_openstack_lightspeed_catalog_image | default('quay.io/openstack-lightspeed/operator-catalog:latest') }}" |
| 26 | + openstack_lightspeed_catalog_name: "{{ cifmw_openstack_lightspeed_catalog_name | default('openstack-lightspeed-catalog') }}" |
| 27 | + |
| 28 | + # Kubeconfig path - use user-provided or default to CRC location |
| 29 | + cifmw_openshift_kubeconfig: "{{ cifmw_openshift_kubeconfig | default(ansible_env.HOME ~ '/.crc/machines/crc/kubeconfig') }}" |
| 30 | + environment: |
| 31 | + KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" |
| 32 | + |
| 33 | + tasks: |
| 34 | + # STEP 1: Deploy OpenStack Lightspeed catalog |
| 35 | + |
| 36 | + - name: Create CatalogSource for OpenStack Lightspeed |
| 37 | + kubernetes.core.k8s: |
| 38 | + state: present |
| 39 | + definition: |
| 40 | + apiVersion: operators.coreos.com/v1alpha1 |
| 41 | + kind: CatalogSource |
| 42 | + metadata: |
| 43 | + name: "{{ openstack_lightspeed_catalog_name }}" |
| 44 | + namespace: "openshift-marketplace" |
| 45 | + spec: |
| 46 | + sourceType: grpc |
| 47 | + image: "{{ openstack_lightspeed_catalog_image }}" |
| 48 | + displayName: "OpenStack Lightspeed Operator" |
| 49 | + publisher: "Red Hat" |
| 50 | + |
| 51 | + - name: Wait for CatalogSource to be ready |
| 52 | + kubernetes.core.k8s_info: |
| 53 | + api_version: operators.coreos.com/v1alpha1 |
| 54 | + kind: CatalogSource |
| 55 | + name: "{{ openstack_lightspeed_catalog_name }}" |
| 56 | + namespace: "openshift-marketplace" |
| 57 | + register: catalog_source |
| 58 | + until: |
| 59 | + - catalog_source.resources is defined |
| 60 | + - catalog_source.resources | length > 0 |
| 61 | + - catalog_source.resources[0].status.connectionState.lastObservedState is defined |
| 62 | + - catalog_source.resources[0].status.connectionState.lastObservedState == "READY" |
| 63 | + retries: 30 |
| 64 | + delay: 10 |
| 65 | + |
| 66 | + # STEP 2: Deploy OpenStack Lightspeed operator |
| 67 | + # Note: OpenStack Lightspeed operator will automatically install |
| 68 | + # and manage the OpenShift Lightspeed operator as a dependency |
| 69 | + |
| 70 | + - name: Create namespace for OpenStack Lightspeed |
| 71 | + kubernetes.core.k8s: |
| 72 | + state: present |
| 73 | + definition: |
| 74 | + apiVersion: v1 |
| 75 | + kind: Namespace |
| 76 | + metadata: |
| 77 | + name: "{{ openstack_lightspeed_namespace }}" |
| 78 | + |
| 79 | + - name: Create OperatorGroup for OpenStack Lightspeed |
| 80 | + kubernetes.core.k8s: |
| 81 | + state: present |
| 82 | + definition: |
| 83 | + apiVersion: operators.coreos.com/v1 |
| 84 | + kind: OperatorGroup |
| 85 | + metadata: |
| 86 | + name: "{{ openstack_lightspeed_operator_group }}" |
| 87 | + namespace: "{{ openstack_lightspeed_namespace }}" |
| 88 | + spec: |
| 89 | + targetNamespaces: |
| 90 | + - "{{ openstack_lightspeed_namespace }}" |
| 91 | + |
| 92 | + - name: Subscribe to OpenStack Lightspeed operator |
| 93 | + kubernetes.core.k8s: |
| 94 | + state: present |
| 95 | + definition: |
| 96 | + apiVersion: operators.coreos.com/v1alpha1 |
| 97 | + kind: Subscription |
| 98 | + metadata: |
| 99 | + name: "openstack-lightspeed-operator" |
| 100 | + namespace: "{{ openstack_lightspeed_namespace }}" |
| 101 | + spec: |
| 102 | + channel: "alpha" |
| 103 | + name: "openstack-lightspeed-operator" |
| 104 | + source: "{{ openstack_lightspeed_catalog_name }}" |
| 105 | + sourceNamespace: "openshift-marketplace" |
| 106 | + installPlanApproval: "Automatic" |
| 107 | + |
| 108 | + - name: Wait for OpenStack Lightspeed CSV to be ready |
| 109 | + kubernetes.core.k8s_info: |
| 110 | + api_version: operators.coreos.com/v1alpha1 |
| 111 | + kind: ClusterServiceVersion |
| 112 | + namespace: "{{ openstack_lightspeed_namespace }}" |
| 113 | + label_selectors: |
| 114 | + - "operators.coreos.com/openstack-lightspeed-operator.{{ openstack_lightspeed_namespace }}" |
| 115 | + register: osls_csv |
| 116 | + until: |
| 117 | + - osls_csv.resources is defined |
| 118 | + - osls_csv.resources | length > 0 |
| 119 | + - osls_csv.resources[0].status.phase is defined |
| 120 | + - osls_csv.resources[0].status.phase == "Succeeded" |
| 121 | + retries: 30 |
| 122 | + delay: 10 |
| 123 | + |
| 124 | + - name: Display deployment summary |
| 125 | + ansible.builtin.debug: |
| 126 | + msg: |
| 127 | + - "✓ OpenStack Lightspeed operator deployed in namespace: {{ openstack_lightspeed_namespace }}" |
| 128 | + - "✓ OpenShift Lightspeed operator will be automatically managed by OpenStack Lightspeed" |
0 commit comments