Skip to content

Commit d97fb73

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 <[email protected]>
1 parent b6f5327 commit d97fb73

File tree

2 files changed

+145
-0
lines changed

2 files changed

+145
-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: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
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+
failed_when: false
59+
until:
60+
- catalog_source.resources is defined
61+
- catalog_source.resources | length > 0
62+
- catalog_source.resources[0].status.connectionState.lastObservedState is defined
63+
- catalog_source.resources[0].status.connectionState.lastObservedState == "READY"
64+
retries: 30
65+
delay: 10
66+
67+
# STEP 2: Deploy OpenStack Lightspeed operator
68+
# Note: OpenStack Lightspeed operator will automatically install
69+
# and manage the OpenShift Lightspeed operator as a dependency
70+
71+
- name: Create namespace for OpenStack Lightspeed
72+
kubernetes.core.k8s:
73+
state: present
74+
definition:
75+
apiVersion: v1
76+
kind: Namespace
77+
metadata:
78+
name: "{{ openstack_lightspeed_namespace }}"
79+
80+
- name: Create OperatorGroup for OpenStack Lightspeed
81+
kubernetes.core.k8s:
82+
state: present
83+
definition:
84+
apiVersion: operators.coreos.com/v1
85+
kind: OperatorGroup
86+
metadata:
87+
name: "{{ openstack_lightspeed_operator_group }}"
88+
namespace: "{{ openstack_lightspeed_namespace }}"
89+
spec:
90+
targetNamespaces:
91+
- "{{ openstack_lightspeed_namespace }}"
92+
93+
- name: Subscribe to OpenStack Lightspeed operator
94+
kubernetes.core.k8s:
95+
state: present
96+
definition:
97+
apiVersion: operators.coreos.com/v1alpha1
98+
kind: Subscription
99+
metadata:
100+
name: "openstack-lightspeed-operator"
101+
namespace: "{{ openstack_lightspeed_namespace }}"
102+
spec:
103+
channel: "alpha"
104+
name: "openstack-lightspeed-operator"
105+
source: "{{ openstack_lightspeed_catalog_name }}"
106+
sourceNamespace: "openshift-marketplace"
107+
installPlanApproval: "Automatic"
108+
109+
- name: Wait for OpenStack Lightspeed CSV to be ready
110+
kubernetes.core.k8s_info:
111+
api_version: operators.coreos.com/v1alpha1
112+
kind: ClusterServiceVersion
113+
namespace: "{{ openstack_lightspeed_namespace }}"
114+
label_selectors:
115+
- "operators.coreos.com/openstack-lightspeed-operator.{{ openstack_lightspeed_namespace }}"
116+
register: osls_csv
117+
failed_when: false
118+
until:
119+
- osls_csv.resources is defined
120+
- osls_csv.resources | length > 0
121+
- osls_csv.resources[0].status.phase is defined
122+
- osls_csv.resources[0].status.phase == "Succeeded"
123+
retries: 30
124+
delay: 10
125+
126+
- name: Display deployment summary
127+
ansible.builtin.debug:
128+
msg:
129+
- "✓ OpenStack Lightspeed operator deployed in namespace: {{ openstack_lightspeed_namespace }}"
130+
- "✓ OpenShift Lightspeed operator will be automatically managed by OpenStack Lightspeed"

0 commit comments

Comments
 (0)