-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathoneview_hypervisor_cluster_profile.yml
156 lines (146 loc) · 5.48 KB
/
oneview_hypervisor_cluster_profile.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
###
# Copyright (2016-2021) 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"
cluster_profile_name: 'Test_HCP'
spt_name: 'Test_spt-1' # SPT with no deployment plan and having one management connection
hyp_mgr_name: '172.18.13.11'
tasks:
- name: Gather facts about server profile templates
oneview_server_profile_template_facts:
config: "{{ config }}"
name: "{{ spt_name }}"
delegate_to: localhost
- set_fact:
spt_uri: "{{ server_profile_templates[0]['uri'] }}"
- name: Gather facts about OS deployment plans
oneview_os_deployment_plan_facts:
config: "{{ config }}"
name: "Basic Deployment Plan"
delegate_to: localhost
- set_fact:
dp_uri: "{{ os_deployment_plans[0]['uri'] }}"
- name: Gather facts about hypervisor managers
oneview_hypervisor_manager_facts:
config: "{{ config }}"
name: "{{ hyp_mgr_name }}"
delegate_to: localhost
- set_fact:
hyp_mgr_uri: "{{ hypervisor_managers[0]['uri'] }}"
- name: Create a basic Hypervisor Cluster Profile
oneview_hypervisor_cluster_profile:
config: "{{ config }}"
state: present
data:
name: "{{ cluster_profile_name }}"
hypervisorManagerUri: "{{ hyp_mgr_uri }}"
path: 'DC1'
hypervisorType: 'Vmware'
hypervisorHostProfileTemplate:
serverProfileTemplateUri: "{{ spt_uri }}"
deploymentPlan:
deploymentPlanUri: "{{ dp_uri }}"
serverPassword:
hostprefix: 'Test-cluster-host'
delegate_to: localhost
register: hyp_cp
# For creating virtual switch layout, enable that param and send the vswitch body under "hypervisorHostProfileTemplate:virtualSwitches"
- name: Create a Hypervisor Cluster Profile with vswitch
oneview_hypervisor_cluster_profile:
config: "{{ config }}"
state: present
params:
create_vswitch_layout: True # If this is true, virtual switch layout will be created
data:
description: "test cluster"
hypervisorType: "Vmware"
hypervisorClusterSettings:
type: "Vmware"
drsEnabled: True
haEnabled: False
multiNicVMotion: False
virtualSwitchType: "Standard"
hypervisorHostProfileTemplate:
serverProfileTemplateUri: "{{ spt_uri }}"
deploymentPlan:
deploymentPlanUri: "{{ dp_uri }}"
serverPassword: "test"
hostprefix: "Test_cluster_profile_with_vswitch"
virtualSwitches: # this is the json body used to create vswitch
serverProfileTemplateUri: "{{ spt_uri }}"
hypervisorManagerUri: "{{ hyp_mgr_uri }}"
hostConfigPolicy:
leaveHostInMaintenance: False
useHostnameToRegister: False
virtualSwitchConfigPolicy:
manageVirtualSwitches: True
configurePortGroups: True
name: "{{ cluster_profile_name }}_with_vswitch"
hypervisorManagerUri: "{{ hyp_mgr_uri }}"
path: "DC1"
delegate_to: localhost
register: hyp_cp_vswitch
- name: Do nothing with the Hypervisor Cluster Profile when no changes are provided
oneview_hypervisor_cluster_profile:
config: "{{ config }}"
state: present
data:
name: "{{ cluster_profile_name }}"
hypervisorManagerUri: "{{ hyp_mgr_uri }}"
path: 'DC1'
hypervisorType: 'Vmware'
delegate_to: localhost
- name: Update the Hypervisor Cluster Profile changing the attribute name
oneview_hypervisor_cluster_profile:
config: "{{ config }}"
state: present
data:
name: "{{ cluster_profile_name }}"
newName: "HCP-renamed"
hypervisorManagerUri: "{{ hyp_mgr_uri }}"
path: 'DC1'
hypervisorType: 'Vmware'
delegate_to: localhost
register: hyp_cp
- name: Delete the Hypervisor Cluster Profile
oneview_hypervisor_cluster_profile:
config: "{{ config }}"
state: absent
params:
force: True
soft_delete: False
data:
name: "HCP-renamed"
delegate_to: localhost
# - name: Delete the Hypervisor Cluster Profile with vswitch
# oneview_hypervisor_cluster_profile:
# config: "{{ config }}"
# state: absent
# params:
# force: False
# soft_delete: False
# data: "{{ hyp_cp_vswitch.ansible_facts.hypervisor_cluster_profile }}"
# delegate_to: localhost
# register: deleted
- name: Do nothing when Hypervisor Cluster Profile is absent
oneview_hypervisor_cluster_profile:
config: "{{ config }}"
state: absent
data:
name: "HCP-renamed"
delegate_to: localhost