deploy_os.yml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. - 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. - block:
  35. - name: Set unattended_iso_filename - centos
  36. set_fact:
  37. unattended_iso_filename: "{{ centos_iso_filename }}"
  38. when: provision_os == os_supported_centos
  39. - name: Set unattended_iso_filename - rocky
  40. set_fact:
  41. unattended_iso_filename: "{{ rocky_iso_filename }}"
  42. when: provision_os == os_supported_rocky
  43. - name: Install OS using iDRAC
  44. dellemc.openmanage.idrac_os_deployment:
  45. idrac_ip: "{{ inventory_hostname }}"
  46. idrac_user: "{{ idrac_username }}"
  47. idrac_password: "{{ idrac_password }}"
  48. share_name: "{{ management_station_ip }}:{{ nfs_share_offline_repo }}"
  49. iso_image: "{{ unattended_iso_filename }}"
  50. expose_duration: "{{ expose_duration }}"
  51. register: deploy_os_idrac
  52. rescue:
  53. - name: OS provisioning failed using iDRAC
  54. fail:
  55. msg: "{{ idrac_provisioning_fail_msg }}"
  56. always:
  57. - name: Set deploy_os_status when provision_method == idrac
  58. set_fact:
  59. deploy_os_status: "{{ not deploy_os_idrac.failed }}"
  60. when: provision_method == provision_method_idrac
  61. - block:
  62. - name: Add to provisioned_hosts to inventory
  63. command: >-
  64. awx --conf.host {{ awx_host }} --conf.username {{ awx_username }} --conf.password {{ awx_password }}
  65. hosts create --name {{ inventory_hostname }} --inventory "{{ provisioned_idrac_inventory_name }}"
  66. register: update_inventory
  67. changed_when: true
  68. no_log: true
  69. when:
  70. - awx_search_key in hostname.stdout
  71. - inventory_hostname not in fetch_inventory.stdout
  72. - deploy_os_status
  73. rescue:
  74. - name: Unable to add host to provisioned_idrac_inventory
  75. fail:
  76. msg: "{{ add_inventory_fail_msg }}"
  77. - name: Provision OS status
  78. debug:
  79. msg: "{{ provision_os_msg }}"
  80. when: deploy_os_status