|
| 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