-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathredfish_boot_order.yml
149 lines (135 loc) · 4.66 KB
/
redfish_boot_order.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
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
---
- hosts: idrac
connection: local
gather_facts: no
vars:
ansible_python_interpreter: python
one_time_boot_device: "Pxe"
uefi_pxe_attributes:
"PxeDev1EnDis": "Enabled"
"PxeDev1Interface": "NIC.Slot.4-1"
tasks:
- name: Check that Boot mode must be set to Uefi before setting the Uefi PXE attributes
redfish_facts:
baseuri: "{{ inventory_hostname }}"
username: "{{ idrac_user }}"
password: "{{ idrac_password }}"
category: "Systems"
command: "GetBiosAttributes"
register: result
tags:
- one-time-pxe-boot
- name: Check that Boot mode must be set to Uefi before setting the Uefi PXE attributes
set_fact:
curr_boot_mode: "{{ redfish_facts.bios_attribute.entries[0] | selectattr('BootMode', 'defined') | map(attribute='BootMode') | list | first }}"
tags:
- one-time-pxe-boot
- name: Change BootMode to 'Uefi' if currently set to 'Bios'
redfish_config:
baseuri: "{{ inventory_hostname }}"
username: "{{ idrac_user }}"
password: "{{ idrac_password }}"
category: "Systems"
command: "SetBiosAttributes"
bios_attribute_name: "BootMode"
bios_attribute_value: "Uefi"
when: curr_boot_mode != 'Uefi'
register: set_boot_mode_uefi
tags:
- one-time-pxe-boot
- name: Create a BIOS config job to change BootMode to Uefi
idrac_redfish_command:
baseuri: "{{ inventory_hostname }}"
username: "{{ idrac_user }}"
password: "{{ idrac_password }}"
category: "Systems"
command: "CreateBiosConfigJob"
when: curr_boot_mode != 'Uefi' and set_boot_mode_uefi.changed
register: boot_mode_uefi_bios_config_job
tags:
- one-time-pxe-boot
- name: Reboot system to apply new BIOS settings
redfish_command:
baseuri: "{{ inventory_hostname }}"
username: "{{ idrac_user }}"
password: "{{ idrac_password }}"
category: "Systems"
command: "PowerReboot"
when: curr_boot_mode != 'Uefi' and boot_mode_uefi_bios_config_job.changed
register: reboot_boot_mode_uefi
tags:
- one-time-pxe-boot
- name: wait for BIOS config job to finish
wait_for:
timeout: 360
when: curr_boot_mode != 'Uefi' and boot_mode_uefi_bios_config_job.changed
tags:
- one-time-pxe-boot
- name: Set Uefi PXE Boot attributes to boot from a specific NIC FQDD
redfish_config:
baseuri: "{{ inventory_hostname }}"
username: "{{ idrac_user }}"
password: "{{ idrac_password }}"
category: "Systems"
command: "SetBiosAttributes"
bios_attribute_name: "{{ item.key }}"
bios_attribute_value: "{{ item.value }}"
register: set_uefi_pxe_attributes
loop: "{{ uefi_pxe_attributes | dict2items }}"
tags:
- one-time-pxe-boot
- name: Check if any of the attributes have changed
set_fact:
bios_attributes_changed: "{{ set_uefi_pxe_attributes.results | selectattr('changed', 'defined') | selectattr('changed', 'equalto', true) | list }}"
tags:
- one-time-pxe-boot
- name: Create a BIOS config job to apply the UEFI PXE attributes
idrac_redfish_command:
baseuri: "{{ inventory_hostname }}"
username: "{{ idrac_user }}"
password: "{{ idrac_password }}"
category: "Systems"
command: "CreateBiosConfigJob"
when: bios_attributes_changed | length > 0
register: uefi_pxe_bios_config_job
tags:
- one-time-pxe-boot
- name: Reboot system to apply new UEFI PXE settings
redfish_command:
baseuri: "{{ inventory_hostname }}"
username: "{{ idrac_user }}"
password: "{{ idrac_password }}"
category: "Systems"
command: "PowerReboot"
when: (bios_attributes_changed | length) > 0 and uefi_pxe_bios_config_job.changed
register: reboot_uefi_pxe_attributes
tags:
- one-time-pxe-boot
- name: wait for BIOS config job to finish
wait_for:
timeout: 360
when: (bios_attributes_changed | length) > 0 and reboot_uefi_pxe_attributes.changed
tags:
- one-time-pxe-boot
- name: Set one time boot device to PXE
redfish_command:
baseuri: "{{ inventory_hostname }}"
username: "{{ idrac_user }}"
password: "{{ idrac_password }}"
category: "Systems"
command: "SetOneTimeBoot"
bootdevice: "{{ one_time_boot_device }}"
register: set_one_time_boot
tags:
- one-time-pxe-boot
- name: Reboot server to boot from PXE
redfish_command:
baseuri: "{{ inventory_hostname }}"
username: "{{ idrac_user }}"
password: "{{ idrac_password }}"
category: "Systems"
command: "PowerReboot"
register: reboot_one_time_boot
when: set_one_time_boot.changed
tags:
- one-time-pxe-boot