Skip to content

Commit 37db4a4

Browse files
committed
[hooks] Add install-openstack-lightspeed hook
This hook deploys the openstack lightspeed operator for OpenShift clusters. The openstack lightspeed operator automatically manages the OpenShift lightspeed operator as a dependency. Signed-off-by: Malinga Tembo <mtembo@redhat.com>
1 parent 14b37c7 commit 37db4a4

File tree

2 files changed

+143
-0
lines changed

2 files changed

+143
-0
lines changed

hooks/playbooks/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,21 @@ on removing "import_playbook" usage in ci-framework project.
2424
### Output
2525
None
2626

27+
## install-openstack-lightspeed.yml
28+
Installs OpenShift Lightspeed and OpenStack Lightspeed operators on CRC cluster.
29+
This hook deploys both operators sequentially, setting up required namespaces,
30+
operator groups, catalog sources, and subscriptions.
31+
32+
### Input
33+
* `cifmw_openstack_lightspeed_namespace`: (String) Namespace for OpenStack Lightspeed operator. Defaults to `openshift-lightspeed`.
34+
* `cifmw_openstack_lightspeed_operator_group`: (String) OperatorGroup name for OpenStack Lightspeed. Defaults to `openstack-lightspeed-operator-group`.
35+
* `cifmw_openstack_lightspeed_catalog_image`: (String) Container image for OpenStack Lightspeed catalog source. Defaults to `quay.io/openstack-lightspeed/operator-catalog:latest`.
36+
* `cifmw_openstack_lightspeed_catalog_name`: (String) Name for OpenStack Lightspeed CatalogSource resource. Defaults to `openstack-lightspeed-catalog`.
37+
* `cifmw_openshift_kubeconfig`: (String) Path to kubeconfig file for OpenShift cluster. Defaults to `{{ ansible_env.HOME }}/.crc/machines/crc/kubeconfig`.
38+
39+
### Output
40+
None
41+
2742
## kustomize_cr.yml
2843
This hook enables customization of CR files, using oc kustomize.
2944
### Input
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
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

Comments
 (0)