Skip to content

Commit 27c0549

Browse files
Merge pull request #116 from swapnil-bobade27/ipi-day-2-operation
Role for IPI day2 operations
2 parents 571bb2c + 803cf46 commit 27c0549

File tree

8 files changed

+245
-1
lines changed

8 files changed

+245
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ This repository consists of additional ansible playbooks for the following:
5050
1. Validate CPU manager feature and run e2e.
5151
1. Enable DISA-STIG profiles for CO on P and remediate various rules.
5252
1. Run Openshift-tests-private testcases.
53+
1. Verify IPI day2 operations
5354

5455
## Assumptions:
5556

examples/all.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,4 +535,12 @@ openshift_test_private_e2e_repo: "https://github.com/openshift/openshift-tests-p
535535
openshift_test_private_git_branch: "master"
536536
openshift_test_private_directory: "/tmp/openshift_test_private_e2e"
537537
openshift_test_private_golang_tarball: "https://go.dev/dl/go1.24.1.linux-ppc64le.tar.gz"
538-
testcase_filters : 'Image_Registry\\|API_Server'
538+
testcase_filters : 'Image_Registry\\|API_Server'
539+
540+
#ipi-day2-operation vars
541+
enable_ipi_day2_operation: false
542+
rsct_operator_repo: "https://github.com/ocp-power-automation/rsct-operator.git"
543+
rsct_dir: "{{ lookup('env', 'PWD') }}/rsct"
544+
rsct_namespace: rsct-operator-system
545+
lso_index: "" # provide LSO index image
546+
cluster_upi: false #set to true if using UPI cluster
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# ipi-day2-operation vars
2+
enable_ipi_day2_operation: true
3+
rsct_git_repo: "https://github.com/ocp-power-automation/rsct-operator.git"
4+
rsct_dir: "{{ lookup('env', 'PWD') }}/rsct"
5+
rsct_namespace: rsct-operator-system
6+
lso_index: "" # provide LSO index image
7+
cluster_upi: false #set to true if using UPI cluster

playbooks/ipi-day2-operation.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
- name: Run ipi day2 operation
3+
hosts: all
4+
tasks:
5+
- name: Fail incase 'KUBECONFIG' environment variable is an empty string
6+
fail:
7+
msg: KUBECONFIG environment variable must be a non-empty string
8+
when: (lookup('env', 'KUBECONFIG') == "")
9+
10+
- name: Check golang version
11+
shell: go version | awk '{ print substr ($3,3) }'
12+
register: golang_version
13+
14+
- fail:
15+
msg: golang is not installed or version < 1.22
16+
when: golang_version.rc !=0 or golang_version.stdout < "1.22"
17+
- debug:
18+
msg: "{{ golang_version }}"
19+
20+
- include_role:
21+
name: ipi-day2-operation
22+
vars:
23+
KUBECONFIG: "{{ lookup('env', 'KUBECONFIG') }}"
24+

playbooks/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,6 @@
152152

