-
Notifications
You must be signed in to change notification settings - Fork 65
/
oneview_server_hardware.yml
172 lines (155 loc) · 5.64 KB
/
oneview_server_hardware.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
###
# Copyright (2016-2020) Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License..
###
---
- hosts: all
vars:
config: "{{ playbook_dir }}/oneview_config.json"
contents: "{{lookup('file', config)}}"
variant: 'Synergy'
multiple_hosts:
- "{{ contents.server_hardware_hostname }}"
tasks:
- name: Gather facts about all Scopes
oneview_scope_facts:
config: "{{ config }}"
delegate_to: localhost
- name: Add a Server Hardware
oneview_server_hardware:
config: "{{ config }}"
state: present
data:
hostname : '{{ contents.server_hardware_hostname }}'
username : '{{ contents.server_hardware_username }}'
password : '{{ contents.server_hardware_password }}'
force : false
licensingIntent: "OneView"
configurationState: "Managed"
initialScopeUris:
- "{{ scopes[0]['uri'] }}" #Supported only with OneView API version >= 600.
delegate_to: localhost
when: variant == 'C7000'
- name: Do nothing when the server hardware is already present
oneview_server_hardware:
config: "{{ config }}"
state: present
data:
hostname : '{{ contents.server_hardware_hostname }}'
username : '{{ contents.server_hardware_username }}'
password : '{{ contents.server_hardware_password }}'
force : false
licensingIntent: "OneView"
configurationState: "Managed"
delegate_to: localhost
when: variant == 'C7000'
#This task available only with OneView API version >= 600.
- name: Add multiple rack-mount servers
oneview_server_hardware:
config: "{{ config }}"
state: multiple_servers_added
data:
mpHostsAndRanges : "{{ multiple_hosts }}"
username : "{{ contents.server_hardware_username }}"
password : "{{ contents.server_hardware_password }}"
initialScopeUris:
- "{{ scopes[0]['uri'] }}"
licensingIntent: "OneView"
configurationState: "Managed"
delegate_to: localhost
when: variant == 'C7000'
- name: Gather facts about all Server Hardwares
oneview_server_hardware_facts:
config: "{{ config }}"
delegate_to: localhost
- debug: var=server_hardwares
- name: Power Off the server hardware
oneview_server_hardware:
config: "{{ config }}"
state: power_state_set
data:
name : "{{ server_hardwares[0]['name'] }}"
powerStateData:
powerState: "Off"
powerControl: "MomentaryPress"
delegate_to: localhost
- name: Power On the server hardware
oneview_server_hardware:
config: "{{ config }}"
state: power_state_set
data:
name : "{{ server_hardwares[0]['name'] }}"
powerStateData:
powerState: "On"
powerControl: "MomentaryPress"
delegate_to: localhost
- name: Refresh the server hardware
oneview_server_hardware:
config: "{{ config }}"
state: refresh_state_set
data:
name : "{{ server_hardwares[0]['name'] }}"
refreshStateData:
refreshState : "RefreshPending"
delegate_to: localhost
- name: Update the Server Hardware iLO firmware version
oneview_server_hardware:
config: "{{ config }}"
state: ilo_firmware_version_updated
data:
name : "{{ server_hardwares[0]['name'] }}"
delegate_to: localhost
- name: Reset the Server Hardware iLO State
oneview_server_hardware:
config: "{{ config }}"
state: ilo_state_reset
data:
name: "{{ server_hardwares[0]['name'] }}"
delegate_to: localhost
- name: Set the server UID state off
oneview_server_hardware:
config: "{{ config }}"
state: uid_state_off
data:
name: "{{ server_hardwares[0]['name'] }}"
delegate_to: localhost
- name: Enable Server Maintenance Mode
oneview_server_hardware:
config: "{{ config }}"
state: enable_maintenance_mode
data:
name: "{{ server_hardwares[0]['name'] }}"
delegate_to: localhost
- name: Disable Server Maintenance Mode
oneview_server_hardware:
config: "{{ config }}"
state: disable_maintenance_mode
data:
name: "{{ server_hardwares[0]['name'] }}"
delegate_to: localhost
# Commenting below tasks to ensure continuity for automation script
# - name: Remove the server hardware by its IP
# oneview_server_hardware:
# config: "{{ config }}"
# state: absent
# data:
# name : '{{ contents.server_hardware_hostname }}'
# delegate_to: localhost
# - name: Do nothing when the server hardware is already removed
# oneview_server_hardware:
# config: "{{ config }}"
# state: absent
# data:
# name : '{{ contents.server_hardware_hostname }}'
# delegate_to: localhost