Home > Servers > Systems Management > White Papers > Dell PowerEdge: Getting Started with Redfish Ansible Modules > Changing a BIOS setting
The playbooks interacting with the BIOS are stored in the redfish-ansible-module/playbooks/bios directory. That directory includes playbooks to:
First, we get the current value of all the BIOS attributes on our servers by running the get_bios_attributes.yml playbook:
All the BIOS attributes are stored in this file for zeus1053:
~/inventory_files/zeus1053/zeus1053_BiosAttributes_<timestamp>.json
Here is an extract from the file:
{
"changed": false,
"failed": false,
"redfish_facts": {
"bios_attribute": {
"entries": [
[
{
"system_uri": "/redfish/v1/Systems/System.Embedded.1"
},
{
"AcPwrRcvry": "Last",
"AcPwrRcvryDelay": "Immediate",
"AcPwrRcvryUserDelay": 60,
"AesNi": "Enabled",
"AgesaVersion": "MilanPI-SP3 1.0.0.2",
"AmdMaxXgmiSpeed": "16GB",
"ApbDis": "Disabled",
"AssetTag": "",
"AuthorizeDeviceFirmware": "Disabled",
"BiosNvmeDriver": "DellQualifiedDrives",
"BootMode": "Bios",
"BootSeqRetry": "Enabled",
"NumLock": "On",
}
]
],
"ret": true
}
}
}
In this section, we change two attributes in the BIOS: BootMode and NumLock. Changing BootMode from bios to uefi is as simple as running the provided playbook, called set_bootmode_uefi.yml, as follows:
If we run the get_bios_attributes.yml playbook again, we can see that the BootMode attribute is now set to Uefi:
{
"changed": false,
"failed": false,
"redfish_facts": {
"bios_attribute": {
"entries": [
[
{
"system_uri": "/redfish/v1/Systems/System.Embedded.1"
},
{
"AcPwrRcvry": "Last",
"AcPwrRcvryDelay": "Immediate",
"AcPwrRcvryUserDelay": 60,
"AesNi": "Enabled",
"AgesaVersion": "MilanPI-SP3 1.0.0.2",
"AmdMaxXgmiSpeed": "16GB",
"ApbDis": "Disabled",
"AssetTag": "",
"AuthorizeDeviceFirmware": "Disabled",
"BiosNvmeDriver": "DellQualifiedDrives",
"BootMode": "Uefi",
"BootSeqRetry": "Enabled",
"NumLock": "On",
}
]
],
"ret": true
}
}
}
The new value is set, and the change appears after the server reboots.
As you can see, changing the boot mode is easy because of the provided playbook. If you want to change a value for which you do not have a specific playbook, you can create one. For instance, to switch NumLock on and off, we have created a playbook called set_bios_attribute.yml:
---
- hosts: myhosts
connection: local
name: Set BIOS attributes
gather_facts: False
vars:
bios_attributes:
SriovGlobalEnable: "Enabled"
tasks:
- name: Set BIOS attribute
community.general.redfish_config:
category: Systems
command: SetBiosAttributes
bios_attributes: "{{ bios_attributes}}"
baseuri: "{{ baseuri }}"
username: "{{ username }}"
password: "{{ password }}"
register: bios_attribute
- name: Create BIOS configuration job (schedule BIOS setting update)
community.general.idrac_redfish_command:
category: Systems
command: CreateBiosConfigJob
baseuri: "{{ baseuri }}"
username: "{{ username }}"
password: "{{ password }}"
when: bios_attribute.changed
- name: Reboot system to apply new BIOS settings
community.general.redfish_command:
category: Systems
command: PowerReboot
baseuri: "{{ baseuri }}"
username: "{{ username }}"
password: "{{ password }}"
when: bios_attribute.changed
The following section is what allows this playbook to change any BIOS attribute:
vars:
bios_attributes:
SriovGlobalEnable: "Enabled"
That section creates a variable called bios_attributes with a value of SriovGlobalEnable: “Enabled”. Changing a specific BIOS attribute is as simple as changing the value of the bios_attributes variable. For instance, to set the NumLock to off, change the preceding section to:
vars:
bios_attributes:
NumLock: "Off"
After the change, the playbook file looks like this:
---
- hosts: myhosts
connection: local
name: Set BIOS attributes
gather_facts: False
vars:
bios_attributes:
NumLock: "Off"
tasks:
- name: Set BIOS attribute
community.general.redfish_config:
category: Systems
command: SetBiosAttributes
bios_attributes: "{{ bios_attributes}}"
baseuri: "{{ baseuri }}"
username: "{{ username }}"
password: "{{ password }}"
register: bios_attribute
- name: Create BIOS configuration job (schedule BIOS setting update)
community.general.idrac_redfish_command:
category: Systems
command: CreateBiosConfigJob
baseuri: "{{ baseuri }}"
username: "{{ username }}"
password: "{{ password }}"
when: bios_attribute.changed
- name: Reboot system to apply new BIOS settings
community.general.redfish_command:
category: Systems
command: PowerReboot
baseuri: "{{ baseuri }}"
username: "{{ username }}"
password: "{{ password }}"
when: bios_attribute.changed
Changing a BIOS attribute is an asynchronous operation, meaning that the playbook returns before the change is made because the playbook itself does not make the change. Instead, it sets the new value and then creates a BIOS configuration job within the iDRAC. The configuration job commits the new value to the BIOS. The new value is only visible after the configuration job is completed and the server reboots.
As we wait for the job to be completed and the server to reboot, we can see that the NumLock attribute is now set to Off:
{
"changed": false,
"failed": false,
"redfish_facts": {
"bios_attribute": {
"entries": [
[
{
"system_uri": "/redfish/v1/Systems/System.Embedded.1"
},
{
"AcPwrRcvry": "Last",
"AcPwrRcvryDelay": "Immediate",
"AcPwrRcvryUserDelay": 60,
"AesNi": "Enabled",
"AgesaVersion": "MilanPI-SP3 1.0.0.2",
"AmdMaxXgmiSpeed": "16GB",
"ApbDis": "Disabled",
"AssetTag": "",
"AuthorizeDeviceFirmware": "Disabled",
"BiosNvmeDriver": "DellQualifiedDrives",
"BootMode": "Uefi",
"BootSeqRetry": "Enabled",
"NumLock": "Off",
}
]
],
"ret": true
}
}
}
This example shows how you can use an Ansible playbook to change BIOS attributes across many servers.