dellemc.openmanage.redfish_powerstate module – Manage device power state

Note

This module is part of the dellemc.openmanage collection (version 9.9.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install dellemc.openmanage. You need further requirements to be able to use this module, see Requirements for details.

To use it in a playbook, specify: dellemc.openmanage.redfish_powerstate.

New in dellemc.openmanage 2.1.0

Synopsis

  • This module allows to manage the different power states of the specified device.

Requirements

The below requirements are needed on the host that executes this module.

  • python >= 3.9.6

Parameters

Parameter

Comments

baseuri

string / required

IP address of the target out-of-band controller. For example- <ipaddress>:<port>.

ca_path

path

added in dellemc.openmanage 5.0.0

The Privacy Enhanced Mail (PEM) file that contains a CA certificate to be used for the validation.

oem_reset_type

dictionary

added in dellemc.openmanage 9.5.0

This parameter initiates a complete Alternate Current (AC) power cycle of the server which is equivalent to disconnecting power cables using OEM API.

oem_reset_type is mutually exclusive with reset_type.

If the value of ‘final_power_state’ is not provided, the default value is ‘Off’.

password

string

Password of the target out-of-band controller.

If the password is not provided, then the environment variable IDRAC_PASSWORD is used.

Example: export IDRAC_PASSWORD=password

reset_type

string

This option resets the device.

ForceOff turns off the device immediately.

ForceOn turns on the device immediately.

ForceRestart turns off the device immediately, and then restarts the server.

GracefulRestart performs graceful shutdown of the device, and then restarts the device.

GracefulShutdown performs a graceful shutdown of the device, and then turns off the device.

Nmi sends a diagnostic interrupt to the device. This option is usually a nonmaskable interrupt (NMI) on x86 systems.

On turns on the device.

PowerCycle performs a power cycle on the device.

PushPowerButton simulates the pressing of a physical power button on the device.

reset_type is mutually exclusive with oem_reset_type.

When a power control operation is performed, which is not supported on the device, an error message is displayed with the list of operations that can be performed.

Choices:

  • "ForceOff"

  • "ForceOn"

  • "ForceRestart"

  • "GracefulRestart"

  • "GracefulShutdown"

  • "Nmi"

  • "On"

  • "PowerCycle"

  • "PushPowerButton"

resource_id

string

This option is the unique identifier of the device being managed. For example, https://<I(baseuri>/redfish/v1/Systems/<resource_id>).

This option is mandatory for base_uri with multiple devices.

To get the device details, use the API https://<I(baseuri>/redfish/v1/Systems) for reset_type operation and https://<I(baseuri>/redfish/v1/Chassis) for oem_reset_type operation.

timeout

integer

added in dellemc.openmanage 5.0.0

The socket level timeout in seconds.

Default: 30

username

string

Username of the target out-of-band controller.

If the username is not provided, then the environment variable IDRAC_USERNAME is used.

Example: export IDRAC_USERNAME=username

validate_certs

boolean

added in dellemc.openmanage 5.0.0

If false, the SSL certificates will not be validated.

Configure false only on personally controlled sites where self-signed certificates are used.

Prior to collection version 5.0.0, the validate_certs is false by default.

Choices:

  • false

  • true ← (default)

x_auth_token

string

added in dellemc.openmanage 9.3.0

Authentication token.

If the x_auth_token is not provided, then the environment variable IDRAC_X_AUTH_TOKEN is used.

Example: export IDRAC_X_AUTH_TOKEN=x_auth_token

Notes

Note

  • Run this module from a system that has direct access to Redfish APIs.

  • This module supports check_mode.

Examples

---
- name: Manage power state of the first device
  dellemc.openmanage.redfish_powerstate:
    baseuri: "192.168.0.1"
    username: "username"
    password: "password"
    ca_path: "/path/to/ca_cert.pem"
    reset_type: "On"

- name: Manage power state of a specified device
  dellemc.openmanage.redfish_powerstate:
    baseuri: "192.168.0.1"
    username: "username"
    password: "password"
    ca_path: "/path/to/ca_cert.pem"
    reset_type: "ForceOff"
    resource_id: "System.Embedded.1"

- name: Perform AC Power Cycle with final power state On
  dellemc.openmanage.redfish_powerstate:
    baseuri: "192.168.0.1"
    username: "username"
    password: "password"
    ca_path: "/path/to/ca_cert.pem"
    oem_reset_type:
      dell:
        final_power_state: "On"
        reset_type: "PowerCycle"

- name: Perform AC Power Cycle  with final power state Off
  dellemc.openmanage.redfish_powerstate:
    baseuri: "192.168.0.1"
    username: "username"
    password: "password"
    ca_path: "/path/to/ca_cert.pem"
    oem_reset_type:
      dell:
        final_power_state: "Off"
        reset_type: "PowerCycle"

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

error_info

dictionary

Details of the HTTP error.

Returned: on http error

Sample: {"error": {"@Message.ExtendedInfo": [{"Message": "Unable to complete the operation because the resource /redfish/v1/Systems/System.Embedded.1/Actions/ComputerSystem.Reset entered in not found.", "MessageArgs": ["/redfish/v1/Systems/System.Embedded.1/Actions/ComputerSystem.Reset"], "MessageArgs@odata.count": 1, "MessageId": "IDRAC.2.1.SYS403", "RelatedProperties": [], "RelatedProperties@odata.count": 0, "Resolution": "Enter the correct resource and retry the operation. For information about valid resource, see the Redfish Users Guide available on the support site.", "Severity": "Critical"}], "code": "Base.1.5.GeneralError", "message": "A general error has occurred. See ExtendedInfo for more information"}}

msg

string

Overall status of the reset operation.

Returned: always

Sample: "Successfully performed the reset type operation 'On'."

Authors

  • Sajna Shetty(@Sajna-Shetty)

  • Lovepreet Singh (@singh-lovepreet1)