deploy_os.yml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. - block:
  16. - name: Configure boot order for PXE booting
  17. dellemc.openmanage.idrac_bios:
  18. idrac_ip: "{{ inventory_hostname }}"
  19. idrac_user: "{{ idrac_username }}"
  20. idrac_password: "{{ idrac_password }}"
  21. attributes:
  22. SetBootOrderEn: NIC.PxeDevice.1-1,NIC.PxeDevice.2-1,NIC.PxeDevice.3-1,NIC.PxeDevice.4-1
  23. UefiBootSeq: NIC.PxeDevice.1-1,NIC.PxeDevice.2-1,NIC.PxeDevice.3-1,NIC.PxeDevice.4-1
  24. register: deploy_os_pxe
  25. rescue:
  26. - name: OS provisioning failed using PXE
  27. fail:
  28. msg: "{{ pxe_provisioning_fail_msg }}"
  29. always:
  30. - name: Set deploy_os_status when provision_method == PXE
  31. set_fact:
  32. deploy_os_status: "{{ not deploy_os_pxe.failed }}"
  33. when: provision_method == provision_method_pxe
  34. - name: Deploy OS using iDRAC
  35. block:
  36. - name: Set unattended_iso_filename - centos
  37. set_fact:
  38. unattended_iso_filename: "{{ centos_iso_filename }}"
  39. when: provision_os == os_supported_centos
  40. - name: Set unattended_iso_filename - rocky
  41. set_fact:
  42. unattended_iso_filename: "{{ rocky_iso_filename }}"
  43. when: provision_os == os_supported_rocky
  44. - name: Set unattended_iso_filename - leap
  45. set_fact:
  46. unattended_iso_filename: "{{ leap_iso_filename }}"
  47. when: provision_os == os_supported_leap
  48. - name: Install OS using iDRAC
  49. dellemc.openmanage.idrac_os_deployment:
  50. idrac_ip: "{{ inventory_hostname }}"
  51. idrac_user: "{{ idrac_username }}"
  52. idrac_password: "{{ idrac_password }}"
  53. share_name: "{{ management_station_ip }}:{{ nfs_share_offline_repo }}"
  54. iso_image: "{{ unattended_iso_filename }}"
  55. expose_duration: "{{ expose_duration }}"
  56. register: deploy_os_idrac
  57. rescue:
  58. - name: Retry deploy OS using iDRAC after reset
  59. block:
  60. - name: Reset iDRAC
  61. dellemc.openmanage.idrac_reset:
  62. idrac_ip: "{{ inventory_hostname }}"
  63. idrac_user: "{{ idrac_username }}"
  64. idrac_password: "{{ idrac_password }}"
  65. - name: Wait for iDRAC Port to become active
  66. wait_for:
  67. host: "{{ inventory_hostname }}"
  68. port: "{{ idrac_port }}"
  69. delay: "{{ max_delay }}"
  70. timeout: "{{ max_timeout }}"
  71. state: started
  72. register: wait_for_idrac
  73. failed_when: wait_for_idrac.elapsed < idrac_reset_time
  74. - name: Get LC status
  75. dellemc.openmanage.idrac_lifecycle_controller_status_info:
  76. idrac_ip: "{{ inventory_hostname }}"
  77. idrac_user: "{{ idrac_username }}"
  78. idrac_password: "{{ idrac_password }}"
  79. register: lc_status
  80. until: lc_status.lc_status_info.LCReady
  81. retries: "{{ max_retries }}"
  82. delay: "{{ max_delay }}"
  83. - name: Retry installing OS using iDRAC
  84. dellemc.openmanage.idrac_os_deployment:
  85. idrac_ip: "{{ inventory_hostname }}"
  86. idrac_user: "{{ idrac_username }}"
  87. idrac_password: "{{ idrac_password }}"
  88. share_name: "{{ management_station_ip }}:{{ nfs_share_offline_repo }}"
  89. iso_image: "{{ unattended_iso_filename }}"
  90. expose_duration: "{{ expose_duration }}"
  91. register: deploy_os_idrac
  92. rescue:
  93. - name: OS provisioning failed using iDRAC
  94. fail:
  95. msg: "{{ idrac_provisioning_fail_msg }}"
  96. always:
  97. - name: Set deploy_os_status when provision_method == idrac
  98. set_fact:
  99. deploy_os_status: "{{ not deploy_os_idrac.failed }}"
  100. when: provision_method == provision_method_idrac
  101. - block:
  102. - name: Add to provisioned_hosts to inventory
  103. command: >-
  104. awx --conf.host {{ awx_host }} --conf.username {{ awx_username }} --conf.password {{ awx_password }}
  105. hosts create --name {{ inventory_hostname }} --inventory "{{ provisioned_idrac_inventory_name }}"
  106. register: update_inventory
  107. changed_when: true
  108. no_log: true
  109. when:
  110. - awx_search_key in hostname.stdout
  111. - inventory_hostname not in fetch_inventory.stdout
  112. - deploy_os_status
  113. rescue:
  114. - name: Unable to add host to provisioned_idrac_inventory
  115. fail:
  116. msg: "{{ add_inventory_fail_msg }}"
  117. - name: Provision OS status
  118. debug:
  119. msg: "{{ provision_os_msg }}"
  120. when: deploy_os_status