community.general.xcc_redfish_command (8.5.0) — module

Manages Lenovo Out-Of-Band controllers using Redfish APIs

| "added in version" 2.4.0 of community.general"

Authors: Yuyan Pan (@panyy3)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

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.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
  - 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"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
  - 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"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
  - name: Eject all Virtual Media
    community.general.xcc_redfish_command:
      category: Manager
      command: VirtualMediaEject
      baseuri: "{{ baseuri }}"
      username: "{{ username }}"
      password: "{{ password }}"
      resource_id: "1"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
  - 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
  - ansible.builtin.debug:
      msg: "{{ result.redfish_facts.data.Oem.Lenovo.SystemStatus }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
  - 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
  - name: Print fetched information
    ansible.builtin.debug:
      msg: "{{ result.redfish_facts.data }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
  - 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
  - name: Print fetched information
    ansible.builtin.debug:
      msg: "{{ result.redfish_facts.data_list }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
  - 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"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
  - 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: {}
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
  - 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
  - name: Create session
    community.general.redfish_command:
      category: Sessions
      command: CreateSession
      baseuri: "{{ baseuri }}"
      username: "{{ username }}"
      password: "{{ password }}"
    register: result
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
  - 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"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
  - 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 }}"

Inputs

    
baseuri:
    description:
    - Base URI of OOB controller.
    required: true
    type: str

command:
    description:
    - List of commands to execute on OOB controller.
    elements: str
    required: true
    type: list

timeout:
    default: 10
    description:
    - Timeout in seconds for URL requests to OOB controller.
    type: int

category:
    description:
    - Category to execute on OOB controller.
    required: true
    type: str

password:
    description:
    - Password for authentication with OOB controller.
    type: str

username:
    description:
    - Username for authentication with OOB controller.
    type: str

auth_token:
    description:
    - Security token for authentication with OOB controller
    type: str

resource_id:
    description:
    - The ID of the System, Manager or Chassis to modify.
    required: false
    type: str

request_body:
    description:
    - The request body to patch or post.
    required: false
    type: dict

resource_uri:
    description:
    - The resource uri to get or patch or post.
    required: false
    type: str

virtual_media:
    description:
    - The options for VirtualMedia commands.
    required: false
    suboptions:
      image_url:
        description:
        - The URL of the image to insert or eject.
        type: str
      inserted:
        default: true
        description:
        - Indicates if the image is treated as inserted on command completion.
        type: bool
      media_types:
        default: []
        description:
        - The list of media types appropriate for the image.
        elements: str
        type: list
      password:
        description:
        - The password for accessing the image URL.
        type: str
      transfer_method:
        description:
        - The transfer method to use with the image.
        type: str
      transfer_protocol_type:
        description:
        - The network protocol to use with the image.
        type: str
      username:
        description:
        - The username for accessing the image URL.
        type: str
      write_protected:
        default: true
        description:
        - Indicates if the media is treated as write-protected.
        type: bool
    type: dict

Outputs

msg:
  description: A message related to the performed action(s).
  returned: when failure or action/update success
  sample: Action was successful
  type: str
redfish_facts:
  description: Resource content.
  returned: when command == GetResource or command == GetCollectionResource
  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 } }'
  type: dict