check_prerequisites.yml 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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_repo vars
  16. include_vars: ../../control_plane_repo/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. shell: 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: Check NFS share access
  40. idrac_server_config_profile:
  41. idrac_ip: "{{ inventory_hostname }}"
  42. idrac_user: "{{ idrac_username }}"
  43. idrac_password: "{{ idrac_password }}"
  44. share_name: "{{ management_station_ip }}:{{ nfs_share_offline_repo }}"
  45. command: "export"
  46. scp_components: "BIOS"
  47. scp_file: "{{ nfs_check_file }}"
  48. export_format: XML
  49. export_use: Default
  50. job_wait: true
  51. register: nfs_check
  52. ignore_errors: true
  53. - name: Missing entries in nfs exports
  54. fail:
  55. msg: "{{ missing_exports_fail_msg }}"
  56. when:
  57. - nfs_check_key in nfs_check.msg or
  58. nfs_check_key in nfs_check.scp_status.Status
  59. - name: Initialize variables
  60. set_fact:
  61. raid_type: false
  62. raid_controller_sensor: ""
  63. raid_enclosure_name: ""
  64. drives_id: ""
  65. enterprise_license: false
  66. datacenter_license: false
  67. provision_status: false
  68. - name: Check tower_cli.cfg is encrypted
  69. command: cat "{{ playbook_dir }}/roles/webui_awx/files/{{ awx_vars_filename }}"
  70. changed_when: false
  71. register: awx_content
  72. run_once: true
  73. when: awx_search_key in hostname.stdout
  74. - name: Decrpyt tower_cli.cfg
  75. command: >-
  76. ansible-vault decrypt "{{ playbook_dir }}/roles/webui_awx/files/{{ awx_vars_filename }}"
  77. --vault-password-file "{{ playbook_dir }}/roles/webui_awx/files/{{ awx_vaultname }}"
  78. changed_when: false
  79. run_once: true
  80. when:
  81. - awx_search_key in hostname.stdout
  82. - "'$ANSIBLE_VAULT;' in awx_content.stdout"
  83. - name: Fetch awx host
  84. command: grep "host:" "{{ playbook_dir }}/roles/webui_awx/files/{{ awx_vars_filename }}"
  85. register: fetch_awx_host
  86. changed_when: false
  87. run_once: true
  88. when: awx_search_key in hostname.stdout
  89. - name: Fetch awx username
  90. command: grep "username:" "{{ playbook_dir }}/roles/webui_awx/files/{{ awx_vars_filename }}"
  91. register: fetch_awx_username
  92. changed_when: false
  93. run_once: true
  94. no_log: true
  95. when: awx_search_key in hostname.stdout
  96. - name: Fetch awx password
  97. command: grep "password:" "{{ playbook_dir }}/roles/webui_awx/files/{{ awx_vars_filename }}"
  98. register: fetch_awx_password
  99. changed_when: false
  100. run_once: true
  101. no_log: true
  102. when: awx_search_key in hostname.stdout
  103. - name: Set awx variables
  104. set_fact:
  105. awx_host: "{{ fetch_awx_host.stdout | regex_replace('host: ','') }}"
  106. awx_username: "{{ fetch_awx_username.stdout | regex_replace('username: ','') }}"
  107. awx_password: "{{ fetch_awx_password.stdout | regex_replace('password: ','') }}"
  108. no_log: true
  109. when: awx_search_key in hostname.stdout
  110. - name: Encrypt tower_cli.cfg
  111. command: >-
  112. ansible-vault encrypt "{{ playbook_dir }}/roles/webui_awx/files/{{ awx_vars_filename }}"
  113. --vault-password-file "{{ playbook_dir }}/roles/webui_awx/files/{{ awx_vaultname }}"
  114. changed_when: false
  115. run_once: true
  116. when:
  117. - awx_search_key in hostname.stdout
  118. - "'$ANSIBLE_VAULT;' in awx_content.stdout"
  119. - name: Get inventory list
  120. command: >-
  121. awx --conf.host "{{ awx_host }}" --conf.username "{{ awx_username }}" --conf.password "{{ awx_password }}"
  122. inventory list -f human --filter "name"
  123. register: inventory_list
  124. run_once: true
  125. changed_when: false
  126. no_log: true
  127. when: awx_search_key in hostname.stdout
  128. - name: Create provisioned_idrac inventory
  129. command: >-
  130. awx --conf.host {{ awx_host }} --conf.username {{ awx_username }} --conf.password {{ awx_password }}
  131. inventory create --name "{{ provisioned_idrac_inventory_name }}" --organization "{{ awx_organization }}"
  132. register: create_inventory
  133. run_once: true
  134. changed_when: true
  135. no_log: true
  136. when:
  137. - awx_search_key in hostname.stdout
  138. - provisioned_idrac_inventory_name not in inventory_list.stdout
  139. - name: Fetch provisioned_idrac inventory
  140. command: >-
  141. awx --conf.host {{ awx_host }} --conf.username {{ awx_username }} --conf.password {{ awx_password }}
  142. hosts list --inventory "{{ provisioned_idrac_inventory_name }}" -f human --filter "name"
  143. register: fetch_inventory
  144. run_once: true
  145. changed_when: false
  146. no_log: true
  147. when: awx_search_key in hostname.stdout
  148. - name: Removing hosts already provisioned
  149. fail:
  150. msg: "{{ provision_skip_msg }}"
  151. when:
  152. - awx_search_key in hostname.stdout
  153. - inventory_hostname in fetch_inventory.stdout
  154. - name: Show status of the Lifecycle Controller
  155. dellemc.openmanage.idrac_lifecycle_controller_status_info:
  156. idrac_ip: "{{ inventory_hostname }}"
  157. idrac_user: "{{ idrac_username }}"
  158. idrac_password: "{{ idrac_password }}"
  159. register: lc_check_status
  160. - name: LC not available
  161. fail:
  162. msg: "{{ lc_check_fail_msg }}"
  163. when: not lc_check_status.lc_status_info.LCReady
  164. register: lc_fail
  165. - name: Get system inventory
  166. dellemc.openmanage.idrac_system_info:
  167. idrac_ip: "{{ inventory_hostname }}"
  168. idrac_user: "{{ idrac_username }}"
  169. idrac_password: "{{ idrac_password }}"
  170. register: idrac_info
  171. - name: Set enterprise license status
  172. set_fact:
  173. enterprise_license: true
  174. with_items: "{{ idrac_info.system_info.License }}"
  175. when:
  176. - '"iDRAC" in idrac_info.system_info.License[my_idx1].LicenseDescription'
  177. - '"Enterprise" in idrac_info.system_info.License[my_idx1].LicenseDescription'
  178. - '"License" in idrac_info.system_info.License[my_idx1].LicenseDescription'
  179. - '"Healthy" in idrac_info.system_info.License[my_idx1].PrimaryStatus'
  180. loop_control:
  181. index_var: my_idx1
  182. - name: Set datacenter license status
  183. set_fact:
  184. datacenter_license: true
  185. with_items: "{{ idrac_info.system_info.License }}"
  186. when:
  187. - '"iDRAC" in idrac_info.system_info.License[my_idx2].LicenseDescription'
  188. - '"Datacenter" in idrac_info.system_info.License[my_idx2].LicenseDescription'
  189. - '"License" in idrac_info.system_info.License[my_idx2].LicenseDescription'
  190. - '"Healthy" in idrac_info.system_info.License[my_idx2].PrimaryStatus'
  191. loop_control:
  192. index_var: my_idx2