-
Notifications
You must be signed in to change notification settings - Fork 0
/
vsphere.yml
205 lines (205 loc) · 6.85 KB
/
vsphere.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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
---
- hosts: localhost
gather_facts: false
tasks:
- name: create Datacenter
delegate_to: localhost
vmware_datacenter:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter_name: "{{ myvmdcname }}"
validate_certs: false
state: present
- name: create Cluster
delegate_to: localhost
vmware_cluster:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter_name: "{{ myvmdcname }}"
cluster_name: "{{ myvmclname }}"
validate_certs: false
state: present
- name: Add ESXi Host 1 to vCenter
delegate_to: localhost
vmware_host:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: "{{ myvmdcname }}"
cluster: "{{ myvmclname }}"
esxi_hostname: "esx01.fsimonetti.lan"
esxi_username: '{{ esxi_username }}'
esxi_password: '{{ esxi_password }}'
validate_certs: false
state: present
- name: Add ESXi license to host 1
delegate_to: localhost
vcenter_license:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
esxi_hostname: "esx01.fsimonetti.lan"
license: '{{ esxi_license }}'
validate_certs: false
state: present
- name: Add ESXi Host 2 to vCenter
delegate_to: localhost
vmware_host:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: "{{ myvmdcname }}"
cluster: "{{ myvmclname }}"
esxi_hostname: "esx02.fsimonetti.lan"
esxi_username: '{{ esxi_username }}'
esxi_password: '{{ esxi_password }}'
validate_certs: false
state: present
- name: Add ESXi license to host 2
delegate_to: localhost
vcenter_license:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
esxi_hostname: "esx02.fsimonetti.lan"
license: '{{ esxi_license }}'
validate_certs: false
state: present
- name: Add vCenter license to VCSA
delegate_to: localhost
vcenter_license:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
license: '{{ vcenter_license }}'
validate_certs: false
state: present
- name: Mount NFS datastores to host 1
delegate_to: localhost
vmware_host_datastore:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
validate_certs: false
nfs_server: '{{ mynfs }}'
nfs_path: '{{ item.path }}'
datastore_type: 'nfs'
datastore_name: '{{ item.name }}'
esxi_hostname: "esx01.fsimonetti.lan"
state: present
nfs_ro: no
loop:
- { 'name': 'iso-ds', 'path': '/mnt/cl0/v0/iso-ds'}
- { 'name': 'vm-ds', 'path': '/mnt/cl0/v1/vm-ds'}
- name: Mount NFS datastores to host 2
delegate_to: localhost
vmware_host_datastore:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
validate_certs: false
nfs_server: '{{ mynfs }}'
nfs_path: '{{ item.path }}'
datastore_type: 'nfs'
datastore_name: '{{ item.name }}'
esxi_hostname: "esx02.fsimonetti.lan"
state: present
nfs_ro: no
loop:
- { 'name': 'iso-ds', 'path': '/mnt/cl0/v0/iso-ds'}
- { 'name': 'vm-ds', 'path': '/mnt/cl0/v1/vm-ds'}
- name: Create directory structure for OS ISOs and vm templates
delegate_to: localhost
vsphere_file:
host: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
validate_certs: false
datacenter: "{{ myvmdcname }}"
datastore: '{{ item.ds }}'
path: '{{ item.dst }}'
state: directory
loop:
- { 'ds': 'iso-ds', 'dst': '/win' }
- { 'ds': 'iso-ds', 'dst': '/linux' }
- { 'ds': 'vm-ds', 'dst': '/templates' }
- name: enable fully automated DRS on the cluster
delegate_to: localhost
vmware_cluster_drs:
cluster_name: "{{ myvmclname }}"
enable_drs: yes
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
validate_certs: false
datacenter: "{{ myvmdcname }}"
# - name: copy Windows 2012R2 ISO to datastore
# delegate_to: localhost
# vsphere_copy:
# hostname: '{{ vcenter_hostname }}'
# username: '{{ vcenter_username }}'
# password: '{{ vcenter_password }}'
# validate_certs: false
# src: /iso/win/2012r2.iso
# datacenter: "{{ myvmdcname }}"
# datastore: 'iso-ds'
# path: /win/2012r2.iso
# - name: copy Windows 2016 ISO to datastore
# delegate_to: localhost
# vsphere_copy:
# hostname: '{{ vcenter_hostname }}'
# username: '{{ vcenter_username }}'
# password: '{{ vcenter_password }}'
# validate_certs: false
# src: /iso/win/2016.iso
# datacenter: "{{ myvmdcname }}"
# datastore: 'iso-ds'
# path: /win/2016.iso
# - name: copy CentOS 8 ISO to datastore
# delegate_to: localhost
# vsphere_copy:
# hostname: '{{ vcenter_hostname }}'
# username: '{{ vcenter_username }}'
# password: '{{ vcenter_password }}'
# validate_certs: false
# src: /iso/linux/centos8.iso
# datacenter: "{{ myvmdcname }}"
# datastore: 'iso-ds'
# path: /linux/centos8.iso
# - name: Clone a virtual machine from Windows template and customize
# delegate_to: localhost
# vmware_guest:
# hostname: "{{ vcenter_hostname }}"
# username: "{{ vcenter_username }}"
# password: "{{ vcenter_password }}"
# validate_certs: no
# datacenter: "{{ myvmdcname }}"
# cluster: "{{ myvmclname }}"
# name: "testvm1"
# folder: "/{{ myvmdcname }}/vm"
# template: "w2016template"
# networks:
# - name: VM Network
# ip: 192.168.101.10
# netmask: 255.255.255.0
# gateway: 192.168.101.2
# customization:
# dns_servers:
# - 192.168.101.104
# dns_suffix:
# - "{{ myaddomain }}"
# domain: "{{ myaddomain }}"
# # https://docs.microsoft.com/en-us/previous-versions/windows/embedded/ms912391(v=winembedded.11)?redirectedfrom=MSDN
# timezone: 110
# hwclockUTC: true
# domainadmin: "administrator@{{ myaddomain }}"
# domainadminpassword: "{{ vcenter_password }}"
# fullname: "Ferdinando Simonetti"
# joindomain: "{{ myaddomain }}"
# orgname: "Ferdinando Simonetti"
# password: "{{ vcenter_password }}"
# state: poweredon
# wait_for_ip_address: true
# wait_for_customization: true