dellemc.openmanage.idrac_session module – Manage iDRAC sessions

Note

This module is part of the dellemc.openmanage collection (version 11.0.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.idrac_session.

New in dellemc.openmanage 9.2.0

Synopsis

  • This module allows the creation and deletion of sessions on iDRAC.

Requirements

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

  • python >= 3.9.6

Parameters

Parameter

Comments

ca_path

path

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

cert_fingerprint

string

SHA-256 fingerprint of the expected TLS certificate (hex digest, with or without colons).

When supplied together with validate_certs=false, the module verifies the remote certificate’s fingerprint instead of performing full CA validation.

enforce_no_log

boolean

If true, the module will fail with an error when state is present and the task was not invoked with no_log=true. This prevents accidental token exposure in job logs.

Choices:

  • false ← (default)

  • true

enforce_validate_certs

boolean

If true and validate_certs is false, the module will fail with an error instead of just emitting a warning.

Choices:

  • false ← (default)

  • true

hostname

aliases: idrac_ip

string

IP address or hostname of the iDRAC.

password

aliases: idrac_password

string

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

password is required when state is present.

port

integer

Port of the iDRAC.

Default: 443

session_id

string

Session ID of the iDRAC.

session_id is required when state is absent.

state

string

The state of the session in an iDRAC.

present creates a session.

absent deletes a session.

Module will always report changes found to be applied when state is present.

Choices:

  • "present" ← (default)

  • "absent"

timeout

integer

The https socket level timeout in seconds.

Default: 30

username

aliases: idrac_user

string

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

username is required when state is present.

validate_certs

boolean

If false, the SSL certificates will not be validated.

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

Choices:

  • false

  • true ← (default)

x_auth_token

aliases: auth_token

string

Authentication token.

When state is absent, either x_auth_token or username/password must be provided.

When using x_auth_token, self-session protection is not available.

Notes

Note

  • Run this module from a system that has direct access to Dell iDRAC.

  • This module supports IPv4 and IPv6 addresses.

  • This module supports check_mode.

  • This module will always report changes found to be applied when state is present.

  • When state is absent, self-session termination protection is applied. If the target session_id is determined to be the caller’s own auth session, the deletion is rejected to prevent accidental lockout.

  • Self-session protection is skipped when using x_auth_token because the caller’s auth session ID cannot be determined from the token alone.

  • When state is absent with username/password, the module creates a temporary auth session to detect self-termination. This temporary session is cleaned up automatically.

  • Troubleshooting - If you receive “Max Sessions Reached”, use idrac_session_info to identify and clean up stale sessions.

  • The x_auth_token returned by this module is a credential that can authenticate subsequent API requests. Set no_log to true on tasks that create or delete a session, and do not print the registered result using ansible.builtin.debug, because job logs and runner artifacts may retain the token.

Examples

---
- name: Create a session
  dellemc.openmanage.idrac_session:
    hostname: 198.162.0.1
    username: username
    password: password
    ca_path: "/path/to/ca_cert.pem"
    state: present
  no_log: true

- name: Delete a session
  dellemc.openmanage.idrac_session:
    hostname: 198.162.0.1
    ca_path: "/path/to/ca_cert.pem"
    state: absent
    x_auth_token: aed4aa802b748d2f3b31deec00a6b28a
    session_id: 2
  no_log: true

- name: Create a session and execute other modules
  block:
    - name: Create a session
      dellemc.openmanage.idrac_session:
        hostname: 198.162.0.1
        username: username
        password: password
        ca_path: "/path/to/ca_cert.pem"
        state: present
      register: authData
      no_log: true

    - name: Call idrac_firmware_info module
      dellemc.openmanage.idrac_firmware_info:
        idrac_ip: 198.162.0.1
        ca_path: "/path/to/ca_cert.pem"
        x_auth_token: "{{ authData.x_auth_token }}"

    - name: Call idrac_user_info module
      dellemc.openmanage.idrac_user_info:
        idrac_ip: 198.162.0.1
        ca_path: "/path/to/ca_cert.pem"
        x_auth_token: "{{ authData.x_auth_token }}"
  always:
    - name: Destroy a session
      dellemc.openmanage.idrac_session:
        hostname: 198.162.0.1
        ca_path: "/path/to/ca_cert.pem"
        state: absent
        x_auth_token: "{{ authData.x_auth_token }}"
        session_id: "{{ authData.session_data.Id }}"
      no_log: true

- name: Delete a session using username/password (with self-session protection)
  dellemc.openmanage.idrac_session:
    hostname: 198.162.0.1
    username: username
    password: password
    ca_path: "/path/to/ca_cert.pem"
    state: absent
    session_id: 74
  no_log: true

- name: Troubleshoot - Query sessions when "Max Sessions Reached" error occurs
  block:
    - name: Check current session utilization
      dellemc.openmanage.idrac_session_info:
        idrac_ip: 198.162.0.1
        idrac_user: username
        idrac_password: password
        ca_path: "/path/to/ca_cert.pem"
        stale_threshold_minutes: 480
      register: session_info

    - name: Display session utilization
      ansible.builtin.debug:
        msg: >-
          Sessions: {{ session_info.session_limits.active_sessions }}/{{ session_info.session_limits.max_sessions }}
          ({{ session_info.session_limits.utilization_percent }}%).
          Stale sessions: {{ session_info.sessions | selectattr('is_stale', 'equalto', true) | list | length }}

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 an invalid username and/or password is entered, and therefore authentication failed.", "MessageArgs": [], "MessageId": "IDRAC.2.9.SYS415", "RelatedProperties": [], "Resolution": "Enter valid user name and password and retry the operation.", "Severity": "Warning"}], "code": "Base.1.12.GeneralError", "message": "A general error has occurred. See ExtendedInfo for more information"}}

msg

string

Status of the session operation.

Returned: always

Sample: "The session has been created successfully."

session_data

dictionary

The session details.

Returned: For session creation operation

Sample: {"@Message.ExtendedInfo": [{"Message": "The resource has been created successfully.", "MessageArgs": [], "MessageId": "Base.1.12.Created", "RelatedProperties": [], "Resolution": "None.", "Severity": "OK"}, {"Message": "A new resource is successfully created.", "MessageArgs": [], "MessageId": "IDRAC.2.9.SYS414", "RelatedProperties": [], "Resolution": "No response action is required.", "Severity": "Informational"}], "ClientOriginIPAddress": "100.96.37.58", "CreatedTime": "2024-04-05T01:14:01-05:00", "Description": "User Session", "Id": "74", "Name": "User Session", "Password": null, "SessionType": "Redfish", "UserName": "root"}

x_auth_token

string

Authentication token.

This value is a credential. Protect it with no_log and do not print it in job output.

Returned: For session creation operation

Sample: "d15f17f01cd627c30173b1582642497d"

Authors

  • Rajshekar P(@rajshekarp87)

  • Kritika Bhateja (@Kritika-Bhateja-03)

  • Saksham Nautiyal (@Saksham-Nautiyal)