Chapter 5. The Redfish modules in RHEL
The Redfish modules for remote management of devices are now part of the redhat.rhel_mgmt
Ansible collection. With the Redfish modules, you can easily use management automation on bare-metal servers and platform hardware by getting information about the servers or control them through an Out-Of-Band (OOB) controller, using the standard HTTPS transport and JSON format.
5.1. The Redfish modules
The redhat.rhel_mgmt
Ansible collection provides the Redfish modules to support hardware management in Ansible over Redfish. The redhat.rhel_mgmt
collection is available in the ansible-collection-redhat-rhel_mgmt
package. To install it, see Installing the redhat.rhel_mgmt Collection using the CLI.
The following Redfish modules are available in the redhat.rhel_mgmt
collection:
-
redfish_info
: Theredfish_info
module retrieves information about the remote Out-Of-Band (OOB) controller such as systems inventory. -
redfish_command
: Theredfish_command
module performs Out-Of-Band (OOB) controller operations like log management and user management, and power operations such as system restart, power on and off. -
redfish_config
: Theredfish_config
module performs OOB controller operations such as changing OOB configuration, or setting the BIOS configuration.
5.2. Redfish modules parameters
The parameters used for the Redfish modules are:
redfish_info parameters: | Description |
---|---|
| (Mandatory) - Base URI of OOB controller. |
| (Mandatory) - List of categories to execute on OOB controller. The default value is ["Systems"]. |
| (Mandatory) - List of commands to execute on OOB controller. |
| Username for authentication to OOB controller. |
| Password for authentication to OOB controller. |
redfish_command parameters: | Description |
---|---|
| (Mandatory) - Base URI of OOB controller. |
| (Mandatory) - List of categories to execute on OOB controller. The default value is ["Systems"]. |
| (Mandatory) - List of commands to execute on OOB controller. |
| Username for authentication to OOB controller. |
| Password for authentication to OOB controller. |
redfish_config parameters: | Description |
---|---|
| (Mandatory) - Base URI of OOB controller. |
| (Mandatory) - List of categories to execute on OOB controller. The default value is ["Systems"]. |
| (Mandatory) - List of commands to execute on OOB controller. |
| Username for authentication to OOB controller. |
| Password for authentication to OOB controller. |
| BIOS attributes to update. |
5.3. Using the redfish_info module
The following example shows how to use the redfish_info
module in a playbook to get information about the CPU inventory. For simplicity, the example uses the same host as the Ansible control host and managed host, thus executing the modules on the same host where the playbook is executed.
Prerequisites
-
The
redhat.rhel_mgmt
collection is installed. -
The
pyghmi
library in thepython3-pyghmi
package is installed on the managed host. If you use localhost as the managed host, install thepython3-pyghmi
package on the host where you execute the playbook. - OOB controller access details.
Procedure
Create a new playbook.yml file with the following content:
--- - name: Get CPU inventory hosts: localhost tasks: - redhat.rhel_mgmt.redfish_info: baseuri: "{{ baseuri }}" username: "{{ username }}" password: "{{ password }}" category: Systems command: GetCpuInventory register: result
Execute the playbook against localhost:
# ansible-playbook playbook.yml
As a result, the output returns the CPU inventory details.
5.4. Using the redfish_command module
The following example shows how to use the redfish_command
module in a playbook to turn on a system. For simplicity, the example uses the same host as the Ansible control host and managed host, thus executing the modules on the same host where the playbook is executed.
Prerequisites
-
The
redhat.rhel_mgmt
collection is installed. -
The
pyghmi
library in thepython3-pyghmi
package is installed on the managed host. If you use localhost as the managed host, install thepython3-pyghmi
package on the host where you execute the playbook. - OOB controller access details.
Procedure
Create a new playbook.yml file with the following content:
--- - name: Power on system hosts: localhost tasks: - redhat.rhel_mgmt.redfish_command: baseuri: "{{ baseuri }}" username: "{{ username }}" password: "{{ password }}" category: Systems command: PowerOn
Execute the playbook against localhost:
# ansible-playbook playbook.yml
As a result, the system powers on.
5.5. Using the redfish_config module
The following example shows how to use the redfish_config
module in a playbook to configure a system to boot with UEFI. For simplicity, the example uses the same host as the Ansible control host and managed host, thus executing the modules on the same host where the playbook is executed.
Prerequisites
-
The
redhat.rhel_mgmt
collection is installed. -
The
pyghmi
library in thepython3-pyghmi
package is installed on the managed host. If you use localhost as the managed host, install thepython3-pyghmi
package on the host where you execute the playbook. - OOB controller access details.
Procedure
Create a new playbook.yml file with the following content:
--- - name: "Set BootMode to UEFI" hosts: localhost tasks: - redhat.rhel_mgmt.redfish_config: baseuri: "{{ baseuri }}" username: "{{ username }}" password: "{{ password }}" category: Systems command: SetBiosAttributes bios_attributes: BootMode: Uefi
Execute the playbook against localhost:
# ansible-playbook playbook.yml
As a result, the system boot mode is set to UEFI.