startup_omnia.yml 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. # Copyright 2022 Dell Inc. or its subsidiaries. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. ---
  15. - name: Start omnia services on reboot
  16. hosts: localhost
  17. connection: local
  18. vars:
  19. wait_time_minutes: 3
  20. os_supported_leap: "leap"
  21. src_resolv_conf: /tmp/resolv.conf
  22. dest_resolv_conf: /etc/resolv.conf
  23. max_retries: 20
  24. cobbler_namespace: cobbler
  25. cobbler_pod: cobbler
  26. cobbler_kickstart_file: rocky8.ks
  27. management_network_namespace: network-config
  28. management_network_pod: mngmnt-network-container
  29. infiniband_pod: infiniband-container
  30. file_perm: '0775'
  31. mount_dir: /mnt/temp/
  32. tasks:
  33. - name: Wait for 3 minutes
  34. pause:
  35. minutes: "{{ wait_time_minutes }}"
  36. - name: Include base_vars.yml
  37. include_vars: ../../../input_params/base_vars.yml
  38. - name: Check resolv.conf file is present
  39. stat:
  40. path: "{{ src_resolv_conf }}"
  41. register: resolv_conf_check
  42. - name: Copy resolv.conf file
  43. copy:
  44. src: "{{ src_resolv_conf }}"
  45. dest: "{{ dest_resolv_conf }}"
  46. mode: preserve
  47. when: resolv_conf_check.stat.exists
  48. - name: Check if mount iso file exists
  49. stat:
  50. path: "/mnt/{{ provision_os }}/EFI/BOOT/grub.cfg"
  51. register: mount_iso_check
  52. - name: Create tmp directory
  53. file:
  54. path: "{{ mount_dir }}"
  55. state: directory
  56. mode: "{{ file_perm }}"
  57. when: not mount_iso_check.stat.exists
  58. - name: Mount the iso file
  59. command: mount -o loop {{ iso_file_path }} {{ mount_dir }}
  60. changed_when: false
  61. failed_when: false
  62. args:
  63. warn: false
  64. when: not mount_iso_check.stat.exists
  65. - name: Copy files to mnt folder
  66. command: "rsync -AHPSXav {{ mount_dir }} /mnt/{{ provision_os }}"
  67. changed_when: true
  68. args:
  69. warn: false
  70. when: not mount_iso_check.stat.exists
  71. - name: Unmount tmp directory
  72. command: "umount {{ mount_dir }}"
  73. changed_when: true
  74. failed_when: false
  75. - name: Delete tmp directory
  76. file:
  77. path: "{{ mount_dir }}"
  78. state: absent
  79. - block:
  80. - name: Fetch SElinux mode
  81. command: /usr/sbin/sestatus
  82. register: sestatus_current
  83. changed_when: false
  84. - name: Set SElinux to permissive mode
  85. command: /usr/sbin/setenforce 0
  86. changed_when: true
  87. when: '"SELinux status: enabled" in sestatus_current.stdout_lines'
  88. when: os_supported_leap not in ansible_distribution | lower
  89. - name: Disable SWAP
  90. command: /usr/sbin/swapoff -a
  91. changed_when: true
  92. - name: Start and enable kubernetes - kubelet
  93. service:
  94. name: kubelet
  95. state: restarted
  96. enabled: yes
  97. - name: Wait for 3 minutes
  98. pause:
  99. minutes: "{{ wait_time_minutes }}"
  100. - name: Get K8s nodes status
  101. command: kubectl get nodes
  102. changed_when: false
  103. register: k8s_nodes
  104. retries: "{{ max_retries }}"
  105. until: "'master' in k8s_nodes.stdout"
  106. - name: Restart coredns pod
  107. command: kubectl rollout restart deployment.apps/coredns -n kube-system
  108. changed_when: true
  109. - block:
  110. - name: Check mngmnt_network pod status
  111. command: kubectl get pods -n {{ management_network_namespace }}
  112. changed_when: false
  113. register: mngmnt_network_pod_status
  114. failed_when: false
  115. - name: Wait for mngmnt_network pod to come to ready state
  116. command: kubectl wait --for=condition=ready -n {{ management_network_namespace }} pod -l app=mngmnt-network
  117. changed_when: false
  118. when: management_network_pod in mngmnt_network_pod_status.stdout
  119. - name: Get mngmnt_network pod name
  120. command: 'kubectl get pod -n {{ management_network_namespace }} -l app=mngmnt-network -o jsonpath="{.items[0].metadata.name}"'
  121. changed_when: false
  122. register: mngmnt_network_pod_name
  123. when: management_network_pod in mngmnt_network_pod_status.stdout
  124. - name: Configuring mngmnt_network container
  125. command: 'kubectl exec --stdin --tty -n {{ management_network_namespace }} {{ mngmnt_network_pod_name.stdout }} \
  126. -- ansible-playbook /root/mngmnt_container_configure.yml -e mngmnt_nic="{{ mngmnt_network_nic }}"'
  127. changed_when: false
  128. failed_when: false
  129. when: management_network_pod in mngmnt_network_pod_status.stdout
  130. when: device_config_support
  131. - block:
  132. - name: Check mngmnt_network pod status
  133. command: kubectl get pods -n {{ management_network_namespace }}
  134. changed_when: false
  135. register: mngmnt_network_pod_status
  136. failed_when: false
  137. - name: Wait for infiniband pod to come to ready state
  138. command: kubectl wait --for=condition=ready -n {{ management_network_namespace }} pod -l app=infiniband
  139. changed_when: false
  140. when: infiniband_pod in mngmnt_network_pod_status.stdout
  141. - name: Get infiniband pod name
  142. command: 'kubectl get pod -n {{ management_network_namespace }} -l app=infiniband -o jsonpath="{.items[0].metadata.name}"'
  143. changed_when: false
  144. register: infiniband_pod_name
  145. when: infiniband_pod in mngmnt_network_pod_status.stdout
  146. - name: Configuring infiniband container
  147. command: 'kubectl exec --stdin --tty -n {{ management_network_namespace }} {{ infiniband_pod_name.stdout }} \
  148. -- ansible-playbook /root/omnia/control_plane/roles/control_plane_ib/files/infiniband_container_configure.yml'
  149. changed_when: false
  150. when: infiniband_pod in mngmnt_network_pod_status.stdout
  151. when: ib_switch_support
  152. - name: Check cobbler pod status
  153. command: kubectl get pods -n {{ cobbler_namespace }}
  154. changed_when: false
  155. register: cobbler_pod_status
  156. failed_when: false
  157. - name: Wait for cobbler pod to come to ready state
  158. command: kubectl wait --for=condition=ready -n {{ cobbler_namespace }} pod -l app=cobbler
  159. changed_when: false
  160. when: cobbler_pod in cobbler_pod_status.stdout
  161. - name: Get cobbler pod name
  162. command: 'kubectl get pod -n {{ cobbler_namespace }} -l app=cobbler -o jsonpath="{.items[0].metadata.name}"'
  163. changed_when: false
  164. register: cobbler_pod_name
  165. when: cobbler_pod in cobbler_pod_status.stdout
  166. - name: Configuring cobbler inside container (It may take 5-10 mins)
  167. 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 }}"
  168. changed_when: true
  169. when: cobbler_pod in cobbler_pod_status.stdout