Skip to content

Commit cd21041

Browse files
jpattararootveera-damisetti
authored
feat: Updated hcp.yaml with CatalogSource image parameter for MCE installation (#421)
Updated hcp.yaml with catalogsource image parameter for MCE installation. So the automation can take care of MCE installations other than the stable versions also by applying the the catalogsource image ID in hcp.yaml. --------- Signed-off-by: root <[email protected]> Co-authored-by: root <[email protected]> Co-authored-by: Veerabhadrarao Damisetti <[email protected]>
1 parent 9c9eec0 commit cd21041

File tree

5 files changed

+61
-27
lines changed

5 files changed

+61
-27
lines changed

docs/set-variables-group-vars.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@
290290
**hcp.pkgs** | list of packages for different hosts |
291291
**hcp.mce.version** | version for multicluster-engine Operator | 2.4
292292
**hcp.mce.instance_name** | name of the MultiClusterEngine instance | engine
293-
**hcp.mce.catalogsource_name** | Name of the catalogsource for operatorhub | redhat-operators
293+
**hcp.mce.catalogsource_image** | Image ID for installing MCE | 970287
294294
**hcp.mce.delete** | true or false - deletes mce and related resources while running deletion playbook | true
295295
**hcp.asc.url_for_ocp_release_file** | Add URL for OCP release.txt File | https://... ..../release.txt
296296
**hcp.asc.db_volume_size** | DatabaseStorage Volume Size | 10Gi

inventories/default/group_vars/hcp.yaml.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ hcp:
1717
version:
1818
instance_name: engine
1919
delete: false
20-
catalogsource_name: redhat-operators
20+
catalogsource_image: # Required only if we need to create the Catalogsource for installing MCE
2121

2222
# AgentServiceConfig Parameters
2323

Lines changed: 48 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,104 @@
11
---
2-
- name: Check if multicluster-engine Namespace exists
3-
k8s_info:
2+
- name: Create CatalogSource.yaml from template
3+
ansible.builtin.template:
4+
src: CatalogSource.yaml.j2
5+
dest: /root/ansible_workdir/CatalogSource.yaml
6+
mode: '0644'
7+
when: hcp.mce.catalogsource_image is defined and hcp.mce.catalogsource_image | length > 0
8+
9+
- name: Deploy CatalogSource
10+
ansible.builtin.command: oc apply -f /root/ansible_workdir/CatalogSource.yaml
11+
when: hcp.mce.catalogsource_image is defined and hcp.mce.catalogsource_image | length > 0
12+
13+
- name: Check if multicluster-engine Namespace exists
14+
kubernetes.core.k8s:
415
api_version: v1
516
kind: Namespace
617
name: "{{ hcp.asc.mce_namespace }}"
718
register: namespace_check
8-
ignore_errors: yes
19+
ignore_errors: true
920

10-
- name: Create multicluster-engine Namespace
11-
k8s:
21+
- name: Create multicluster-engine Namespace
22+
kubernetes.core.k8s:
1223
api_version: v1
1324
kind: Namespace
1425
name: "{{ hcp.asc.mce_namespace }}"
1526
state: present
16-
when: namespace_check.resources | length == 0
27+
when: namespace_check.resources | length == 0
1728

1829
- name: Create OperatorGroup.yaml
19-
template:
30+
ansible.builtin.template:
2031
src: OperatorGroup.yaml.j2
2132
dest: /root/ansible_workdir/OperatorGroup.yaml
33+
mode: '0644'
2234

2335
- name: Deploy OperatorGroup
24-
command: oc apply -f /root/ansible_workdir/OperatorGroup.yaml
36+
ansible.builtin.command: oc apply -f /root/ansible_workdir/OperatorGroup.yaml
2537

2638
- name: Create Subscription.yaml
27-
template:
39+
ansible.builtin.template:
2840
src: Subscription.yaml.j2
2941
dest: /root/ansible_workdir/Subscription.yaml
42+
mode: '0644'
3043

3144
- name: Deploy Subscription for MCE
32-
command: oc apply -f /root/ansible_workdir/Subscription.yaml
45+
ansible.builtin.command: oc apply -f /root/ansible_workdir/Subscription.yaml
3346

3447
- name: Wait for MCE deployment to be created
35-
shell: oc get all -n {{ hcp.asc.mce_namespace }} | grep -i deployment | grep -i multicluster-engine | wc -l
36-
register: mce_deploy
48+
ansible.builtin.shell: |
49+
set -o pipefail
50+
oc get all -n {{ hcp.asc.mce_namespace }} | grep -i deployment | grep -i multicluster-engine | wc -l
3751
until: mce_deploy.stdout == '1'
3852
retries: 20
3953
delay: 5
4054

4155
- name: Wait for MCE deployment to be available
42-
shell: oc get deployment multicluster-engine-operator -n {{ hcp.asc.mce_namespace }} -o=jsonpath='{.status.replicas}{" "}{.status.availableReplicas}'
56+
ansible.builtin.shell: >
57+
oc get deployment multicluster-engine-operator -n {{ hcp.asc.mce_namespace }}
58+
-o=jsonpath='{.status.replicas}{" "}{.status.availableReplicas}'
4359
register: mce_pod_status
4460
until: mce_pod_status.stdout.split(' ')[0] == mce_pod_status.stdout.split(' ')[1]
4561
retries: 20
4662
delay: 5
4763

4864
- name: Create MultiClusterEngine.yaml
49-
template:
65+
ansible.builtin.template:
5066
src: MultiClusterEngine.yaml.j2
5167
dest: /root/ansible_workdir/MultiClusterEngine.yaml
68+
mode: '0644'
5269

5370
- name: Deploy MCE Instance
54-
command: oc apply -f /root/ansible_workdir/MultiClusterEngine.yaml
71+
ansible.builtin.command: oc apply -f /root/ansible_workdir/MultiClusterEngine.yaml
5572

5673
- name: Wait for MCE to be Available
57-
shell: oc get mce --no-headers | awk '{print $2}'
74+
ansible.builtin.shell: |
75+
set -o pipefail
76+
oc get mce --no-headers | awk '{print $2}'
5877
register: mce_status
5978
until: mce_status.stdout == "Available"
6079
retries: 40
61-
delay: 10
80+
delay: 10
6281

6382
- name: Enable hypershift-preview component in MCE
64-
command: oc patch mce {{ hcp.mce.instance_name }} -p '{"spec":{"overrides":{"components":[{"name":"hypershift-preview","enabled":true}]}}}' --type merge
83+
ansible.builtin.command: >
84+
oc patch mce {{ hcp.mce.instance_name }}
85+
-p '{"spec":{"overrides":{"components":[{"name":"hypershift-preview","enabled":true}]}}}'
86+
--type merge
6587
6688
- name: Create ClusterImageSet.yaml
67-
template:
89+
ansible.builtin.template:
6890
src: ClusterImageSet.yaml.j2
6991
dest: /root/ansible_workdir/ClusterImageSet.yaml
92+
mode: '0644'
7093

71-
- name: Deploy ClusterImageSet
72-
command: oc apply -f /root/ansible_workdir/ClusterImageSet.yaml
94+
- name: Deploy ClusterImageSet
95+
ansible.builtin.command: oc apply -f /root/ansible_workdir/ClusterImageSet.yaml
7396

7497
- name: Create Provisioning.yaml
75-
template:
98+
ansible.builtin.template:
7699
src: Provisioning.yaml.j2
77100
dest: /root/ansible_workdir/Provisioning.yaml
101+
mode: '0644'
78102

79-
- name: Deploy Provisioning
80-
command: oc apply -f /root/ansible_workdir/Provisioning.yaml
103+
- name: Deploy Provisioning
104+
ansible.builtin.command: oc apply -f /root/ansible_workdir/Provisioning.yaml
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: operators.coreos.com/v1alpha1
2+
kind: CatalogSource
3+
metadata:
4+
name: redhat-operators
5+
namespace: openshift-marketplace
6+
spec:
7+
sourceType: grpc
8+
publisher: redhat
9+
displayName: Red Hat Operators v4.18 Stage
10+
image: {{ hcp.mce.catalogsource_image }}

roles/install_mce_operator/templates/Subscription.yaml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
namespace: "{{ hcp.asc.mce_namespace }}"
66
spec:
77
sourceNamespace: openshift-marketplace
8-
source: {{ hcp.mce.catalogsource_name }}
8+
source: redhat-operators
99
channel: stable-{{ hcp.mce.version }}
1010
installPlanApproval: Automatic
1111
name: multicluster-engine

0 commit comments

Comments
 (0)