# Copyright 2022 Dell Inc. or its subsidiaries. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. --- - name: Start omnia services on reboot hosts: localhost connection: local vars: wait_time_minutes: 3 os_supported_leap: "leap" src_resolv_conf: /tmp/resolv.conf dest_resolv_conf: /etc/resolv.conf max_retries: 20 cobbler_namespace: cobbler cobbler_pod: cobbler cobbler_kickstart_file: rocky8.ks management_network_namespace: network-config management_network_pod: mngmnt-network-container infiniband_pod: infiniband-container file_perm: '0775' mount_dir: /mnt/temp/ tasks: - name: Wait for 3 minutes pause: minutes: "{{ wait_time_minutes }}" - name: Include base_vars.yml include_vars: ../../../input_params/base_vars.yml - name: Check resolv.conf file is present stat: path: "{{ src_resolv_conf }}" register: resolv_conf_check - name: Copy resolv.conf file copy: src: "{{ src_resolv_conf }}" dest: "{{ dest_resolv_conf }}" mode: preserve when: resolv_conf_check.stat.exists - name: Check if mount iso file exists stat: path: "/mnt/{{ provision_os }}/EFI/BOOT/grub.cfg" register: mount_iso_check - name: Create tmp directory file: path: "{{ mount_dir }}" state: directory mode: "{{ file_perm }}" when: not mount_iso_check.stat.exists - name: Mount the iso file command: mount -o loop {{ iso_file_path }} {{ mount_dir }} changed_when: false failed_when: false args: warn: false when: not mount_iso_check.stat.exists - name: Copy files to mnt folder command: "rsync -AHPSXav {{ mount_dir }} /mnt/{{ provision_os }}" changed_when: true args: warn: false when: not mount_iso_check.stat.exists - name: Unmount tmp directory command: "umount {{ mount_dir }}" changed_when: true failed_when: false - name: Delete tmp directory file: path: "{{ mount_dir }}" state: absent - block: - name: Fetch SElinux mode command: /usr/sbin/sestatus register: sestatus_current changed_when: false - name: Set SElinux to permissive mode command: /usr/sbin/setenforce 0 changed_when: true when: '"SELinux status: enabled" in sestatus_current.stdout_lines' when: os_supported_leap not in ansible_distribution | lower - name: Disable SWAP command: /usr/sbin/swapoff -a changed_when: true - name: Start and enable kubernetes - kubelet service: name: kubelet state: restarted enabled: yes - name: Wait for 3 minutes pause: minutes: "{{ wait_time_minutes }}" - name: Get K8s nodes status command: kubectl get nodes changed_when: false register: k8s_nodes retries: "{{ max_retries }}" until: "'master' in k8s_nodes.stdout" - name: Restart coredns pod command: kubectl rollout restart deployment.apps/coredns -n kube-system changed_when: true - block: - name: Check mngmnt_network pod status command: kubectl get pods -n {{ management_network_namespace }} changed_when: false register: mngmnt_network_pod_status failed_when: false - name: Wait for mngmnt_network pod to come to ready state command: kubectl wait --for=condition=ready -n {{ management_network_namespace }} pod -l app=mngmnt-network changed_when: false when: management_network_pod in mngmnt_network_pod_status.stdout - name: Get mngmnt_network pod name command: 'kubectl get pod -n {{ management_network_namespace }} -l app=mngmnt-network -o jsonpath="{.items[0].metadata.name}"' changed_when: false register: mngmnt_network_pod_name when: management_network_pod in mngmnt_network_pod_status.stdout - name: Configuring mngmnt_network container command: 'kubectl exec --stdin --tty -n {{ management_network_namespace }} {{ mngmnt_network_pod_name.stdout }} \ -- ansible-playbook /root/mngmnt_container_configure.yml -e mngmnt_nic="{{ mngmnt_network_nic }}"' changed_when: false failed_when: false when: management_network_pod in mngmnt_network_pod_status.stdout when: device_config_support - block: - name: Check mngmnt_network pod status command: kubectl get pods -n {{ management_network_namespace }} changed_when: false register: mngmnt_network_pod_status failed_when: false - name: Wait for infiniband pod to come to ready state command: kubectl wait --for=condition=ready -n {{ management_network_namespace }} pod -l app=infiniband changed_when: false when: infiniband_pod in mngmnt_network_pod_status.stdout - name: Get infiniband pod name command: 'kubectl get pod -n {{ management_network_namespace }} -l app=infiniband -o jsonpath="{.items[0].metadata.name}"' changed_when: false register: infiniband_pod_name when: infiniband_pod in mngmnt_network_pod_status.stdout - name: Configuring infiniband container command: 'kubectl exec --stdin --tty -n {{ management_network_namespace }} {{ infiniband_pod_name.stdout }} \ -- ansible-playbook /root/omnia/control_plane/roles/control_plane_ib/files/infiniband_container_configure.yml' changed_when: false when: infiniband_pod in mngmnt_network_pod_status.stdout when: ib_switch_support - name: Check cobbler pod status command: kubectl get pods -n {{ cobbler_namespace }} changed_when: false register: cobbler_pod_status failed_when: false - name: Wait for cobbler pod to come to ready state command: kubectl wait --for=condition=ready -n {{ cobbler_namespace }} pod -l app=cobbler changed_when: false when: cobbler_pod in cobbler_pod_status.stdout - name: Get cobbler pod name command: 'kubectl get pod -n {{ cobbler_namespace }} -l app=cobbler -o jsonpath="{.items[0].metadata.name}"' changed_when: false register: cobbler_pod_name when: cobbler_pod in cobbler_pod_status.stdout - name: Configuring cobbler inside container (It may take 5-10 mins) command: "kubectl exec --stdin --tty -n {{ cobbler_namespace }} {{ cobbler_pod_name.stdout }} -- ansible-playbook /root/cobbler_configurations_rocky.yml -e provision_os={{ provision_os }} -e file_perm={{ file_perm }}" changed_when: true when: cobbler_pod in cobbler_pod_status.stdout