check_prerequisites.yml 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. # Copyright 2021 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: Include control_plane_common vars
  16. include_vars: ../../control_plane_common/vars/main.yml
  17. run_once: true
  18. - name: Include custom_iso vars
  19. include_vars: ../../control_plane_customiso/vars/main.yml
  20. run_once: true
  21. - name: Check {{ management_station_ip_file }} file is present
  22. stat:
  23. path: "{{ role_path }}/files/{{ management_station_ip_file }}"
  24. register: ip_file_check
  25. run_once: true
  26. - name: Fetch management station ip from {{ management_station_ip_file }}
  27. command: cat {{ role_path }}/files/{{ management_station_ip_file }}
  28. changed_when: false
  29. register: fetch_ip
  30. run_once: true
  31. when: ip_file_check.stat.exists
  32. - name: Missing {{ management_station_ip_file }}
  33. fail:
  34. msg: "{{ missing_ip_file_fail_msg }}"
  35. when: not ip_file_check.stat.exists
  36. - name: Set management_station_ip
  37. set_fact:
  38. management_station_ip: "{{ fetch_ip.stdout }}"
  39. - name: Initialize variables
  40. set_fact:
  41. raid_type: false
  42. raid_controller_sensor: ""
  43. raid_enclosure_name: ""
  44. drives_id: ""
  45. enterprise_license: false
  46. datacenter_license: false
  47. provision_status: false
  48. model_status: false
  49. idrac_license_name: ""
  50. deploy_os_status: false
  51. - block:
  52. - name: Check tower_cli.cfg is encrypted
  53. command: cat "{{ playbook_dir }}/roles/webui_awx/files/{{ awx_vars_filename }}"
  54. changed_when: false
  55. register: awx_content
  56. run_once: true
  57. - name: Decrpyt tower_cli.cfg
  58. command: >-
  59. ansible-vault decrypt "{{ playbook_dir }}/roles/webui_awx/files/{{ awx_vars_filename }}"
  60. --vault-password-file "{{ playbook_dir }}/roles/webui_awx/files/{{ awx_vaultname }}"
  61. changed_when: false
  62. run_once: true
  63. when: "'$ANSIBLE_VAULT;' in awx_content.stdout"
  64. - name: Fetch awx host
  65. command: grep "host:" "{{ playbook_dir }}/roles/webui_awx/files/{{ awx_vars_filename }}"
  66. register: fetch_awx_host
  67. changed_when: false
  68. run_once: true
  69. - name: Fetch awx username
  70. command: grep "username:" "{{ playbook_dir }}/roles/webui_awx/files/{{ awx_vars_filename }}"
  71. register: fetch_awx_username
  72. changed_when: false
  73. run_once: true
  74. no_log: true
  75. - name: Fetch awx password
  76. command: grep "password:" "{{ playbook_dir }}/roles/webui_awx/files/{{ awx_vars_filename }}"
  77. register: fetch_awx_password
  78. changed_when: false
  79. run_once: true
  80. no_log: true
  81. - name: Set awx variables
  82. set_fact:
  83. awx_host: "{{ fetch_awx_host.stdout | regex_replace('host: ','') }}"
  84. awx_username: "{{ fetch_awx_username.stdout | regex_replace('username: ','') }}"
  85. awx_password: "{{ fetch_awx_password.stdout | regex_replace('password: ','') }}"
  86. no_log: true
  87. - name: Encrypt tower_cli.cfg
  88. command: >-
  89. ansible-vault encrypt "{{ playbook_dir }}/roles/webui_awx/files/{{ awx_vars_filename }}"
  90. --vault-password-file "{{ playbook_dir }}/roles/webui_awx/files/{{ awx_vaultname }}"
  91. changed_when: false
  92. run_once: true
  93. when: "'$ANSIBLE_VAULT;' in awx_content.stdout"
  94. - name: Get inventory list
  95. command: >-
  96. awx --conf.host "{{ awx_host }}" --conf.username "{{ awx_username }}" --conf.password "{{ awx_password }}"
  97. inventory list -f human --filter "name"
  98. register: inventory_list
  99. run_once: true
  100. changed_when: false
  101. no_log: true
  102. - name: Create provisioned_idrac inventory
  103. command: >-
  104. awx --conf.host {{ awx_host }} --conf.username {{ awx_username }} --conf.password {{ awx_password }}
  105. inventory create --name "{{ provisioned_idrac_inventory_name }}" --organization "{{ awx_organization }}"
  106. register: create_inventory
  107. run_once: true
  108. changed_when: true
  109. no_log: true
  110. when: provisioned_idrac_inventory_name not in inventory_list.stdout
  111. - name: Fetch provisioned_idrac inventory
  112. command: >-
  113. awx --conf.host {{ awx_host }} --conf.username {{ awx_username }} --conf.password {{ awx_password }}
  114. hosts list --inventory "{{ provisioned_idrac_inventory_name }}" -f human --filter "name"
  115. register: fetch_inventory
  116. run_once: true
  117. changed_when: false
  118. no_log: true
  119. - name: Set provision status
  120. set_fact:
  121. provision_status: true
  122. when: inventory_hostname in fetch_inventory.stdout
  123. - name: Removing hosts already provisioned
  124. debug:
  125. msg: "{{ provision_skip_msg }}"
  126. when: provision_status
  127. when: awx_search_key in hostname.stdout
  128. - block:
  129. - name: Show status of the Lifecycle Controller
  130. dellemc.openmanage.idrac_lifecycle_controller_status_info:
  131. idrac_ip: "{{ inventory_hostname }}"
  132. idrac_user: "{{ idrac_username }}"
  133. idrac_password: "{{ idrac_password }}"
  134. register: lc_check_status
  135. - name: LC not available
  136. fail:
  137. msg: "{{ lc_check_fail_msg }}"
  138. when: not lc_check_status.lc_status_info.LCReady
  139. register: lc_fail
  140. - name: Get system inventory
  141. dellemc.openmanage.idrac_system_info:
  142. idrac_ip: "{{ inventory_hostname }}"
  143. idrac_user: "{{ idrac_username }}"
  144. idrac_password: "{{ idrac_password }}"
  145. register: idrac_info
  146. - block:
  147. - name: Set enterprise license status
  148. set_fact:
  149. enterprise_license: true
  150. idrac_license_name: "{{ idrac_info.system_info.License[my_idx1].LicenseDescription }}"
  151. with_items: "{{ idrac_info.system_info.License }}"
  152. when:
  153. - '"iDRAC" in idrac_info.system_info.License[my_idx1].LicenseDescription'
  154. - '"Enterprise" in idrac_info.system_info.License[my_idx1].LicenseDescription'
  155. - '"License" in idrac_info.system_info.License[my_idx1].LicenseDescription'
  156. - '"Healthy" in idrac_info.system_info.License[my_idx1].PrimaryStatus'
  157. loop_control:
  158. index_var: my_idx1
  159. - name: Set datacenter license status
  160. set_fact:
  161. datacenter_license: true
  162. idrac_license_name: "{{ idrac_info.system_info.License[my_idx1].LicenseDescription }}"
  163. with_items: "{{ idrac_info.system_info.License }}"
  164. when:
  165. - '"iDRAC" in idrac_info.system_info.License[my_idx2].LicenseDescription'
  166. - '"Datacenter" in idrac_info.system_info.License[my_idx2].LicenseDescription'
  167. - '"License" in idrac_info.system_info.License[my_idx2].LicenseDescription'
  168. - '"Healthy" in idrac_info.system_info.License[my_idx2].PrimaryStatus'
  169. loop_control:
  170. index_var: my_idx2
  171. when: idrac_info.system_info.License is defined
  172. - name: Change provision mode in absence of license
  173. set_fact:
  174. provision_method: "pxe"
  175. when: not (enterprise_license or datacenter_license)
  176. - name: Firmware version of iDRAC9 not supported
  177. debug:
  178. msg: "{{ idrac9_firmware_not_supported_msg }}"
  179. when:
  180. - '"iDRAC9" in idrac_license_name'
  181. - idrac_info.system_info.iDRAC[0].FirmwareVersion < idrac9_supported_version
  182. - name: Firmware version of iDRAC8 not supported
  183. debug:
  184. msg: "{{ idrac8_firmware_not_supported_msg }}"
  185. when:
  186. - '"iDRAC8" in idrac_license_name'
  187. - idrac_info.system_info.iDRAC[0].FirmwareVersion < idrac8_supported_version
  188. - name: Check NFS share access
  189. dellemc.openmanage.idrac_server_config_profile:
  190. idrac_ip: "{{ inventory_hostname }}"
  191. idrac_user: "{{ idrac_username }}"
  192. idrac_password: "{{ idrac_password }}"
  193. share_name: "{{ management_station_ip }}:{{ nfs_share_offline_repo }}"
  194. command: "export"
  195. scp_components: "BIOS"
  196. scp_file: "{{ nfs_check_file }}"
  197. export_format: XML
  198. export_use: Default
  199. job_wait: true
  200. register: nfs_check
  201. ignore_errors: true
  202. until: not nfs_check.failed
  203. retries: "{{ retries_count }}"
  204. - name: Missing entries in nfs exports
  205. fail:
  206. msg: "{{ missing_exports_fail_msg }}"
  207. when:
  208. - nfs_check_key in nfs_check.msg or
  209. nfs_check_key in nfs_check.scp_status.Status
  210. when: not provision_status