check_prerequisites.yml 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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. 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. - block:
  69. - name: Check tower_cli.cfg is encrypted
  70. command: cat "{{ playbook_dir }}/roles/webui_awx/files/{{ awx_vars_filename }}"
  71. changed_when: false
  72. register: awx_content
  73. run_once: true
  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: "'$ANSIBLE_VAULT;' in awx_content.stdout"
  81. - name: Fetch awx host
  82. command: grep "host:" "{{ playbook_dir }}/roles/webui_awx/files/{{ awx_vars_filename }}"
  83. register: fetch_awx_host
  84. changed_when: false
  85. run_once: true
  86. - name: Fetch awx username
  87. command: grep "username:" "{{ playbook_dir }}/roles/webui_awx/files/{{ awx_vars_filename }}"
  88. register: fetch_awx_username
  89. changed_when: false
  90. run_once: true
  91. no_log: true
  92. - name: Fetch awx password
  93. command: grep "password:" "{{ playbook_dir }}/roles/webui_awx/files/{{ awx_vars_filename }}"
  94. register: fetch_awx_password
  95. changed_when: false
  96. run_once: true
  97. no_log: true
  98. - name: Set awx variables
  99. set_fact:
  100. awx_host: "{{ fetch_awx_host.stdout | regex_replace('host: ','') }}"
  101. awx_username: "{{ fetch_awx_username.stdout | regex_replace('username: ','') }}"
  102. awx_password: "{{ fetch_awx_password.stdout | regex_replace('password: ','') }}"
  103. no_log: true
  104. - name: Encrypt tower_cli.cfg
  105. command: >-
  106. ansible-vault encrypt "{{ playbook_dir }}/roles/webui_awx/files/{{ awx_vars_filename }}"
  107. --vault-password-file "{{ playbook_dir }}/roles/webui_awx/files/{{ awx_vaultname }}"
  108. changed_when: false
  109. run_once: true
  110. when: "'$ANSIBLE_VAULT;' in awx_content.stdout"
  111. - name: Get inventory list
  112. command: >-
  113. awx --conf.host "{{ awx_host }}" --conf.username "{{ awx_username }}" --conf.password "{{ awx_password }}"
  114. inventory list -f human --filter "name"
  115. register: inventory_list
  116. run_once: true
  117. changed_when: false
  118. no_log: true
  119. - name: Create provisioned_idrac inventory
  120. command: >-
  121. awx --conf.host {{ awx_host }} --conf.username {{ awx_username }} --conf.password {{ awx_password }}
  122. inventory create --name "{{ provisioned_idrac_inventory_name }}" --organization "{{ awx_organization }}"
  123. register: create_inventory
  124. run_once: true
  125. changed_when: true
  126. no_log: true
  127. when: provisioned_idrac_inventory_name not in inventory_list.stdout
  128. - name: Fetch provisioned_idrac inventory
  129. command: >-
  130. awx --conf.host {{ awx_host }} --conf.username {{ awx_username }} --conf.password {{ awx_password }}
  131. hosts list --inventory "{{ provisioned_idrac_inventory_name }}" -f human --filter "name"
  132. register: fetch_inventory
  133. run_once: true
  134. changed_when: false
  135. no_log: true
  136. - name: Set provision status
  137. set_fact:
  138. provision_status: true
  139. when: inventory_hostname in fetch_inventory.stdout
  140. - name: Removing hosts already provisioned
  141. debug:
  142. msg: "{{ provision_skip_msg }}"
  143. when: provision_status
  144. when: awx_search_key in hostname.stdout
  145. - block:
  146. - name: Show status of the Lifecycle Controller
  147. dellemc.openmanage.idrac_lifecycle_controller_status_info:
  148. idrac_ip: "{{ inventory_hostname }}"
  149. idrac_user: "{{ idrac_username }}"
  150. idrac_password: "{{ idrac_password }}"
  151. register: lc_check_status
  152. - name: LC not available
  153. fail:
  154. msg: "{{ lc_check_fail_msg }}"
  155. when: not lc_check_status.lc_status_info.LCReady
  156. register: lc_fail
  157. - name: Get system inventory
  158. dellemc.openmanage.idrac_system_info:
  159. idrac_ip: "{{ inventory_hostname }}"
  160. idrac_user: "{{ idrac_username }}"
  161. idrac_password: "{{ idrac_password }}"
  162. register: idrac_info
  163. - name: Set enterprise license status
  164. set_fact:
  165. enterprise_license: true
  166. with_items: "{{ idrac_info.system_info.License }}"
  167. when:
  168. - '"iDRAC" in idrac_info.system_info.License[my_idx1].LicenseDescription'
  169. - '"Enterprise" in idrac_info.system_info.License[my_idx1].LicenseDescription'
  170. - '"License" in idrac_info.system_info.License[my_idx1].LicenseDescription'
  171. - '"Healthy" in idrac_info.system_info.License[my_idx1].PrimaryStatus'
  172. loop_control:
  173. index_var: my_idx1
  174. - name: Set datacenter license status
  175. set_fact:
  176. datacenter_license: true
  177. with_items: "{{ idrac_info.system_info.License }}"
  178. when:
  179. - '"iDRAC" in idrac_info.system_info.License[my_idx2].LicenseDescription'
  180. - '"Datacenter" in idrac_info.system_info.License[my_idx2].LicenseDescription'
  181. - '"License" in idrac_info.system_info.License[my_idx2].LicenseDescription'
  182. - '"Healthy" in idrac_info.system_info.License[my_idx2].PrimaryStatus'
  183. loop_control:
  184. index_var: my_idx2
  185. when: not provision_status