deploy_os.yml 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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: Set one-time boot device to PXE
  16. community.general.redfish_command:
  17. category: Systems
  18. command: SetOneTimeBoot
  19. bootdevice: "Pxe"
  20. baseuri: "{{ inventory_hostname }}"
  21. username: "{{ idrac_username }}"
  22. password: "{{ idrac_password }}"
  23. when: not (enterprise_license or datacenter_license)
  24. - name: Reboot server
  25. dellemc.openmanage.redfish_powerstate:
  26. baseuri: "{{ inventory_hostname }}"
  27. username: "{{ idrac_username }}"
  28. password: "{{ idrac_password }}"
  29. reset_type: ForceRestart
  30. when: not (enterprise_license or datacenter_license)
  31. register: deploy_os
  32. - name: Install OS using iDRAC
  33. dellemc.openmanage.idrac_os_deployment:
  34. idrac_ip: "{{ inventory_hostname }}"
  35. idrac_user: "{{ idrac_username }}"
  36. idrac_password: "{{ idrac_password }}"
  37. share_name: "{{ management_station_ip }}:{{ nfs_share_offline_repo }}"
  38. iso_image: "{{ unattended_iso_filename }}"
  39. expose_duration: "{{ expose_duration }}"
  40. register: deploy_os
  41. when: enterprise_license or datacenter_license
  42. - name: Add to provisioned_hosts to inventory
  43. command: >-
  44. awx --conf.host {{ awx_host }} --conf.username {{ awx_username }} --conf.password {{ awx_password }}
  45. hosts create --name {{ inventory_hostname }} --inventory "{{ provisioned_idrac_inventory_name }}"
  46. register: update_inventory
  47. changed_when: true
  48. no_log: true
  49. when:
  50. - awx_search_key in hostname.stdout
  51. - inventory_hostname not in fetch_inventory.stdout
  52. - not deploy_os.failed
  53. - name: Provision OS status
  54. debug:
  55. msg: "{{ provision_os_msg }}"
  56. when: not deploy_os.failed