-
Notifications
You must be signed in to change notification settings - Fork 0
/
redfish_manager_attributes.yml
132 lines (119 loc) · 4.02 KB
/
redfish_manager_attributes.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
---
- hosts: idrac
name: Set the iDRAC manager and system attributes
connection: local
gather_facts: False
vars:
idrac_manager_attributes:
"IPv4.1.DHCPEnable": "Enabled"
"IPv4.1.DNSFromDHCP": "Enabled"
"IPMILan.1.Enable": "Enabled"
"Serial.1.BaudRate": "115200"
"IPMISerial.1.BaudRate": "115200"
"IPMISOL.1.BaudRate": "115200"
"VirtualConsole.1.PluginType": "Java"
idrac_system_attributes:
"ThermalSettings.1.FanSpeedOffset": "Off"
"ServerPwr.1.PSRedPolicy": "A/B Grid Redundant"
"ServerPwr.1.PSRapidOn": "Enabled"
tasks:
- name: Get iDRAC manager attributes
uri:
url: "https://{{inventory_hostname}}/redfish/v1/Managers/iDRAC.Embedded.1/Attributes"
user: "{{ idrac_user }}"
password: "{{ idrac_password }}"
method: GET
headers:
accept: "application/json"
force_basic_auth: no
validate_certs: no
register: result
tags:
- get-idrac-attributes
- name: get iDRAC manager attributes
set_fact:
current_manager_attributes: "{{ result.json.Attributes }}"
tags:
- get-idrac-attributes
- debug:
var: current_manager_attributes[item.key]
loop: "{{ idrac_manager_attributes | dict2items }}"
tags:
- get-idrac-attributes
- name: iterate and add those manager attributes to dict that have a different value
set_fact:
new_manager_attributes: "{{ new_manager_attributes | default({}) | combine( { item.key: item.value } ) }}"
when: item.key in current_manager_attributes and item.value != current_manager_attributes[item.key]
loop: "{{ idrac_manager_attributes | dict2items }}"
tags:
- get-idrac-attributes
- debug:
var: new_manager_attributes
tags:
- get-idrac-attributes
- name: Set iDRAC attributes
uri:
url: "https://{{inventory_hostname}}/redfish/v1/Managers/iDRAC.Embedded.1/Attributes"
user: "{{ idrac_user }}"
password: "{{ idrac_password }}"
method: PATCH
headers:
accept: "application/json"
content-type: "application/json"
body:
"Attributes": "{{ new_manager_attributes }}"
body_format: "json"
force_basic_auth: no
validate_certs: no
when: new_manager_attributes is defined and new_manager_attributes.keys()|length > 0
register: result
tags:
- set-idrac-attributes
- name: Get iDRAC system attributes
uri:
url: "https://{{inventory_hostname}}/redfish/v1/Managers/System.Embedded.1/Attributes"
user: "{{ idrac_user }}"
password: "{{ idrac_password }}"
method: GET
headers:
accept: "application/json"
force_basic_auth: no
validate_certs: no
register: result
tags:
- get-system-attributes
- name: get iDRAC system attributes
set_fact:
current_system_attributes: "{{ result.json.Attributes }}"
tags:
- get-system-attributes
- debug:
var: current_system_attributes[item.key]
loop: "{{ idrac_system_attributes | dict2items }}"
tags:
- get-system-attributes
- name: iterate and add those attributes to dict that have a different value
set_fact:
new_system_attributes: "{{ new_system_attributes | default({}) | combine( { item.key: item.value } ) }}"
when: item.key in current_system_attributes and item.value != current_system_attributes[item.key]
loop: "{{ idrac_system_attributes | dict2items }}"
tags:
- get-system-attribute
- name: Set System attributes
uri:
url: "https://{{inventory_hostname}}/redfish/v1/Managers/System.Embedded.1/Attributes"
user: "{{ idrac_user }}"
password: "{{ idrac_password }}"
method: PATCH
headers:
accept: "application/json"
content-type: "application/json"
body:
"Attributes": "{{ new_system_attributes }}"
body_format: "json"
force_basic_auth: no
validate_certs: no
when: new_system_attributes is defined and new_system_attributes.keys()|length > 0
register: result
tags:
- set-system-attributes