I have this playbook that what I'm trying to do it's to install CentOS using Ansible and Redfish, I don't want to use any modules, I'll install the CentOS on multiple Dell iDRAC9 servers and I'm having one issue:
2)After the ISO it's mounted, the server has not entered automatically into ISO boot menu, and I'm trying to achieve this by the Set boot order task.
Hello,
I have this playbook that what I'm trying to do it's to install CentOS using Ansible and Redfish, I don't want to use any modules, I'll install the CentOS on multiple Dell iDRAC9 servers and I'm having one issue:
2)After the ISO it's mounted, the server has not entered automatically into ISO boot menu, and I'm trying to achieve this by the Set boot order task.
Can someone please help me to correct this?
Here's the code:
`- hosts: Linux_OS_machine connection: local name: ULP image install gather_facts: false vars: ansible_python_interpreter: /usr/bin/env python datatype: SetBiosAttributes image: "{{ iso_version }}-{{ inventory_hostname }}.iso"
tasks:
name: Check system power state uri: url: https://{{ idrac }}/redfish/v1/Systems/System.Embedded.1 user: "{{ idrac_user }}" password: "{{ idrac_pass }}" method: GET validate_certs: false force_basic_auth: yes return_content: yes register: system_status
name: Power on system if off when: system_status.json.PowerState == "Off" uri: url: https://{{ idrac }}/redfish/v1/Systems/System.Embedded.1/Actions/ComputerSystem.Reset/ user: "{{ idrac_user }}" password: "{{ idrac_pass }}" method: POST body: ResetType: On validate_certs: false force_basic_auth: yes status_code: 204 body_format: json
name: Wait for 3 minutes for system to power on pause: minutes: 3 when: system_status.json.PowerState == "Off"
name: Check if virtual media is mounted uri: url: https://{{ idrac }}/redfish/v1/Managers/iDRAC.Embedded.1/VirtualMedia/CD user: "{{ idrac_user }}" password: "{{ idrac_pass }}" method: GET validate_certs: false force_basic_auth: yes return_content: yes register: vm_status
name: Unmount virtual media if mounted uri: url: https://{{ idrac }}/redfish/v1/Managers/iDRAC.Embedded.1/VirtualMedia/CD/Actions/VirtualMedia.EjectMedia method: POST user: "{{ idrac_user }}" password: "{{ idrac_pass }}" validate_certs: false force_basic_auth: yes status_code: 204 body_format: json vars: image: "{{ iso_version }}-{{ inventory_hostname }}.iso" when:
name: Mount virtual media if not already mounted uri: url: https://{{ idrac }}/redfish/v1/Managers/iDRAC.Embedded.1/VirtualMedia/CD/Actions/VirtualMedia.InsertMedia method: POST headers: Authorization: Basic {{ (idrac_user + ':' + idrac_pass) | b64encode }} user: "{{ idrac_user }}" password: "{{ idrac_pass }}" validate_certs: false force_basic_auth: yes status_code: [200, 204] body_format: json body: Image: "" vars: image: "{{ iso_version }}-{{ inventory_hostname }}.iso" when:
name: Set boot order to CD/DVD uri: url: https://{{ idrac }}/redfish/v1/Systems/System.Embedded.1/Bios/ method: PATCH user: "{{ idrac_user }}" password: "{{ idrac_pass }}" validate_certs: no force_basic_auth: yes headers: Content-Type: application/json body_format: json body: Attributes: {}
register: boot_order
name: Reboot the system uri: url: https://{{ idrac }}/redfish/v1/Systems/System.Embedded.1/Actions/ComputerSystem.Reset/ user: "{{ idrac_user }}" password: "{{ idrac_pass }}" method: POST body: ResetType: ForceRestart validate_certs: false force_basic_auth: yes status_code: 204 body_format: json
name: Wait for 5 minutes for system to power on pause: minutes: 5
name: Pause for 15 minutes for ULP image to be installed pause: minutes: 15
name: Wait for system to boot up wait_for: port: 22 host: "{{ inventory_hostname }}" delay: 30 timeout: 900 `
Thanks!