-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathredfish_command.py
1165 lines (1073 loc) · 37.8 KB
/
redfish_command.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright (c) 2017-2018 Dell EMC Inc.
# 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
from __future__ import absolute_import, division, print_function
__metaclass__ = type
DOCUMENTATION = r"""
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.
extends_documentation_fragment:
- community.general.attributes
attributes:
check_mode:
support: none
diff_mode:
support: none
options:
category:
required: true
description:
- Category to execute on OOB controller.
type: str
command:
required: true
description:
- List of commands to execute on OOB controller.
type: list
elements: str
baseuri:
required: true
description:
- Base URI of OOB controller.
type: str
username:
description:
- Username for authenticating to OOB controller.
type: str
password:
description:
- Password for authenticating to OOB controller.
type: str
auth_token:
description:
- Security token for authenticating to OOB controller.
type: str
version_added: 2.3.0
session_uri:
description:
- URI of the session resource.
type: str
version_added: 2.3.0
id:
required: false
aliases: [account_id]
description:
- 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.
type: str
new_username:
required: false
aliases: [account_username]
description:
- Username of account to add/delete/modify.
type: str
new_password:
required: false
aliases: [account_password]
description:
- New password of account to add/modify.
type: str
roleid:
required: false
aliases: [account_roleid]
description:
- Role of account to add/modify.
type: str
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'
bootdevice:
required: false
description:
- Boot device when setting boot configuration.
type: str
timeout:
description:
- Timeout in seconds for HTTP requests to OOB controller.
- The default value for this parameter changed from V(10) to V(60) in community.general 9.0.0.
type: int
default: 60
boot_override_mode:
description:
- Boot mode when using an override.
type: str
choices: [Legacy, UEFI]
version_added: 3.5.0
uefi_target:
required: false
description:
- UEFI boot target when bootdevice is "UefiTarget".
type: str
boot_next:
required: false
description:
- BootNext target when bootdevice is "UefiBootNext".
type: str
update_username:
required: false
aliases: [account_updatename]
description:
- New user name for updating account_username.
type: str
version_added: '0.2.0'
account_properties:
required: false
description:
- Properties of account service to update.
type: dict
default: {}
version_added: '0.2.0'
resource_id:
required: false
description:
- ID of the System, Manager or Chassis to modify.
type: str
version_added: '0.2.0'
update_image_uri:
required: false
description:
- URI of the image for the update.
type: str
version_added: '0.2.0'
update_image_file:
required: false
description:
- Filename, with optional path, of the image for the update.
type: path
version_added: '7.1.0'
update_protocol:
required: false
description:
- Protocol for the update.
type: str
version_added: '0.2.0'
update_targets:
required: false
description:
- List of target resource URIs to apply the update to.
type: list
elements: str
default: []
version_added: '0.2.0'
update_creds:
required: false
description:
- Credentials for retrieving the update image.
type: dict
version_added: '0.2.0'
suboptions:
username:
required: false
description:
- Username for retrieving the update image.
type: str
password:
required: false
description:
- Password for retrieving the update image.
type: str
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'
update_oem_params:
required: false
description:
- Properties for HTTP Multipart Push Updates.
type: dict
version_added: '7.5.0'
update_handle:
required: false
description:
- Handle to check the status of an update in progress.
type: str
version_added: '6.1.0'
update_custom_oem_header:
required: false
description:
- Optional OEM header, sent as separate form-data for the Multipart HTTP push update.
- The header shall start with "Oem" according to DMTF Redfish spec 12.6.2.2.
- For more details, see U(https://www.dmtf.org/sites/default/files/standards/documents/DSP0266_1.21.0.html).
- If set, then O(update_custom_oem_params) is required too.
type: str
version_added: '10.1.0'
update_custom_oem_params:
required: false
description:
- Custom OEM properties for HTTP Multipart Push updates.
- If set, then O(update_custom_oem_header) is required too.
- The properties will be passed raw without any validation or conversion by Ansible. This means the content can be a
file, a string, or any other data. If the content is a dict that should be converted to JSON, then the content must
be converted to JSON before passing it to this module using the P(ansible.builtin.to_json#filter) filter.
type: raw
version_added: '10.1.0'
update_custom_oem_mime_type:
required: false
description:
- MIME Type for custom OEM properties for HTTP Multipart Push updates.
type: str
version_added: '10.1.0'
virtual_media:
required: false
description:
- Options for VirtualMedia commands.
type: dict
version_added: '0.2.0'
suboptions:
media_types:
required: false
description:
- List of media types appropriate for the image.
type: list
elements: str
default: []
image_url:
required: false
description:
- URL of the image to insert or eject.
type: str
inserted:
required: false
description:
- Indicates that the image is treated as inserted on command completion.
type: bool
default: true
write_protected:
required: false
description:
- Indicates that the media is treated as write-protected.
type: bool
default: true
username:
required: false
description:
- Username for accessing the image URL.
type: str
password:
required: false
description:
- Password for accessing the image URL.
type: str
transfer_protocol_type:
required: false
description:
- Network protocol to use with the image.
type: str
transfer_method:
required: false
description:
- Transfer method to use with the image.
type: str
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
bios_attributes:
required: false
description:
- BIOS attributes that needs to be verified in the given server.
type: dict
version_added: 6.4.0
reset_to_defaults_mode:
description:
- Mode to apply when reseting to default.
type: str
choices: [ResetAll, PreserveNetworkAndUsers, PreserveNetwork]
version_added: 8.6.0
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
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
author:
- "Jose Delarosa (@jose-delarosa)"
- "T S Kushal (@TSKushal)"
"""
EXAMPLES = r"""
- name: Restart system power gracefully
community.general.redfish_command:
category: Systems
command: PowerGracefulRestart
resource_id: 437XR1138R2
baseuri: "{{ baseuri }}"
username: "{{ username }}"
password: "{{ password }}"
- 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
- name: Set one-time boot device to {{ bootdevice }}
community.general.redfish_command:
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"
community.general.redfish_command:
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"
community.general.redfish_command:
category: Systems
command: SetOneTimeBoot
resource_id: 437XR1138R2
bootdevice: "UefiBootNext"
boot_next: "Boot0001"
baseuri: "{{ baseuri }}"
username: "{{ username }}"
password: "{{ password }}"
- 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 }}"
- name: Set one-time boot to BiosSetup
community.general.redfish_command:
category: Systems
command: SetOneTimeBoot
boot_next: BiosSetup
boot_override_mode: Legacy
baseuri: "{{ baseuri }}"
username: "{{ username }}"
password: "{{ password }}"
- name: Disable persistent boot device override
community.general.redfish_command:
category: Systems
command: DisableBootOverride
- 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 }}"
- name: Add user
community.general.redfish_command:
category: Accounts
command: AddUser
baseuri: "{{ baseuri }}"
username: "{{ username }}"
password: "{{ password }}"
new_username: "{{ new_username }}"
new_password: "{{ new_password }}"
roleid: "{{ roleid }}"
- 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
- name: Add user using new option aliases
community.general.redfish_command:
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
community.general.redfish_command:
category: Accounts
command: DeleteUser
baseuri: "{{ baseuri }}"
username: "{{ username }}"
password: "{{ password }}"
account_username: "{{ account_username }}"
- name: Disable user
community.general.redfish_command:
category: Accounts
command: DisableUser
baseuri: "{{ baseuri }}"
username: "{{ username }}"
password: "{{ password }}"
account_username: "{{ account_username }}"
- name: Enable user
community.general.redfish_command:
category: Accounts
command: EnableUser
baseuri: "{{ baseuri }}"
username: "{{ username }}"
password: "{{ password }}"
account_username: "{{ account_username }}"
- name: Add and enable user
community.general.redfish_command:
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
community.general.redfish_command:
category: Accounts
command: UpdateUserPassword
baseuri: "{{ baseuri }}"
username: "{{ username }}"
password: "{{ password }}"
account_username: "{{ account_username }}"
account_password: "{{ account_password }}"
- name: Update user role
community.general.redfish_command:
category: Accounts
command: UpdateUserRole
baseuri: "{{ baseuri }}"
username: "{{ username }}"
password: "{{ password }}"
account_username: "{{ account_username }}"
roleid: "{{ roleid }}"
- name: Update user name
community.general.redfish_command:
category: Accounts
command: UpdateUserName
baseuri: "{{ baseuri }}"
username: "{{ username }}"
password: "{{ password }}"
account_username: "{{ account_username }}"
account_updatename: "{{ account_updatename }}"
- name: Update user name
community.general.redfish_command:
category: Accounts
command: UpdateUserName
baseuri: "{{ baseuri }}"
username: "{{ username }}"
password: "{{ password }}"
account_username: "{{ account_username }}"
update_username: "{{ update_username }}"
- name: Update AccountService properties
community.general.redfish_command:
category: Accounts
command: UpdateAccountServiceProperties
baseuri: "{{ baseuri }}"
username: "{{ username }}"
password: "{{ password }}"
account_properties:
AccountLockoutThreshold: 5
AccountLockoutDuration: 600
- name: Update user AccountTypes
community.general.redfish_command:
category: Accounts
command: UpdateUserAccountTypes
baseuri: "{{ baseuri }}"
username: "{{ username }}"
password: "{{ password }}"
account_username: "{{ account_username }}"
account_types:
- Redfish
- WebUI
- name: Clear Manager Logs with a timeout of 20 seconds
community.general.redfish_command:
category: Manager
command: ClearLogs
resource_id: BMC
baseuri: "{{ baseuri }}"
username: "{{ username }}"
password: "{{ password }}"
timeout: 20
- 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 }}"
- name: Clear Sessions
community.general.redfish_command:
category: Sessions
command: ClearSessions
baseuri: "{{ baseuri }}"
username: "{{ username }}"
password: "{{ password }}"
- name: Simple update
community.general.redfish_command:
category: Update
command: SimpleUpdate
baseuri: "{{ baseuri }}"
username: "{{ username }}"
password: "{{ password }}"
update_image_uri: https://example.com/myupdate.img
- name: Simple update with additional options
community.general.redfish_command:
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
- 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
update_oem_params:
PreserveConfiguration: false
- name: Multipart HTTP push with custom OEM options
vars:
oem_payload:
ImageType: BMC
community.general.redfish_command:
category: Update
command: MultipartHTTPPushUpdate
baseuri: "{{ baseuri }}"
username: "{{ username }}"
password: "{{ password }}"
update_image_file: ~/images/myupdate.img
update_targets:
- /redfish/v1/UpdateService/FirmwareInventory/BMC
update_custom_oem_header: OemParameters
update_custom_oem_mime_type: "application/json"
update_custom_oem_params: "{{ oem_payload | to_json }}"
- 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
- 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
- name: Insert Virtual Media
community.general.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: BMC
- 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
- name: Eject Virtual Media
community.general.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: BMC
- name: Restart manager power gracefully
community.general.redfish_command:
category: Manager
command: GracefulRestart
resource_id: BMC
baseuri: "{{ baseuri }}"
username: "{{ username }}"
password: "{{ password }}"
- 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
- 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
- name: Factory reset manager to defaults
community.general.redfish_command:
category: Manager
command: ResetToDefaults
resource_id: BMC
reset_to_defaults_mode: ResetAll
- 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"
"""
RETURN = r"""
msg:
description: Message with action result or error description.
returned: always
type: str
sample: "Action was successful"
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"
}
}
"""
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.community.general.plugins.module_utils.redfish_utils import RedfishUtils
from ansible.module_utils.common.text.converters import to_native
# More will be added as module features are expanded
CATEGORY_COMMANDS_ALL = {
"Systems": ["PowerOn", "PowerForceOff", "PowerForceRestart", "PowerGracefulRestart",
"PowerGracefulShutdown", "PowerReboot", "PowerCycle", "SetOneTimeBoot", "EnableContinuousBootOverride", "DisableBootOverride",
"IndicatorLedOn", "IndicatorLedOff", "IndicatorLedBlink", "VirtualMediaInsert", "VirtualMediaEject", "VerifyBiosAttributes"],
"Chassis": ["IndicatorLedOn", "IndicatorLedOff", "IndicatorLedBlink"],
"Accounts": ["AddUser", "EnableUser", "DeleteUser", "DisableUser",
"UpdateUserRole", "UpdateUserPassword", "UpdateUserName",
"UpdateUserAccountTypes", "UpdateAccountServiceProperties"],
"Sessions": ["ClearSessions", "CreateSession", "DeleteSession"],
"Manager": ["GracefulRestart", "ClearLogs", "VirtualMediaInsert",
"ResetToDefaults",
"VirtualMediaEject", "PowerOn", "PowerForceOff", "PowerForceRestart",
"PowerGracefulRestart", "PowerGracefulShutdown", "PowerReboot"],
"Update": ["SimpleUpdate", "MultipartHTTPPushUpdate", "PerformRequestedOperations"],
}
def main():
result = {}
return_values = {}
module = AnsibleModule(
argument_spec=dict(
category=dict(required=True),
command=dict(required=True, type='list', elements='str'),
baseuri=dict(required=True),
username=dict(),
password=dict(no_log=True),
auth_token=dict(no_log=True),
session_uri=dict(),
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"]),
account_types=dict(type='list', elements='str', aliases=["account_accounttypes"]),
oem_account_types=dict(type='list', elements='str', aliases=["account_oemaccounttypes"]),
update_username=dict(type='str', aliases=["account_updatename"]),
account_properties=dict(type='dict', default={}),
bootdevice=dict(),
timeout=dict(type='int', default=60),
uefi_target=dict(),
boot_next=dict(),
boot_override_mode=dict(choices=['Legacy', 'UEFI']),
resource_id=dict(),
update_image_uri=dict(),
update_image_file=dict(type='path'),
update_protocol=dict(),
update_targets=dict(type='list', elements='str', default=[]),
update_oem_params=dict(type='dict'),
update_custom_oem_header=dict(type='str'),
update_custom_oem_mime_type=dict(type='str'),
update_custom_oem_params=dict(type='raw'),
update_creds=dict(
type='dict',
options=dict(
username=dict(),
password=dict(no_log=True)
)
),
update_apply_time=dict(choices=['Immediate', 'OnReset', 'AtMaintenanceWindowStart',
'InMaintenanceWindowOnReset', 'OnStartUpdateRequest']),
update_handle=dict(),
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(),
)
),
strip_etag_quotes=dict(type='bool', default=False),
reset_to_defaults_mode=dict(choices=['ResetAll', 'PreserveNetworkAndUsers', 'PreserveNetwork']),
bios_attributes=dict(type="dict"),
wait=dict(type='bool', default=False),
wait_timeout=dict(type='int', default=120),
ciphers=dict(type='list', elements='str'),
),
required_together=[
('username', 'password'),
('update_custom_oem_header', 'update_custom_oem_params'),
],
required_one_of=[
('username', 'auth_token'),
],
mutually_exclusive=[
('username', 'auth_token'),
],
supports_check_mode=False
)
category = module.params['category']
command_list = module.params['command']
# admin credentials used for authentication
creds = {'user': module.params['username'],
'pswd': module.params['password'],
'token': module.params['auth_token']}
# user to add/modify/delete
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'],
'account_passwordchangerequired': None,
}
# 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'],
'update_image_file': module.params['update_image_file'],
'update_protocol': module.params['update_protocol'],
'update_targets': module.params['update_targets'],
'update_creds': module.params['update_creds'],
'update_apply_time': module.params['update_apply_time'],
'update_oem_params': module.params['update_oem_params'],
'update_custom_oem_header': module.params['update_custom_oem_header'],
'update_custom_oem_params': module.params['update_custom_oem_params'],
'update_custom_oem_mime_type': module.params['update_custom_oem_mime_type'],
'update_handle': module.params['update_handle'],
}
# Boot override options
boot_opts = {
'bootdevice': module.params['bootdevice'],
'uefi_target': module.params['uefi_target'],
'boot_next': module.params['boot_next'],
'boot_override_mode': module.params['boot_override_mode'],
}
# VirtualMedia options
virtual_media = module.params['virtual_media']