2020-03-09 10:11:07 +01:00
|
|
|
#!/usr/bin/python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
# Copyright (c) 2017-2018 Dell EMC Inc.
|
2022-08-05 12:28:29 +02:00
|
|
|
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
from __future__ import absolute_import, division, print_function
|
|
|
|
__metaclass__ = type
|
|
|
|
|
|
|
|
DOCUMENTATION = '''
|
|
|
|
---
|
|
|
|
module: redfish_command
|
|
|
|
short_description: Manages Out-Of-Band controllers using Redfish APIs
|
|
|
|
description:
|
|
|
|
- Builds Redfish URIs locally and sends them to remote OOB controllers to
|
|
|
|
perform an action.
|
|
|
|
- Manages OOB controller ex. reboot, log management.
|
|
|
|
- Manages OOB controller users ex. add, remove, update.
|
|
|
|
- Manages system power ex. on, off, graceful and forced reboot.
|
2023-02-20 17:28:13 +01:00
|
|
|
extends_documentation_fragment:
|
|
|
|
- community.general.attributes
|
|
|
|
attributes:
|
|
|
|
check_mode:
|
|
|
|
support: none
|
|
|
|
diff_mode:
|
|
|
|
support: none
|
2020-03-09 10:11:07 +01:00
|
|
|
options:
|
|
|
|
category:
|
|
|
|
required: true
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- Category to execute on OOB controller.
|
2020-03-09 10:11:07 +01:00
|
|
|
type: str
|
|
|
|
command:
|
|
|
|
required: true
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- List of commands to execute on OOB controller.
|
2020-03-09 10:11:07 +01:00
|
|
|
type: list
|
2021-02-12 06:47:23 +01:00
|
|
|
elements: str
|
2020-03-09 10:11:07 +01:00
|
|
|
baseuri:
|
|
|
|
required: true
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- Base URI of OOB controller.
|
2020-03-09 10:11:07 +01:00
|
|
|
type: str
|
|
|
|
username:
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- Username for authenticating to OOB controller.
|
2020-03-09 10:11:07 +01:00
|
|
|
type: str
|
|
|
|
password:
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- Password for authenticating to OOB controller.
|
2020-03-09 10:11:07 +01:00
|
|
|
type: str
|
2021-03-19 21:14:33 +01:00
|
|
|
auth_token:
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- Security token for authenticating to OOB controller.
|
2021-03-19 21:14:33 +01:00
|
|
|
type: str
|
|
|
|
version_added: 2.3.0
|
|
|
|
session_uri:
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- URI of the session resource.
|
2021-03-19 21:14:33 +01:00
|
|
|
type: str
|
|
|
|
version_added: 2.3.0
|
2020-03-09 10:11:07 +01:00
|
|
|
id:
|
|
|
|
required: false
|
|
|
|
aliases: [ account_id ]
|
|
|
|
description:
|
2021-09-16 22:20:49 +02:00
|
|
|
- ID of account to delete/modify.
|
|
|
|
- Can also be used in account creation to work around vendor issues where the ID of the new user is required in the POST request.
|
2020-03-09 10:11:07 +01:00
|
|
|
type: str
|
|
|
|
new_username:
|
|
|
|
required: false
|
|
|
|
aliases: [ account_username ]
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- Username of account to add/delete/modify.
|
2020-03-09 10:11:07 +01:00
|
|
|
type: str
|
|
|
|
new_password:
|
|
|
|
required: false
|
|
|
|
aliases: [ account_password ]
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- New password of account to add/modify.
|
2020-03-09 10:11:07 +01:00
|
|
|
type: str
|
|
|
|
roleid:
|
|
|
|
required: false
|
|
|
|
aliases: [ account_roleid ]
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- Role of account to add/modify.
|
2020-03-09 10:11:07 +01:00
|
|
|
type: str
|
2023-07-12 19:48:29 +02:00
|
|
|
account_types:
|
|
|
|
required: false
|
|
|
|
aliases: [ account_accounttypes ]
|
|
|
|
description:
|
|
|
|
- Array of account types to apply to a user account.
|
|
|
|
type: list
|
|
|
|
elements: str
|
|
|
|
version_added: '7.2.0'
|
|
|
|
oem_account_types:
|
|
|
|
required: false
|
|
|
|
aliases: [ account_oemaccounttypes ]
|
|
|
|
description:
|
|
|
|
- Array of OEM account types to apply to a user account.
|
|
|
|
type: list
|
|
|
|
elements: str
|
|
|
|
version_added: '7.2.0'
|
2020-03-09 10:11:07 +01:00
|
|
|
bootdevice:
|
|
|
|
required: false
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- Boot device when setting boot configuration.
|
2020-03-09 10:11:07 +01:00
|
|
|
type: str
|
|
|
|
timeout:
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- Timeout in seconds for HTTP requests to OOB controller.
|
2024-04-22 18:28:22 +02:00
|
|
|
- The default value for this parameter changed from V(10) to V(60)
|
|
|
|
in community.general 9.0.0.
|
2020-03-09 10:11:07 +01:00
|
|
|
type: int
|
2024-04-22 18:28:22 +02:00
|
|
|
default: 60
|
2021-08-04 19:53:43 +02:00
|
|
|
boot_override_mode:
|
|
|
|
description:
|
|
|
|
- Boot mode when using an override.
|
|
|
|
type: str
|
|
|
|
choices: [ Legacy, UEFI ]
|
|
|
|
version_added: 3.5.0
|
2020-03-09 10:11:07 +01:00
|
|
|
uefi_target:
|
|
|
|
required: false
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- UEFI boot target when bootdevice is "UefiTarget".
|
2020-03-09 10:11:07 +01:00
|
|
|
type: str
|
|
|
|
boot_next:
|
|
|
|
required: false
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- BootNext target when bootdevice is "UefiBootNext".
|
2020-03-09 10:11:07 +01:00
|
|
|
type: str
|
|
|
|
update_username:
|
|
|
|
required: false
|
|
|
|
aliases: [ account_updatename ]
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- New user name for updating account_username.
|
2020-03-09 10:11:07 +01:00
|
|
|
type: str
|
2020-06-13 15:01:19 +02:00
|
|
|
version_added: '0.2.0'
|
2020-03-09 10:11:07 +01:00
|
|
|
account_properties:
|
|
|
|
required: false
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- Properties of account service to update.
|
2020-03-09 10:11:07 +01:00
|
|
|
type: dict
|
2022-11-01 19:25:51 +01:00
|
|
|
default: {}
|
2020-06-13 15:01:19 +02:00
|
|
|
version_added: '0.2.0'
|
2020-03-09 10:11:07 +01:00
|
|
|
resource_id:
|
|
|
|
required: false
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- ID of the System, Manager or Chassis to modify.
|
2020-03-09 10:11:07 +01:00
|
|
|
type: str
|
2020-06-13 15:01:19 +02:00
|
|
|
version_added: '0.2.0'
|
2020-03-09 10:11:07 +01:00
|
|
|
update_image_uri:
|
|
|
|
required: false
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- URI of the image for the update.
|
2020-03-09 10:11:07 +01:00
|
|
|
type: str
|
2020-06-13 15:01:19 +02:00
|
|
|
version_added: '0.2.0'
|
2023-06-05 21:56:44 +02:00
|
|
|
update_image_file:
|
|
|
|
required: false
|
|
|
|
description:
|
|
|
|
- Filename, with optional path, of the image for the update.
|
|
|
|
type: path
|
|
|
|
version_added: '7.1.0'
|
2020-03-09 10:11:07 +01:00
|
|
|
update_protocol:
|
|
|
|
required: false
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- Protocol for the update.
|
2020-03-09 10:11:07 +01:00
|
|
|
type: str
|
2020-06-13 15:01:19 +02:00
|
|
|
version_added: '0.2.0'
|
2020-03-09 10:11:07 +01:00
|
|
|
update_targets:
|
|
|
|
required: false
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- List of target resource URIs to apply the update to.
|
2020-03-09 10:11:07 +01:00
|
|
|
type: list
|
|
|
|
elements: str
|
2022-11-01 19:25:51 +01:00
|
|
|
default: []
|
2020-06-13 15:01:19 +02:00
|
|
|
version_added: '0.2.0'
|
2020-03-09 10:11:07 +01:00
|
|
|
update_creds:
|
|
|
|
required: false
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- Credentials for retrieving the update image.
|
2020-03-09 10:11:07 +01:00
|
|
|
type: dict
|
2020-06-13 15:01:19 +02:00
|
|
|
version_added: '0.2.0'
|
2020-03-09 10:11:07 +01:00
|
|
|
suboptions:
|
|
|
|
username:
|
|
|
|
required: false
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- Username for retrieving the update image.
|
2020-03-09 10:11:07 +01:00
|
|
|
type: str
|
|
|
|
password:
|
|
|
|
required: false
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- Password for retrieving the update image.
|
2020-03-09 10:11:07 +01:00
|
|
|
type: str
|
2022-11-23 07:46:39 +01:00
|
|
|
update_apply_time:
|
|
|
|
required: false
|
|
|
|
description:
|
|
|
|
- Time when to apply the update.
|
|
|
|
type: str
|
|
|
|
choices:
|
|
|
|
- Immediate
|
|
|
|
- OnReset
|
|
|
|
- AtMaintenanceWindowStart
|
|
|
|
- InMaintenanceWindowOnReset
|
|
|
|
- OnStartUpdateRequest
|
|
|
|
version_added: '6.1.0'
|
2023-10-02 21:46:29 +02:00
|
|
|
update_oem_params:
|
|
|
|
required: false
|
|
|
|
description:
|
|
|
|
- Properties for HTTP Multipart Push Updates.
|
|
|
|
type: dict
|
|
|
|
version_added: '7.5.0'
|
2022-11-23 07:46:39 +01:00
|
|
|
update_handle:
|
|
|
|
required: false
|
|
|
|
description:
|
|
|
|
- Handle to check the status of an update in progress.
|
|
|
|
type: str
|
|
|
|
version_added: '6.1.0'
|
2020-06-11 20:24:41 +02:00
|
|
|
virtual_media:
|
|
|
|
required: false
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- Options for VirtualMedia commands.
|
2020-06-11 20:24:41 +02:00
|
|
|
type: dict
|
2020-06-13 15:01:19 +02:00
|
|
|
version_added: '0.2.0'
|
2020-06-11 20:24:41 +02:00
|
|
|
suboptions:
|
|
|
|
media_types:
|
|
|
|
required: false
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- List of media types appropriate for the image.
|
2020-06-11 20:24:41 +02:00
|
|
|
type: list
|
|
|
|
elements: str
|
2022-11-01 19:25:51 +01:00
|
|
|
default: []
|
2020-06-11 20:24:41 +02:00
|
|
|
image_url:
|
|
|
|
required: false
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- URL of the image to insert or eject.
|
2020-06-11 20:24:41 +02:00
|
|
|
type: str
|
|
|
|
inserted:
|
|
|
|
required: false
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- Indicates that the image is treated as inserted on command completion.
|
2020-06-11 20:24:41 +02:00
|
|
|
type: bool
|
2022-09-06 20:42:17 +02:00
|
|
|
default: true
|
2020-06-11 20:24:41 +02:00
|
|
|
write_protected:
|
|
|
|
required: false
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- Indicates that the media is treated as write-protected.
|
2020-06-11 20:24:41 +02:00
|
|
|
type: bool
|
2022-09-06 20:42:17 +02:00
|
|
|
default: true
|
2020-06-11 20:24:41 +02:00
|
|
|
username:
|
|
|
|
required: false
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- Username for accessing the image URL.
|
2020-06-11 20:24:41 +02:00
|
|
|
type: str
|
|
|
|
password:
|
|
|
|
required: false
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- Password for accessing the image URL.
|
2020-06-11 20:24:41 +02:00
|
|
|
type: str
|
|
|
|
transfer_protocol_type:
|
|
|
|
required: false
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- Network protocol to use with the image.
|
2020-06-11 20:24:41 +02:00
|
|
|
type: str
|
|
|
|
transfer_method:
|
|
|
|
required: false
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- Transfer method to use with the image.
|
2020-06-11 20:24:41 +02:00
|
|
|
type: str
|
2021-09-01 22:59:27 +02:00
|
|
|
strip_etag_quotes:
|
|
|
|
description:
|
|
|
|
- Removes surrounding quotes of etag used in C(If-Match) header
|
|
|
|
of C(PATCH) requests.
|
|
|
|
- Only use this option to resolve bad vendor implementation where
|
|
|
|
C(If-Match) only matches the unquoted etag string.
|
|
|
|
type: bool
|
|
|
|
default: false
|
|
|
|
version_added: 3.7.0
|
2023-02-17 07:49:54 +01:00
|
|
|
bios_attributes:
|
|
|
|
required: false
|
|
|
|
description:
|
|
|
|
- BIOS attributes that needs to be verified in the given server.
|
|
|
|
type: dict
|
|
|
|
version_added: 6.4.0
|
2024-04-03 13:47:00 +02:00
|
|
|
reset_to_defaults_mode:
|
|
|
|
description:
|
|
|
|
- Mode to apply when reseting to default.
|
|
|
|
type: str
|
|
|
|
choices: [ ResetAll, PreserveNetworkAndUsers, PreserveNetwork ]
|
|
|
|
version_added: 8.6.0
|
2024-06-03 06:49:40 +02:00
|
|
|
wait:
|
|
|
|
required: false
|
|
|
|
description:
|
|
|
|
- Block until the service is ready again.
|
|
|
|
type: bool
|
|
|
|
default: false
|
|
|
|
version_added: 9.1.0
|
|
|
|
wait_timeout:
|
|
|
|
required: false
|
|
|
|
description:
|
|
|
|
- How long to block until the service is ready again before giving up.
|
|
|
|
type: int
|
|
|
|
default: 120
|
|
|
|
version_added: 9.1.0
|
2024-06-20 21:03:28 +02:00
|
|
|
ciphers:
|
|
|
|
required: false
|
|
|
|
description:
|
|
|
|
- SSL/TLS Ciphers to use for the request.
|
|
|
|
- 'When a list is provided, all ciphers are joined in order with V(:).'
|
|
|
|
- See the L(OpenSSL Cipher List Format,https://www.openssl.org/docs/manmaster/man1/openssl-ciphers.html#CIPHER-LIST-FORMAT)
|
|
|
|
for more details.
|
|
|
|
- The available ciphers is dependent on the Python and OpenSSL/LibreSSL versions.
|
|
|
|
type: list
|
|
|
|
elements: str
|
|
|
|
version_added: 9.2.0
|
2020-03-09 10:11:07 +01:00
|
|
|
|
2023-02-17 07:49:54 +01:00
|
|
|
author:
|
|
|
|
- "Jose Delarosa (@jose-delarosa)"
|
|
|
|
- "T S Kushal (@TSKushal)"
|
2020-03-09 10:11:07 +01:00
|
|
|
'''
|
|
|
|
|
|
|
|
EXAMPLES = '''
|
|
|
|
- name: Restart system power gracefully
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_command:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Systems
|
|
|
|
command: PowerGracefulRestart
|
|
|
|
resource_id: 437XR1138R2
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
|
2020-09-23 08:42:56 +02:00
|
|
|
- name: Turn system power off
|
|
|
|
community.general.redfish_command:
|
|
|
|
category: Systems
|
|
|
|
command: PowerForceOff
|
|
|
|
resource_id: 437XR1138R2
|
|
|
|
|
|
|
|
- name: Restart system power forcefully
|
|
|
|
community.general.redfish_command:
|
|
|
|
category: Systems
|
|
|
|
command: PowerForceRestart
|
|
|
|
resource_id: 437XR1138R2
|
|
|
|
|
|
|
|
- name: Shutdown system power gracefully
|
|
|
|
community.general.redfish_command:
|
|
|
|
category: Systems
|
|
|
|
command: PowerGracefulShutdown
|
|
|
|
resource_id: 437XR1138R2
|
|
|
|
|
|
|
|
- name: Turn system power on
|
|
|
|
community.general.redfish_command:
|
|
|
|
category: Systems
|
|
|
|
command: PowerOn
|
|
|
|
resource_id: 437XR1138R2
|
|
|
|
|
|
|
|
- name: Reboot system power
|
|
|
|
community.general.redfish_command:
|
|
|
|
category: Systems
|
|
|
|
command: PowerReboot
|
|
|
|
resource_id: 437XR1138R2
|
|
|
|
|
2020-03-09 10:11:07 +01:00
|
|
|
- name: Set one-time boot device to {{ bootdevice }}
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_command:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Systems
|
|
|
|
command: SetOneTimeBoot
|
|
|
|
resource_id: 437XR1138R2
|
|
|
|
bootdevice: "{{ bootdevice }}"
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
|
|
|
|
- name: Set one-time boot device to UefiTarget of "/0x31/0x33/0x01/0x01"
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_command:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Systems
|
|
|
|
command: SetOneTimeBoot
|
|
|
|
resource_id: 437XR1138R2
|
|
|
|
bootdevice: "UefiTarget"
|
|
|
|
uefi_target: "/0x31/0x33/0x01/0x01"
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
|
|
|
|
- name: Set one-time boot device to BootNext target of "Boot0001"
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_command:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Systems
|
|
|
|
command: SetOneTimeBoot
|
|
|
|
resource_id: 437XR1138R2
|
|
|
|
bootdevice: "UefiBootNext"
|
|
|
|
boot_next: "Boot0001"
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
|
2020-09-10 17:25:48 +02:00
|
|
|
- name: Set persistent boot device override
|
|
|
|
community.general.redfish_command:
|
|
|
|
category: Systems
|
|
|
|
command: EnableContinuousBootOverride
|
|
|
|
resource_id: 437XR1138R2
|
|
|
|
bootdevice: "{{ bootdevice }}"
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
|
2021-08-04 19:53:43 +02:00
|
|
|
- name: Set one-time boot to BiosSetup
|
|
|
|
community.general.redfish_command:
|
|
|
|
category: Systems
|
|
|
|
command: SetOneTimeBoot
|
2021-11-13 14:01:32 +01:00
|
|
|
boot_next: BiosSetup
|
2021-08-04 19:53:43 +02:00
|
|
|
boot_override_mode: Legacy
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
|
2020-09-10 17:25:48 +02:00
|
|
|
- name: Disable persistent boot device override
|
|
|
|
community.general.redfish_command:
|
|
|
|
category: Systems
|
|
|
|
command: DisableBootOverride
|
|
|
|
|
2022-04-11 20:10:18 +02:00
|
|
|
- name: Set system indicator LED to blink using security token for auth
|
|
|
|
community.general.redfish_command:
|
|
|
|
category: Systems
|
|
|
|
command: IndicatorLedBlink
|
|
|
|
resource_id: 437XR1138R2
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
auth_token: "{{ result.session.token }}"
|
|
|
|
|
2020-03-09 10:11:07 +01:00
|
|
|
- name: Add user
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_command:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Accounts
|
|
|
|
command: AddUser
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
new_username: "{{ new_username }}"
|
|
|
|
new_password: "{{ new_password }}"
|
|
|
|
roleid: "{{ roleid }}"
|
|
|
|
|
2023-07-12 19:48:29 +02:00
|
|
|
- name: Add user with specified account types
|
|
|
|
community.general.redfish_command:
|
|
|
|
category: Accounts
|
|
|
|
command: AddUser
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
new_username: "{{ new_username }}"
|
|
|
|
new_password: "{{ new_password }}"
|
|
|
|
roleid: "{{ roleid }}"
|
|
|
|
account_types:
|
|
|
|
- Redfish
|
|
|
|
- WebUI
|
|
|
|
|
2020-03-09 10:11:07 +01:00
|
|
|
- name: Add user using new option aliases
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_command:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Accounts
|
|
|
|
command: AddUser
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
account_username: "{{ account_username }}"
|
|
|
|
account_password: "{{ account_password }}"
|
|
|
|
account_roleid: "{{ account_roleid }}"
|
|
|
|
|
|
|
|
- name: Delete user
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_command:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Accounts
|
|
|
|
command: DeleteUser
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
account_username: "{{ account_username }}"
|
|
|
|
|
|
|
|
- name: Disable user
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_command:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Accounts
|
|
|
|
command: DisableUser
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
account_username: "{{ account_username }}"
|
|
|
|
|
|
|
|
- name: Enable user
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_command:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Accounts
|
|
|
|
command: EnableUser
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
account_username: "{{ account_username }}"
|
|
|
|
|
|
|
|
- name: Add and enable user
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_command:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Accounts
|
|
|
|
command: AddUser,EnableUser
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
new_username: "{{ new_username }}"
|
|
|
|
new_password: "{{ new_password }}"
|
|
|
|
roleid: "{{ roleid }}"
|
|
|
|
|
|
|
|
- name: Update user password
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_command:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Accounts
|
|
|
|
command: UpdateUserPassword
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
account_username: "{{ account_username }}"
|
|
|
|
account_password: "{{ account_password }}"
|
|
|
|
|
|
|
|
- name: Update user role
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_command:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Accounts
|
|
|
|
command: UpdateUserRole
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
account_username: "{{ account_username }}"
|
|
|
|
roleid: "{{ roleid }}"
|
|
|
|
|
|
|
|
- name: Update user name
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_command:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Accounts
|
|
|
|
command: UpdateUserName
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
account_username: "{{ account_username }}"
|
|
|
|
account_updatename: "{{ account_updatename }}"
|
|
|
|
|
|
|
|
- name: Update user name
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_command:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Accounts
|
|
|
|
command: UpdateUserName
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
account_username: "{{ account_username }}"
|
|
|
|
update_username: "{{ update_username }}"
|
|
|
|
|
|
|
|
- name: Update AccountService properties
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_command:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Accounts
|
|
|
|
command: UpdateAccountServiceProperties
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
account_properties:
|
|
|
|
AccountLockoutThreshold: 5
|
|
|
|
AccountLockoutDuration: 600
|
|
|
|
|
|
|
|
- name: Clear Manager Logs with a timeout of 20 seconds
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_command:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Manager
|
|
|
|
command: ClearLogs
|
|
|
|
resource_id: BMC
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
timeout: 20
|
|
|
|
|
2021-03-19 21:14:33 +01:00
|
|
|
- name: Create session
|
|
|
|
community.general.redfish_command:
|
|
|
|
category: Sessions
|
|
|
|
command: CreateSession
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- name: Set chassis indicator LED to blink using security token for auth
|
|
|
|
community.general.redfish_command:
|
|
|
|
category: Chassis
|
|
|
|
command: IndicatorLedBlink
|
|
|
|
resource_id: 1U
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
auth_token: "{{ result.session.token }}"
|
|
|
|
|
|
|
|
- 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 }}"
|
|
|
|
|
2020-03-09 10:11:07 +01:00
|
|
|
- name: Clear Sessions
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_command:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Sessions
|
|
|
|
command: ClearSessions
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
|
|
|
|
- name: Simple update
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_command:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Update
|
|
|
|
command: SimpleUpdate
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
update_image_uri: https://example.com/myupdate.img
|
|
|
|
|
|
|
|
- name: Simple update with additional options
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_command:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Update
|
|
|
|
command: SimpleUpdate
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
update_image_uri: //example.com/myupdate.img
|
|
|
|
update_protocol: FTP
|
|
|
|
update_targets:
|
|
|
|
- /redfish/v1/UpdateService/FirmwareInventory/BMC
|
|
|
|
update_creds:
|
|
|
|
username: operator
|
|
|
|
password: supersecretpwd
|
2020-06-11 20:24:41 +02:00
|
|
|
|
2023-06-05 21:56:44 +02:00
|
|
|
- name: Multipart HTTP push update; timeout is 600 seconds to allow for a
|
|
|
|
large image transfer
|
|
|
|
community.general.redfish_command:
|
|
|
|
category: Update
|
|
|
|
command: MultipartHTTPPushUpdate
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
timeout: 600
|
|
|
|
update_image_file: ~/images/myupdate.img
|
|
|
|
|
|
|
|
- name: Multipart HTTP push with additional options; timeout is 600 seconds
|
|
|
|
to allow for a large image transfer
|
|
|
|
community.general.redfish_command:
|
|
|
|
category: Update
|
|
|
|
command: MultipartHTTPPushUpdate
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
timeout: 600
|
|
|
|
update_image_file: ~/images/myupdate.img
|
|
|
|
update_targets:
|
|
|
|
- /redfish/v1/UpdateService/FirmwareInventory/BMC
|
2023-10-02 21:46:29 +02:00
|
|
|
update_oem_params:
|
|
|
|
PreserveConfiguration: false
|
2023-06-05 21:56:44 +02:00
|
|
|
|
2022-11-23 07:46:39 +01:00
|
|
|
- name: Perform requested operations to continue the update
|
|
|
|
community.general.redfish_command:
|
|
|
|
category: Update
|
|
|
|
command: PerformRequestedOperations
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
update_handle: /redfish/v1/TaskService/TaskMonitors/735
|
|
|
|
|
2022-08-24 21:36:35 +02:00
|
|
|
- name: Insert Virtual Media
|
|
|
|
community.general.redfish_command:
|
|
|
|
category: Systems
|
|
|
|
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
|
|
|
|
|
2020-06-11 20:24:41 +02:00
|
|
|
- name: Insert Virtual Media
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_command:
|
2020-06-11 20:24:41 +02:00
|
|
|
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: BMC
|
|
|
|
|
2022-08-24 21:36:35 +02:00
|
|
|
- name: Eject Virtual Media
|
|
|
|
community.general.redfish_command:
|
|
|
|
category: Systems
|
|
|
|
command: VirtualMediaEject
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
virtual_media:
|
|
|
|
image_url: 'http://example.com/images/SomeLinux-current.iso'
|
|
|
|
resource_id: 1
|
|
|
|
|
2020-06-11 20:24:41 +02:00
|
|
|
- name: Eject Virtual Media
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_command:
|
2020-06-11 20:24:41 +02:00
|
|
|
category: Manager
|
|
|
|
command: VirtualMediaEject
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
virtual_media:
|
|
|
|
image_url: 'http://example.com/images/SomeLinux-current.iso'
|
|
|
|
resource_id: BMC
|
2020-09-23 08:42:56 +02:00
|
|
|
|
|
|
|
- name: Restart manager power gracefully
|
|
|
|
community.general.redfish_command:
|
|
|
|
category: Manager
|
|
|
|
command: GracefulRestart
|
|
|
|
resource_id: BMC
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
|
2024-06-03 06:49:40 +02:00
|
|
|
- name: Restart manager power gracefully and wait for it to be available
|
|
|
|
community.general.redfish_command:
|
|
|
|
category: Manager
|
|
|
|
command: GracefulRestart
|
|
|
|
resource_id: BMC
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
wait: True
|
|
|
|
|
2020-09-23 08:42:56 +02:00
|
|
|
- name: Restart manager power gracefully
|
|
|
|
community.general.redfish_command:
|
|
|
|
category: Manager
|
|
|
|
command: PowerGracefulRestart
|
|
|
|
resource_id: BMC
|
|
|
|
|
|
|
|
- name: Turn manager power off
|
|
|
|
community.general.redfish_command:
|
|
|
|
category: Manager
|
|
|
|
command: PowerForceOff
|
|
|
|
resource_id: BMC
|
|
|
|
|
|
|
|
- name: Restart manager power forcefully
|
|
|
|
community.general.redfish_command:
|
|
|
|
category: Manager
|
|
|
|
command: PowerForceRestart
|
|
|
|
resource_id: BMC
|
|
|
|
|
|
|
|
- name: Shutdown manager power gracefully
|
|
|
|
community.general.redfish_command:
|
|
|
|
category: Manager
|
|
|
|
command: PowerGracefulShutdown
|
|
|
|
resource_id: BMC
|
|
|
|
|
|
|
|
- name: Turn manager power on
|
|
|
|
community.general.redfish_command:
|
|
|
|
category: Manager
|
|
|
|
command: PowerOn
|
|
|
|
resource_id: BMC
|
|
|
|
|
|
|
|
- name: Reboot manager power
|
|
|
|
community.general.redfish_command:
|
|
|
|
category: Manager
|
|
|
|
command: PowerReboot
|
|
|
|
resource_id: BMC
|
2023-02-17 07:49:54 +01:00
|
|
|
|
2024-04-03 13:47:00 +02:00
|
|
|
- name: Factory reset manager to defaults
|
|
|
|
community.general.redfish_command:
|
|
|
|
category: Manager
|
|
|
|
command: ResetToDefaults
|
|
|
|
resource_id: BMC
|
|
|
|
reset_to_defaults_mode: ResetAll
|
|
|
|
|
2023-02-17 07:49:54 +01:00
|
|
|
- name: Verify BIOS attributes
|
|
|
|
community.general.redfish_command:
|
|
|
|
category: Systems
|
|
|
|
command: VerifyBiosAttributes
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
bios_attributes:
|
|
|
|
SubNumaClustering: "Disabled"
|
|
|
|
WorkloadProfile: "Virtualization-MaxPerformance"
|
2020-03-09 10:11:07 +01:00
|
|
|
'''
|
|
|
|
|
|
|
|
RETURN = '''
|
|
|
|
msg:
|
|
|
|
description: Message with action result or error description
|
|
|
|
returned: always
|
|
|
|
type: str
|
|
|
|
sample: "Action was successful"
|
2022-11-23 07:46:39 +01:00
|
|
|
return_values:
|
|
|
|
description: Dictionary containing command-specific response data from the action.
|
|
|
|
returned: on success
|
|
|
|
type: dict
|
|
|
|
version_added: 6.1.0
|
|
|
|
sample: {
|
|
|
|
"update_status": {
|
|
|
|
"handle": "/redfish/v1/TaskService/TaskMonitors/735",
|
|
|
|
"messages": [],
|
|
|
|
"resets_requested": [],
|
|
|
|
"ret": true,
|
|
|
|
"status": "New"
|
|
|
|
}
|
|
|
|
}
|
2020-03-09 10:11:07 +01:00
|
|
|
'''
|
|
|
|
|
|
|
|
from ansible.module_utils.basic import AnsibleModule
|
|
|
|
from ansible_collections.community.general.plugins.module_utils.redfish_utils import RedfishUtils
|
2021-06-26 23:59:11 +02:00
|
|
|
from ansible.module_utils.common.text.converters import to_native
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
# More will be added as module features are expanded
|
|
|
|
CATEGORY_COMMANDS_ALL = {
|
|
|
|
"Systems": ["PowerOn", "PowerForceOff", "PowerForceRestart", "PowerGracefulRestart",
|
2023-08-14 21:59:24 +02:00
|
|
|
"PowerGracefulShutdown", "PowerReboot", "PowerCycle", "SetOneTimeBoot", "EnableContinuousBootOverride", "DisableBootOverride",
|
2023-02-17 07:49:54 +01:00
|
|
|
"IndicatorLedOn", "IndicatorLedOff", "IndicatorLedBlink", "VirtualMediaInsert", "VirtualMediaEject", "VerifyBiosAttributes"],
|
2020-03-09 10:11:07 +01:00
|
|
|
"Chassis": ["IndicatorLedOn", "IndicatorLedOff", "IndicatorLedBlink"],
|
|
|
|
"Accounts": ["AddUser", "EnableUser", "DeleteUser", "DisableUser",
|
|
|
|
"UpdateUserRole", "UpdateUserPassword", "UpdateUserName",
|
|
|
|
"UpdateAccountServiceProperties"],
|
2021-03-19 21:14:33 +01:00
|
|
|
"Sessions": ["ClearSessions", "CreateSession", "DeleteSession"],
|
2020-06-11 20:24:41 +02:00
|
|
|
"Manager": ["GracefulRestart", "ClearLogs", "VirtualMediaInsert",
|
2024-04-03 13:47:00 +02:00
|
|
|
"ResetToDefaults",
|
2020-09-23 08:42:56 +02:00
|
|
|
"VirtualMediaEject", "PowerOn", "PowerForceOff", "PowerForceRestart",
|
|
|
|
"PowerGracefulRestart", "PowerGracefulShutdown", "PowerReboot"],
|
2023-06-05 21:56:44 +02:00
|
|
|
"Update": ["SimpleUpdate", "MultipartHTTPPushUpdate", "PerformRequestedOperations"],
|
2020-03-09 10:11:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
result = {}
|
2022-11-23 07:46:39 +01:00
|
|
|
return_values = {}
|
2020-03-09 10:11:07 +01:00
|
|
|
module = AnsibleModule(
|
|
|
|
argument_spec=dict(
|
|
|
|
category=dict(required=True),
|
2021-02-12 06:47:23 +01:00
|
|
|
command=dict(required=True, type='list', elements='str'),
|
2020-03-09 10:11:07 +01:00
|
|
|
baseuri=dict(required=True),
|
2021-03-19 21:14:33 +01:00
|
|
|
username=dict(),
|
|
|
|
password=dict(no_log=True),
|
|
|
|
auth_token=dict(no_log=True),
|
|
|
|
session_uri=dict(),
|
2020-03-09 10:11:07 +01:00
|
|
|
id=dict(aliases=["account_id"]),
|
|
|
|
new_username=dict(aliases=["account_username"]),
|
|
|
|
new_password=dict(aliases=["account_password"], no_log=True),
|
|
|
|
roleid=dict(aliases=["account_roleid"]),
|
2023-07-12 19:48:29 +02:00
|
|
|
account_types=dict(type='list', elements='str', aliases=["account_accounttypes"]),
|
|
|
|
oem_account_types=dict(type='list', elements='str', aliases=["account_oemaccounttypes"]),
|
2020-03-09 10:11:07 +01:00
|
|
|
update_username=dict(type='str', aliases=["account_updatename"]),
|
|
|
|
account_properties=dict(type='dict', default={}),
|
|
|
|
bootdevice=dict(),
|
2024-04-22 18:28:22 +02:00
|
|
|
timeout=dict(type='int', default=60),
|
2020-03-09 10:11:07 +01:00
|
|
|
uefi_target=dict(),
|
|
|
|
boot_next=dict(),
|
2021-08-04 19:53:43 +02:00
|
|
|
boot_override_mode=dict(choices=['Legacy', 'UEFI']),
|
2020-03-09 10:11:07 +01:00
|
|
|
resource_id=dict(),
|
|
|
|
update_image_uri=dict(),
|
2023-06-05 21:56:44 +02:00
|
|
|
update_image_file=dict(type='path'),
|
2020-03-09 10:11:07 +01:00
|
|
|
update_protocol=dict(),
|
|
|
|
update_targets=dict(type='list', elements='str', default=[]),
|
2023-10-02 21:46:29 +02:00
|
|
|
update_oem_params=dict(type='dict'),
|
2020-03-09 10:11:07 +01:00
|
|
|
update_creds=dict(
|
|
|
|
type='dict',
|
|
|
|
options=dict(
|
|
|
|
username=dict(),
|
2021-02-08 16:33:18 +01:00
|
|
|
password=dict(no_log=True)
|
2020-03-09 10:11:07 +01:00
|
|
|
)
|
2020-06-11 20:24:41 +02:00
|
|
|
),
|
2022-11-23 07:46:39 +01:00
|
|
|
update_apply_time=dict(choices=['Immediate', 'OnReset', 'AtMaintenanceWindowStart',
|
|
|
|
'InMaintenanceWindowOnReset', 'OnStartUpdateRequest']),
|
|
|
|
update_handle=dict(),
|
2020-06-11 20:24:41 +02:00
|
|
|
virtual_media=dict(
|
|
|
|
type='dict',
|
|
|
|
options=dict(
|
|
|
|
media_types=dict(type='list', elements='str', default=[]),
|
|
|
|
image_url=dict(),
|
|
|
|
inserted=dict(type='bool', default=True),
|
|
|
|
write_protected=dict(type='bool', default=True),
|
|
|
|
username=dict(),
|
|
|
|
password=dict(no_log=True),
|
|
|
|
transfer_protocol_type=dict(),
|
|
|
|
transfer_method=dict(),
|
|
|
|
)
|
2021-09-01 22:59:27 +02:00
|
|
|
),
|
|
|
|
strip_etag_quotes=dict(type='bool', default=False),
|
2024-04-03 13:47:00 +02:00
|
|
|
reset_to_defaults_mode=dict(choices=['ResetAll', 'PreserveNetworkAndUsers', 'PreserveNetwork']),
|
2024-06-03 06:49:40 +02:00
|
|
|
bios_attributes=dict(type="dict"),
|
|
|
|
wait=dict(type='bool', default=False),
|
|
|
|
wait_timeout=dict(type='int', default=120),
|
2024-06-20 21:03:28 +02:00
|
|
|
ciphers=dict(type='list', elements='str'),
|
2020-03-09 10:11:07 +01:00
|
|
|
),
|
2021-03-19 21:14:33 +01:00
|
|
|
required_together=[
|
|
|
|
('username', 'password'),
|
|
|
|
],
|
|
|
|
required_one_of=[
|
|
|
|
('username', 'auth_token'),
|
|
|
|
],
|
|
|
|
mutually_exclusive=[
|
|
|
|
('username', 'auth_token'),
|
|
|
|
],
|
2020-03-09 10:11:07 +01:00
|
|
|
supports_check_mode=False
|
|
|
|
)
|
|
|
|
|
|
|
|
category = module.params['category']
|
|
|
|
command_list = module.params['command']
|
|
|
|
|
|
|
|
# admin credentials used for authentication
|
|
|
|
creds = {'user': module.params['username'],
|
2021-03-19 21:14:33 +01:00
|
|
|
'pswd': module.params['password'],
|
|
|
|
'token': module.params['auth_token']}
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
# user to add/modify/delete
|
2023-07-12 19:48:29 +02:00
|
|
|
user = {
|
|
|
|
'account_id': module.params['id'],
|
|
|
|
'account_username': module.params['new_username'],
|
|
|
|
'account_password': module.params['new_password'],
|
|
|
|
'account_roleid': module.params['roleid'],
|
|
|
|
'account_accounttypes': module.params['account_types'],
|
|
|
|
'account_oemaccounttypes': module.params['oem_account_types'],
|
|
|
|
'account_updatename': module.params['update_username'],
|
|
|
|
'account_properties': module.params['account_properties'],
|
|
|
|
}
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
# timeout
|
|
|
|
timeout = module.params['timeout']
|
|
|
|
|
|
|
|
# System, Manager or Chassis ID to modify
|
|
|
|
resource_id = module.params['resource_id']
|
|
|
|
|
|
|
|
# update options
|
|
|
|
update_opts = {
|
|
|
|
'update_image_uri': module.params['update_image_uri'],
|
2023-06-05 21:56:44 +02:00
|
|
|
'update_image_file': module.params['update_image_file'],
|
2020-03-09 10:11:07 +01:00
|
|
|
'update_protocol': module.params['update_protocol'],
|
|
|
|
'update_targets': module.params['update_targets'],
|
2022-11-23 07:46:39 +01:00
|
|
|
'update_creds': module.params['update_creds'],
|
|
|
|
'update_apply_time': module.params['update_apply_time'],
|
2023-10-02 21:46:29 +02:00
|
|
|
'update_oem_params': module.params['update_oem_params'],
|
2022-11-23 07:46:39 +01:00
|
|
|
'update_handle': module.params['update_handle'],
|
2020-03-09 10:11:07 +01:00
|
|
|
}
|
|
|
|
|
2020-09-10 17:25:48 +02:00
|
|
|
# Boot override options
|
|
|
|
boot_opts = {
|
|
|
|
'bootdevice': module.params['bootdevice'],
|
|
|
|
'uefi_target': module.params['uefi_target'],
|
2021-08-04 19:53:43 +02:00
|
|
|
'boot_next': module.params['boot_next'],
|
|
|
|
'boot_override_mode': module.params['boot_override_mode'],
|
2020-09-10 17:25:48 +02:00
|
|
|
}
|
|
|
|
|
2020-06-11 20:24:41 +02:00
|
|
|
# VirtualMedia options
|
|
|
|
virtual_media = module.params['virtual_media']
|
|
|
|
|
2021-09-01 22:59:27 +02:00
|
|
|
# Etag options
|
|
|
|
strip_etag_quotes = module.params['strip_etag_quotes']
|
|
|
|
|
2023-02-17 07:49:54 +01:00
|
|
|
# BIOS Attributes options
|
|
|
|
bios_attributes = module.params['bios_attributes']
|
|
|
|
|
2024-06-20 21:03:28 +02:00
|
|
|
# ciphers
|
|
|
|
ciphers = module.params['ciphers']
|
|
|
|
|
2020-03-09 10:11:07 +01:00
|
|
|
# Build root URI
|
|
|
|
root_uri = "https://" + module.params['baseuri']
|
|
|
|
rf_utils = RedfishUtils(creds, root_uri, timeout, module,
|
2024-06-20 21:03:28 +02:00
|
|
|
resource_id=resource_id, data_modification=True, strip_etag_quotes=strip_etag_quotes,
|
|
|
|
ciphers=ciphers)
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
# Check that Category is valid
|
|
|
|
if category not in CATEGORY_COMMANDS_ALL:
|
2021-02-23 23:19:27 +01:00
|
|
|
module.fail_json(msg=to_native("Invalid Category '%s'. Valid Categories = %s" % (category, list(CATEGORY_COMMANDS_ALL.keys()))))
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
# Check that all commands are valid
|
|
|
|
for cmd in command_list:
|
|
|
|
# Fail if even one command given is invalid
|
|
|
|
if cmd not in CATEGORY_COMMANDS_ALL[category]:
|
|
|
|
module.fail_json(msg=to_native("Invalid Command '%s'. Valid Commands = %s" % (cmd, CATEGORY_COMMANDS_ALL[category])))
|
|
|
|
|
|
|
|
# Organize by Categories / Commands
|
|
|
|
if category == "Accounts":
|
|
|
|
ACCOUNTS_COMMANDS = {
|
|
|
|
"AddUser": rf_utils.add_user,
|
|
|
|
"EnableUser": rf_utils.enable_user,
|
|
|
|
"DeleteUser": rf_utils.delete_user,
|
|
|
|
"DisableUser": rf_utils.disable_user,
|
|
|
|
"UpdateUserRole": rf_utils.update_user_role,
|
|
|
|
"UpdateUserPassword": rf_utils.update_user_password,
|
|
|
|
"UpdateUserName": rf_utils.update_user_name,
|
|
|
|
"UpdateAccountServiceProperties": rf_utils.update_accountservice_properties
|
|
|
|
}
|
|
|
|
|
|
|
|
# execute only if we find an Account service resource
|
|
|
|
result = rf_utils._find_accountservice_resource()
|
|
|
|
if result['ret'] is False:
|
|
|
|
module.fail_json(msg=to_native(result['msg']))
|
|
|
|
|
|
|
|
for command in command_list:
|
|
|
|
result = ACCOUNTS_COMMANDS[command](user)
|
|
|
|
|
|
|
|
elif category == "Systems":
|
|
|
|
# execute only if we find a System resource
|
|
|
|
result = rf_utils._find_systems_resource()
|
|
|
|
if result['ret'] is False:
|
|
|
|
module.fail_json(msg=to_native(result['msg']))
|
|
|
|
|
|
|
|
for command in command_list:
|
2020-09-23 08:42:56 +02:00
|
|
|
if command.startswith('Power'):
|
2020-03-09 10:11:07 +01:00
|
|
|
result = rf_utils.manage_system_power(command)
|
|
|
|
elif command == "SetOneTimeBoot":
|
2020-09-10 17:25:48 +02:00
|
|
|
boot_opts['override_enabled'] = 'Once'
|
|
|
|
result = rf_utils.set_boot_override(boot_opts)
|
|
|
|
elif command == "EnableContinuousBootOverride":
|
|
|
|
boot_opts['override_enabled'] = 'Continuous'
|
|
|
|
result = rf_utils.set_boot_override(boot_opts)
|
|
|
|
elif command == "DisableBootOverride":
|
|
|
|
boot_opts['override_enabled'] = 'Disabled'
|
|
|
|
result = rf_utils.set_boot_override(boot_opts)
|
2022-04-11 20:10:18 +02:00
|
|
|
elif command.startswith('IndicatorLed'):
|
|
|
|
result = rf_utils.manage_system_indicator_led(command)
|
2022-08-24 21:36:35 +02:00
|
|
|
elif command == 'VirtualMediaInsert':
|
|
|
|
result = rf_utils.virtual_media_insert(virtual_media, category)
|
|
|
|
elif command == 'VirtualMediaEject':
|
|
|
|
result = rf_utils.virtual_media_eject(virtual_media, category)
|
2023-02-17 07:49:54 +01:00
|
|
|
elif command == 'VerifyBiosAttributes':
|
|
|
|
result = rf_utils.verify_bios_attributes(bios_attributes)
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
elif category == "Chassis":
|
|
|
|
result = rf_utils._find_chassis_resource()
|
|
|
|
if result['ret'] is False:
|
|
|
|
module.fail_json(msg=to_native(result['msg']))
|
|
|
|
|
|
|
|
led_commands = ["IndicatorLedOn", "IndicatorLedOff", "IndicatorLedBlink"]
|
|
|
|
|
|
|
|
# Check if more than one led_command is present
|
|
|
|
num_led_commands = sum([command in led_commands for command in command_list])
|
|
|
|
if num_led_commands > 1:
|
|
|
|
result = {'ret': False, 'msg': "Only one IndicatorLed command should be sent at a time."}
|
|
|
|
else:
|
|
|
|
for command in command_list:
|
|
|
|
if command in led_commands:
|
2022-04-11 20:10:18 +02:00
|
|
|
result = rf_utils.manage_chassis_indicator_led(command)
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
elif category == "Sessions":
|
|
|
|
# execute only if we find SessionService resources
|
|
|
|
resource = rf_utils._find_sessionservice_resource()
|
|
|
|
if resource['ret'] is False:
|
|
|
|
module.fail_json(msg=resource['msg'])
|
|
|
|
|
|
|
|
for command in command_list:
|
|
|
|
if command == "ClearSessions":
|
|
|
|
result = rf_utils.clear_sessions()
|
2021-03-19 21:14:33 +01:00
|
|
|
elif command == "CreateSession":
|
|
|
|
result = rf_utils.create_session()
|
|
|
|
elif command == "DeleteSession":
|
|
|
|
result = rf_utils.delete_session(module.params['session_uri'])
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
elif category == "Manager":
|
|
|
|
# execute only if we find a Manager service resource
|
|
|
|
result = rf_utils._find_managers_resource()
|
|
|
|
if result['ret'] is False:
|
|
|
|
module.fail_json(msg=to_native(result['msg']))
|
|
|
|
|
|
|
|
for command in command_list:
|
2020-09-23 08:42:56 +02:00
|
|
|
# standardize on the Power* commands, but allow the the legacy
|
|
|
|
# GracefulRestart command
|
2020-06-11 20:24:41 +02:00
|
|
|
if command == 'GracefulRestart':
|
2020-09-23 08:42:56 +02:00
|
|
|
command = 'PowerGracefulRestart'
|
|
|
|
|
|
|
|
if command.startswith('Power'):
|
2024-06-03 06:49:40 +02:00
|
|
|
result = rf_utils.manage_manager_power(command, module.params['wait'], module.params['wait_timeout'])
|
2020-06-11 20:24:41 +02:00
|
|
|
elif command == 'ClearLogs':
|
|
|
|
result = rf_utils.clear_logs()
|
|
|
|
elif command == 'VirtualMediaInsert':
|
2022-08-24 21:36:35 +02:00
|
|
|
result = rf_utils.virtual_media_insert(virtual_media, category)
|
2020-06-11 20:24:41 +02:00
|
|
|
elif command == 'VirtualMediaEject':
|
2022-08-24 21:36:35 +02:00
|
|
|
result = rf_utils.virtual_media_eject(virtual_media, category)
|
2024-04-03 13:47:00 +02:00
|
|
|
elif command == 'ResetToDefaults':
|
|
|
|
result = rf_utils.manager_reset_to_defaults(module.params['reset_to_defaults_mode'])
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
elif category == "Update":
|
|
|
|
# execute only if we find UpdateService resources
|
|
|
|
resource = rf_utils._find_updateservice_resource()
|
|
|
|
if resource['ret'] is False:
|
|
|
|
module.fail_json(msg=resource['msg'])
|
|
|
|
|
|
|
|
for command in command_list:
|
|
|
|
if command == "SimpleUpdate":
|
|
|
|
result = rf_utils.simple_update(update_opts)
|
2022-11-23 07:46:39 +01:00
|
|
|
if 'update_status' in result:
|
|
|
|
return_values['update_status'] = result['update_status']
|
2023-06-05 21:56:44 +02:00
|
|
|
elif command == "MultipartHTTPPushUpdate":
|
|
|
|
result = rf_utils.multipath_http_push_update(update_opts)
|
|
|
|
if 'update_status' in result:
|
|
|
|
return_values['update_status'] = result['update_status']
|
2022-11-23 07:46:39 +01:00
|
|
|
elif command == "PerformRequestedOperations":
|
|
|
|
result = rf_utils.perform_requested_update_operations(update_opts['update_handle'])
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
# Return data back or fail with proper message
|
|
|
|
if result['ret'] is True:
|
|
|
|
del result['ret']
|
|
|
|
changed = result.get('changed', True)
|
2021-03-19 21:14:33 +01:00
|
|
|
session = result.get('session', dict())
|
|
|
|
module.exit_json(changed=changed, session=session,
|
2022-11-23 07:46:39 +01:00
|
|
|
msg='Action was successful',
|
|
|
|
return_values=return_values)
|
2020-03-09 10:11:07 +01:00
|
|
|
else:
|
|
|
|
module.fail_json(msg=to_native(result['msg']))
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|