W3cubDocs

/Ansible

community.general.xcc_redfish_command – Manages Lenovo Out-Of-Band controllers using Redfish APIs

Note

This plugin is part of the community.general collection (version 3.8.1).

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 community.general.

To use it in a playbook, specify: community.general.xcc_redfish_command.

New in version 2.4.0: of community.general

Synopsis

  • Builds Redfish URIs locally and sends them to remote OOB controllers to perform an action or get information back or update a configuration attribute.
  • Manages virtual media.
  • Supports getting information back via GET method.
  • Supports updating a configuration attribute via PATCH method.
  • Supports performing an action via POST method.

Parameters

Parameter Choices/Defaults Comments
auth_token
string
Security token for authentication with OOB controller
baseuri
string / required
Base URI of OOB controller.
category
string / required
Category to execute on OOB controller.
command
list / elements=string / required
List of commands to execute on OOB controller.
password
string
Password for authentication with OOB controller.
request_body
dictionary
The request body to patch or post.
resource_id
string
The ID of the System, Manager or Chassis to modify.
resource_uri
string
The resource uri to get or patch or post.
timeout
integer
Default:
10
Timeout in seconds for URL requests to OOB controller.
username
string
Username for authentication with OOB controller.
virtual_media
dictionary
The options for VirtualMedia commands.
image_url
string
The URL of the image to insert or eject.
inserted
boolean
    Choices:
  • no
  • yes
Indicates if the image is treated as inserted on command completion.
media_types
list / elements=string
The list of media types appropriate for the image.
password
string
The password for accessing the image URL.
transfer_method
string
The transfer method to use with the image.
transfer_protocol_type
string
The network protocol to use with the image.
username
string
The username for accessing the image URL.
write_protected
boolean
    Choices:
  • no
  • yes
Indicates if the media is treated as write-protected.

Examples

- name: Insert Virtual Media
  community.general.xcc_redfish_command:
    category: Manager
    command: VirtualMediaInsert
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    virtual_media:
      image_url: "http://example.com/images/SomeLinux-current.iso"
      media_types:
        - CD
        - DVD
    resource_id: "1"

- name: Eject Virtual Media
  community.general.xcc_redfish_command:
    category: Manager
    command: VirtualMediaEject
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    virtual_media:
      image_url: "http://example.com/images/SomeLinux-current.iso"
    resource_id: "1"

- name: Eject all Virtual Media
  community.general.xcc_redfish_command:
    category: Manager
    command: VirtualMediaEject
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    resource_id: "1"

- name: Get ComputeSystem Oem property SystemStatus via GetResource command
  community.general.xcc_redfish_command:
    category: Raw
    command: GetResource
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    resource_uri: "/redfish/v1/Systems/1"
  register: result
- ansible.builtin.debug:
    msg: "{{ result.redfish_facts.data.Oem.Lenovo.SystemStatus }}"

- name: Get Oem DNS setting via GetResource command
  community.general.xcc_redfish_command:
    category: Raw
    command: GetResource
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    resource_uri: "/redfish/v1/Managers/1/NetworkProtocol/Oem/Lenovo/DNS"
  register: result

- name: Print fetched information
  ansible.builtin.debug:
    msg: "{{ result.redfish_facts.data }}"

- name: Get Lenovo FoD key collection resource via GetCollectionResource command
  community.general.xcc_redfish_command:
    category: Raw
    command: GetCollectionResource
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    resource_uri: "/redfish/v1/Managers/1/Oem/Lenovo/FoD/Keys"
  register: result

- name: Print fetched information
  ansible.builtin.debug:
    msg: "{{ result.redfish_facts.data_list }}"

- name: Update ComputeSystem property AssetTag via PatchResource command
  community.general.xcc_redfish_command:
    category: Raw
    command: PatchResource
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    resource_uri: "/redfish/v1/Systems/1"
    request_body:
      AssetTag: "new_asset_tag"

- name: Perform BootToBIOSSetup action via PostResource command
  community.general.xcc_redfish_command:
    category: Raw
    command: PostResource
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    resource_uri: "/redfish/v1/Systems/1/Actions/Oem/LenovoComputerSystem.BootToBIOSSetup"
    request_body: {}

- name: Perform SecureBoot.ResetKeys action via PostResource command
  community.general.xcc_redfish_command:
    category: Raw
    command: PostResource
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    resource_uri: "/redfish/v1/Systems/1/SecureBoot/Actions/SecureBoot.ResetKeys"
    request_body:
      ResetKeysType: DeleteAllKeys

- name: Create session
  community.general.redfish_command:
    category: Sessions
    command: CreateSession
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
  register: result

- name: Update Manager DateTimeLocalOffset property using security token for auth
  community.general.xcc_redfish_command:
    category: Raw
    command: PatchResource
    baseuri: "{{ baseuri }}"
    auth_token: "{{ result.session.token }}"
    resource_uri: "/redfish/v1/Managers/1"
    request_body:
      DateTimeLocalOffset: "+08:00"

- name: Delete session using security token created by CreateSesssion above
  community.general.redfish_command:
    category: Sessions
    command: DeleteSession
    baseuri: "{{ baseuri }}"
    auth_token: "{{ result.session.token }}"
    session_uri: "{{ result.session.uri }}"

Return Values

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

Key Returned Description
msg
string
when failure or action/update success
A message related to the performed action(s).

Sample:
Action was successful
redfish_facts
dictionary
when command == GetResource or command == GetCollectionResource
Resource content.

Sample:
{ "redfish_facts": { "data": { "@odata.etag": ""3179bf00d69f25a8b3c"", "@odata.id": "/redfish/v1/Managers/1/NetworkProtocol/Oem/Lenovo/DNS", "@odata.type": "#LenovoDNS.v1_0_0.LenovoDNS", "DDNS": [ { "DDNSEnable": true, "DomainName": "", "DomainNameSource": "DHCP" } ], "DNSEnable": true, "Description": "This resource is used to represent a DNS resource for a Redfish implementation.", "IPv4Address1": "10.103.62.178", "IPv4Address2": "0.0.0.0", "IPv4Address3": "0.0.0.0", "IPv6Address1": "::", "IPv6Address2": "::", "IPv6Address3": "::", "Id": "LenovoDNS", "PreferredAddresstype": "IPv4" }, "ret": true } }


Authors

  • Yuyan Pan (@panyy3)

© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/community/general/xcc_redfish_command_module.html