Score:0

Virtual Media it's not ejected on the Dell iDRAC9 after the installation using Ansible it's completed

yt flag

I have this code but unfortunately it's not ejecting the ISO after installing the CentOS and I don't know what to do, can someone please give me a hint on how I can treat this? I can't use Ansible modules, I'm forced to use only the Redfish API.

Here's the code:

- hosts: Linux_OS_machine
  connection: local
  gather_facts: False
  vars:
    datatype: SetBiosAttributes

  tasks:
    - 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: Umount virtual media if mounted, ignore errors if not
      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
        body_format: json
        status_code: 204
        ignore_errors: yes
      vars:
        image: "{{ iso_version }}-{{ inventory_hostname }}.iso"
      when:
        - vm_status.json.ConnectedVia == "VirtualMedia"
        - vm_status.json.Status != "NotConnected"
        - vm_status.json.Image == image

    - name: Mount virtual media
      uri:
        url: "https://{{ idrac }}/redfish/v1/Managers/iDRAC.Embedded.1/VirtualMedia/CD/Actions/VirtualMedia.InsertMedia"
        method: POST
        user: "{{ idrac_user }}"
        password: "{{ idrac_pass }}"
        validate_certs: False
        status_code: [200, 204]
        body:
          Image: ""
          Oem: {
            "Dell": {
              "BootOnce": "Cd"
            }
          }
        body_format: json
      when:
        - vm_status.json.ConnectedVia == "NotConnected"
        
    - name: Set BIOS boot mode to Legacy
      uri:
        url: "https://{{ idrac }}/redfish/v1/Systems/System.Embedded.1/Bios/Settings"
        method: PATCH
        user: "{{ idrac_user }}"
        password: "{{ idrac_pass }}"
        validate_certs: False
        status_code: [200, 204]
        body:
          Attributes:
            BootMode: Bios
        body_format: json

    - name: Set boot order to boot from HDD
      uri:
        url: https://{{ idrac }}/redfish/v1/Systems/System.Embedded.1
        method: PATCH
        headers:
          Authorization: Basic {{ (idrac_user + ':' + idrac_pass) | b64encode }}
          Content-Type: application/json
        user: "{{ idrac_user }}"
        password: "{{ idrac_pass }}"
        validate_certs: false
        force_basic_auth: yes
        status_code: [200, 204]
        body_format: json
        body:
          Boot:
            BootSourceOverrideTarget: Hdd
            BootSourceOverrideEnabled: Continuous
            BootSourceOverrideMode: Legacy

    - name: Set ISO as primary boot device for installing the ULP
      uri:
        url: https://{{ idrac }}/redfish/v1/Systems/System.Embedded.1
        method: PATCH
        headers:
          Authorization: Basic {{ (idrac_user + ':' + idrac_pass) | b64encode }}
          Content-Type: application/json
        user: "{{ idrac_user }}"
        password: "{{ idrac_pass }}"
        validate_certs: false
        force_basic_auth: yes
        status_code: [200, 204]
        body_format: json
        body:
          Boot:
            BootSourceOverrideTarget: Cd
            BootSourceOverrideEnabled: Once
            BootSourceOverrideMode: Legacy

    - name: Restart system to start ulp auto install
      uri:
        url: "https://{{ idrac }}/redfish/v1/Systems/System.Embedded.1/Actions/ComputerSystem.Reset"
        method: POST
        user: "{{ idrac_user }}"
        password: "{{ idrac_pass }}"
        validate_certs: False
        body: {
          "ResetType": "GracefulRestart"
        }
        body_format: json
        status_code: [200, 204]
        
    - name: Display message after restarting system
      debug:
        msg: "Wait for the ULP installation to be completed."


    - name: Wait for ssh
      wait_for:
        port: 22
        host: '{{ inventory_hostname }}'
        timeout: 8000
        delay: 30
      delegate_to: localhost
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.