153153
- import_playbook: openshift-test-private-e2e.yml
154154
when: openshift_test_private_validation is defined and openshift_test_private_validation
155+
156+
- import_playbook: ipi-day2-operation.yml
157+
when: enable_ipi_day2_operation is defined and enable_ipi_day2_operation
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
IPI-day2-operations
2+
=========
3+
4+
This play will perform the day2 operation on IPI cluster
5+
6+
This playbook will:
7+
- Install RSCT operator
8+
- Install LSO operator
9+
- Install ODF operator
10+
11+
Requirements
12+
------------
13+
14+
- Access to the cluster as a user with the cluster-admin role
15+
- The cluster is in a known good state, without any errors
16+
- OCP secret with name ***podman-secret*** in the default namespace which is used for global secret update and has following keys:
17+
***username***, ***password*** and ***registry***
18+
19+
20+
Role Variables
21+
--------------
22+
| Variable | Required | Default | Comments |
23+
|--------------------------------|----------|-------------|------------------------------------------------|
24+
| enable_ipi_day2_operation | no | false | Set it to true to run this playbook |
25+
| rsct_git_repo | yes | https://github.com/ocp-power-automation/rsct-operator.git | RSCT git repo |
26+
| rsct_dir | no | "{{ lookup('env', 'PWD') }}/rsct" | directory for RSCT |
27+
| rsct_namespace | no | rsct-operator-system | RSCT namespace |
28+
| lso_index | no | " " | Index image for LSO operator |
29+
| cluster_upi | no | false | #set to true if using UPI cluster |
30+
31+
32+
Dependencies
33+
------------
34+
35+
- Export KUBECONFIG
36+
- Install go with version 1.22 and above
37+
- Import LSO role
38+
- Import ODF role
39+
40+
Example Playbook
41+
----------------
42+
43+
```
44+
- name: Run ipi day2 operation
45+
hosts: all
46+
tasks:
47+
- name: Fail incase 'KUBECONFIG' environment variable is an empty string
48+
fail:
49+
msg: KUBECONFIG environment variable must be a non-empty string
50+
when: (lookup('env', 'KUBECONFIG') == "")
51+
52+
- include_role:
53+
name: ipi-day2-operation
54+
vars:
55+
KUBECONFIG: "{{ lookup('env', 'KUBECONFIG') }}"
56+
```
57+
58+
License
59+
-------
60+
61+
See LICENCE.txt
62+
63+
Author Information
64+
------------------
65+
66+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# ipi-day2-operation vars
2+
enable_ipi_day2_operation: true
3+
rsct_git_repo: https://github.com/ocp-power-automation/rsct-operator.git
4+
rsct_dir: "{{ lookup('env', 'PWD') }}/rsct"
5+
rsct_namespace: rsct-operator-system
6+
lso_index: "" # provide LSO index image
7+
cluster_upi: false #set to true if using UPI cluster
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
---
2+
# tasks file for playbooks/roles/ipi-day2-operation
3+
4+
- name: Check if cluster operators and nodes are healthy
5+
include_role:
6+
name: check-cluster-health
7+
8+
- name: Check if secret podman-secret exist
9+
shell: oc get secret podman-secret | wc -l
10+
register: login_secret
11+
12+
- name: Fail if podman-secret does not exist in current namespace
13+
fail:
14+
msg: "Secret podman-secret does not exist in current namespace"
15+
when: login_secret.stdout|int!=2
16+
17+
# Deploy RSCT operator
18+
- name: Ensure 'rsct' directory exists
19+
ansible.builtin.file:
20+
path: "{{ rsct_dir }}"
21+
state: directory
22+
mode: '0755'
23+
24+
- name: Clone the RSCT repository from GitHub
25+
ansible.builtin.git:
26+
repo: "{{ rsct_git_repo }}"
27+
dest: "{{ rsct_dir }}"
28+
force: yes
29+
30+
# install controller-gen
31+
- name: Install controller-gen
32+
ansible.builtin.shell: |
33+
go install sigs.k8s.io/controller-tools/cmd/[email protected]
34+
35+
- name: Install kustomize
36+
ansible.builtin.shell: |
37+
go install sigs.k8s.io/kustomize/kustomize/v4@latest
38+
39+
#Set version for RSCT
40+
- name: Echo version
41+
ansible.builtin.shell: echo "VERSION is $VERSION"
42+
environment:
43+
VERSION: "0.0.1-alpha1"
44+
45+
# Run make command for RSCT
46+
- name: Deploy RSCT operator
47+
command: make deploy
48+
args:
49+
chdir: "{{ lookup('env', 'PWD') }}/rsct"
50+
51+
# Check RSCT pods
52+
- name: Check created pods
53+
shell: oc get pods -n "{{ rsct_namespace }}"
54+
register: rsct_pods
55+
56+
- debug:
57+
msg: "{{ rsct_pods.stdout_lines }}"
58+
59+
# Add test user as rsct-test
60+
- name: Add the test user as rsct-test
61+
shell: "oc adm policy add-scc-to-user -z rsct-test privileged -n {{ rsct_namespace }}"
62+
63+
# Create cluster role binding
64+
- name: Create cluster binding role
65+
shell: oc apply -f rsct_v1alpha1_rsct.yaml
66+
args:
67+
chdir: "{{ lookup('env', 'PWD') }}/rsct/config/samples/"
68+
69+
# Check pods after cluster role binding
70+
- name: Check created pods
71+
ansible.builtin.shell: |
72+
oc get pods -n "{{ rsct_namespace }}" --no-headers | grep -v "Running\|Completed" | wc -l
73+
register: rsct_pods1
74+
until: (rsct_pods1.stdout | int) == 0 and rsct_pods1.stderr == ""
75+
retries: 5
76+
delay: 30
77+
changed_when: false
78+
79+
# Check all resources from rsct-operator-system namespace
80+
- name: Check all the created resources
81+
shell: oc get all -n "{{ rsct_namespace }}"
82+
register: all_resources
83+
84+
- debug:
85+
msg: "{{ all_resources.stdout_lines }}"
86+
87+
# Install dependencies
88+
- name: Install pip
89+
become: true
90+
package:
91+
name: python3-pip
92+
state: present
93+
94+
- name: Install kubernetes Python module
95+
pip:
96+
name: kubernetes
97+
executable: pip3
98+
99+
# Install LSO
100+
- name: Install LSO - Local Storage operator
101+
include_role:
102+
name: ocp-lso
103+
vars:
104+
lso_catalogsource_image: "{{ lso_index }}"
105+
upi_cluster: "{{ cluster_upi }}"
106+
107+
# Get worker nodes to check processor/CPU
108+
- name: Get worker node names
109+
shell: oc get nodes -o custom-columns=NAME:.metadata.name --no-headers | grep worker
110+
register: worker_nodes
111+
112+
# Check available CPU's on worker nodes
113+
- name: Get CPU count for each worker node
114+
shell: >
115+
oc get node {{ item }} -o jsonpath='{.status.capacity.cpu}'
116+
loop: "{{ worker_nodes.stdout_lines }}"
117+
register: worker_cores
118+
119+
- name: Fail if any worker node has less than 16 CPUs
120+
fail:
121+
msg: "Node {{ item.item }} has only {{ item.stdout }} CPUs, which is less than minimum requirement for ODF."
122+
when: item.stdout | int < 16
123+
loop: "{{ worker_cores.results }}"
124+
125+
# ODF installation
126+
- name: Install ODF - Openshift Data Foundation
127+
include_role:
128+
name: ocp-odf-operator

0 commit comments

Comments
 (0)