check_prerequisites.yml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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 unattended ISO file
  22. stat:
  23. path: "{{ role_path }}/../control_plane_customiso/files/{{ unattended_iso_filename }}"
  24. register: custom_iso_check
  25. run_once: true
  26. - name: Custom ISO file not present
  27. fail:
  28. msg: "{{ custom_iso_check_fail_msg }}"
  29. when: not custom_iso_check.stat.exists
  30. register: custom_iso_fail
  31. - name: Adding NFS share entries in {{ exports_file_path }}
  32. lineinfile:
  33. path: "{{ exports_file_path }}"
  34. line: "{{ nfs_share_offline_repo }} {{ inventory_hostname }}(rw,sync,no_root_squash)"
  35. when: '"awx-" not in hostname.stdout'
  36. - name: Exporting the shared directories
  37. command: exportfs -r
  38. changed_when: true
  39. when: '"awx-" not in hostname.stdout'
  40. run_once: true
  41. - name: Check nfs exports file present
  42. stat:
  43. path: "{{ role_path }}/../control_plane_customiso/files/exports"
  44. register: nfs_exports_present
  45. when: '"awx-" in hostname.stdout'
  46. run_once: true
  47. - name: Check nfs exports file content
  48. command: cat "{{ role_path }}/../control_plane_customiso/files/exports"
  49. changed_when: false
  50. register: check_exports_path
  51. run_once: true
  52. when:
  53. - '"awx-" in hostname.stdout'
  54. - nfs_exports_present.stat.exists
  55. - name: Missing entries in nfs exports
  56. fail:
  57. msg: "{{ missing_exports_fail_msg }}"
  58. when:
  59. - '"awx-" in hostname.stdout'
  60. - not nfs_exports_present.stat.exists or
  61. check_exports_path.rc == 1 or
  62. inventory_hostname not in check_exports_path.stdout
  63. - name: Fetch management station ip from exports file
  64. shell: awk 'FNR==1' {{ role_path }}/../control_plane_customiso/files/exports | awk '{print $2}'
  65. changed_when: false
  66. register: fetch_public_ip
  67. when: '"awx-" in hostname.stdout'
  68. - name: Set public ip
  69. set_fact:
  70. public_ip: "{{ fetch_public_ip.stdout.split(\"(\")[0] }}"
  71. when: '"awx-" in hostname.stdout'
  72. - name: Initialize variables
  73. set_fact:
  74. raid_type: false
  75. raid_controller_sensor: ""
  76. raid_enclosure_name: ""
  77. drives_id: ""
  78. enterprise_license: false
  79. datacenter_license: false
  80. provision_status: false
  81. - name: Check provisioned_idrac_ip.yml file present
  82. stat:
  83. path: "{{ role_path }}/files/provisioned_idrac_ip.yml"
  84. register: provisioned_file_present
  85. run_once: true
  86. - name: Check idrac server is already provisioned
  87. command: cat {{ role_path }}/files/provisioned_idrac_ip.yml
  88. changed_when: false
  89. register: check_provision_status
  90. when: provisioned_file_present.stat.exists
  91. run_once: true
  92. - name: Removing hosts already provisioned
  93. fail:
  94. msg: "{{ provision_fail_msg }}"
  95. when:
  96. - provisioned_file_present.stat.exists
  97. - inventory_hostname in check_provision_status.stdout
  98. - name: Show status of the Lifecycle Controller
  99. dellemc.openmanage.idrac_lifecycle_controller_status_info:
  100. idrac_ip: "{{ inventory_hostname }}"
  101. idrac_user: "{{ idrac_username }}"
  102. idrac_password: "{{ idrac_password }}"
  103. register: lc_check_status
  104. - name: LC not available
  105. fail:
  106. msg: "{{ lc_check_fail_msg }}"
  107. when: not lc_check_status.lc_status_info.LCReady
  108. register: lc_fail
  109. - name: Get system inventory
  110. dellemc.openmanage.idrac_system_info:
  111. idrac_ip: "{{ inventory_hostname }}"
  112. idrac_user: "{{ idrac_username }}"
  113. idrac_password: "{{ idrac_password }}"
  114. register: idrac_info
  115. - name: Set enterprise license status
  116. set_fact:
  117. enterprise_license: true
  118. with_items: "{{ idrac_info.system_info.License }}"
  119. when:
  120. - '"iDRAC" in idrac_info.system_info.License[my_idx1].LicenseDescription'
  121. - '"Enterprise" in idrac_info.system_info.License[my_idx1].LicenseDescription'
  122. - '"License" in idrac_info.system_info.License[my_idx1].LicenseDescription'
  123. - '"Healthy" in idrac_info.system_info.License[my_idx1].PrimaryStatus'
  124. loop_control:
  125. index_var: my_idx1
  126. - name: Set datacenter license status
  127. set_fact:
  128. datacenter_license: true
  129. with_items: "{{ idrac_info.system_info.License }}"
  130. when:
  131. - '"iDRAC" in idrac_info.system_info.License[my_idx2].LicenseDescription'
  132. - '"Datacenter" in idrac_info.system_info.License[my_idx2].LicenseDescription'
  133. - '"License" in idrac_info.system_info.License[my_idx2].LicenseDescription'
  134. - '"Healthy" in idrac_info.system_info.License[my_idx2].PrimaryStatus'
  135. loop_control:
  136. index_var: my_idx2