-
Notifications
You must be signed in to change notification settings - Fork 1
/
idrac-boot-pxe-onetime-fx2-redfish.yml
executable file
·90 lines (80 loc) · 3.28 KB
/
idrac-boot-pxe-onetime-fx2-redfish.yml
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
---
- hosts: all
connection: local
name: Set One Time Boot to PXE
gather_facts: False
vars:
pxe_devices:
- NIC.Slot.1-1-1 # PCIe NIC
#- NIC.ChassisSlot.1-1-1 # FX2 PCIe NIC
#- NIC.ChassisSlot.3-1-1 # FX2 PCIe NIC
#- NIC.ChassisSlot.5-1-1 # FX2 PCIe NIC
#- NIC.ChassisSlot.7-1-1 # FX2 PCIe NIC
vars_files:
- vault.yml
tasks:
- name: Get BIOS Attributes
community.general.redfish_info:
baseuri: "{{ oob_host }}"
username: "{{ vault_oob_username }}"
password: "{{ vault_oob_password }}"
category: Systems
command: GetBiosAttributes
register: result_attributes
- name: Get BIOS boot mode and set fact boot_mode
set_fact:
boot_mode: "{{ result_attributes.redfish_facts.bios_attribute.entries.0.1.BootMode }}"
- name: UEFI
block:
- name: Set OneTimeBoot (UEFI)
community.general.redfish_config:
baseuri: "{{ oob_host }}"
username: "{{ vault_oob_username }}"
password: "{{ vault_oob_password }}"
category: Systems
command: SetBiosAttributes
bios_attributes:
OneTimeBootMode: "OneTimeUefiBootSeq"
OneTimeUefiBootSeqDev: "NIC.PxeDevice.1-1"
register: result_uefi
when: boot_mode == "Uefi" # Only run block when boot mode is Uefi
- name: LegacyBoot
block:
- name: Set OneTimeBootMode (LegacyBoot)
community.general.redfish_config:
baseuri: "{{ oob_host }}"
username: "{{ vault_oob_username }}"
password: "{{ vault_oob_password }}"
category: Systems
command: SetBiosAttributes
bios_attributes:
OneTimeBootMode: "OneTimeBootSeq"
- name: Set OneTimeBootSeqDev (LegacyBoot)
community.general.redfish_config:
baseuri: "{{ oob_host }}"
username: "{{ vault_oob_username }}"
password: "{{ vault_oob_password }}"
category: Systems
command: SetBiosAttributes
bios_attributes:
OneTimeBootSeqDev: "{{ item }}"
loop: "{{ pxe_devices }}" # FX2 Support. Sleds will have different PCIe NIC FQDD depending on the slot.
ignore_errors: True # FX2 Support. The PCIe NICs that aren't in a slot will fail. The one that is present will succeed.
register: result_bios
when: boot_mode == "Bios" # Only run block when boot mode is Bios
- name: Create BIOS Config job
community.general.idrac_redfish_command:
baseuri: "{{ oob_host }}"
username: "{{ vault_oob_username }}"
password: "{{ vault_oob_password }}"
category: Systems
command: CreateBiosConfigJob
when: result_uefi.changed or result_bios.changed # Only run when things have changed
- name: Restart sytem power gracefully
community.general.redfish_command:
category: Systems
command: PowerGracefulRestart
baseuri: "{{ oob_host }}"
username: "{{ vault_oob_username }}"
password: "{{ vault_oob_password }}"
when: result_uefi.changed or result_bios.changed # Only run when things have changed