-
Notifications
You must be signed in to change notification settings - Fork 1
/
demo_1.yml
78 lines (70 loc) · 2.19 KB
/
demo_1.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
---
- name: VMware Object Creation
hosts: localhost
gather_facts: False
vars_files:
- vcenter_vars.yml
tasks:
- name: Create a datacenter "{{ datacenter }}"
vmware_datacenter:
validate_certs: no
hostname: "{{ vcenter_server }}"
username: "{{ vcenter_user }}"
password: "{{ vcenter_pass }}"
datacenter_name: "{{ datacenter }}"
state: present
register: datacenter_result
- name: Check if datacenter "{{ datacenter }}" is created
assert:
that:
- "datacenter_result.changed"
- name: Create a cluster "{{ cluster }}"
vmware_cluster:
validate_certs: no
hostname: "{{ vcenter_server }}"
username: "{{ vcenter_user }}"
password: "{{ vcenter_pass }}"
datacenter_name: "{{ datacenter }}"
cluster_name: "{{ cluster }}"
enable_ha: no
enable_drs: yes
enable_vsan: no
state: present
register: cluster_result
- name: Check if cluster is created
assert:
that:
- "cluster_result.changed"
- name: Add existing ESXi "{{ esxi_hostname }}"
vmware_host:
validate_certs: no
hostname: "{{ vcenter_server }}"
username: "{{ vcenter_user }}"
password: "{{ vcenter_pass }}"
datacenter_name: "{{ datacenter }}"
cluster_name: "{{ cluster }}"
esxi_hostname: "{{ esxi_hostname }}"
esxi_username: "{{ esxi_username }}"
esxi_password: "{{ esxi_password }}"
state: present
register: host_result
- name: Check if host "{{ esxi_hostname }}" is added
assert:
that:
- "host_result.changed"
- name: Exit ESXi "{{ esxi_hostname }}" from maintenance mode
vmware_maintenancemode:
validate_certs: no
hostname: "{{ vcenter_server }}"
username: "{{ vcenter_user }}"
password: "{{ vcenter_pass }}"
esxi_hostname: "{{ esxi_hostname }}"
state: absent
register: host_result
- name: Check if host "{{ esxi_hostname }}" is exited from maintenance mode
assert:
that:
- "host_result.changed"
- name: Finish
debug:
msg: "Done"