-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdemo_2.yml
49 lines (44 loc) · 1.38 KB
/
demo_2.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
---
- name: Guest Creation
gather_facts: no
vars_files:
- vcenter_vars.yml
hosts: localhost
tasks:
- name: Clone a virtual machine {{ vm_name }} from existing template {{ template_name }}
vmware_guest:
name: "{{ vm_name }}"
template: "{{ template_name }}"
hostname: "{{ vcenter_server }}"
username: "{{ vcenter_user }}"
password: "{{ vcenter_pass }}"
validate_certs: no
folder: "{{ folder }}"
datacenter: "{{ datacenter_2 }}"
networks:
- name: "{{ network }}"
type: dhcp
cluster: "{{ cluster_2 }}"
customization:
dns_servers: "{{ dns_server }}"
wait_for_ip_address: yes
register: vm_result
- name: Assert that VM is created
assert:
that:
- "vm_result.changed"
- name: Create a virtual machine {{ vm_name }} snapshot name {{ snapshot }}
vmware_guest_snapshot:
name: "{{ vm_name }}"
hostname: "{{ vcenter_server }}"
username: "{{ vcenter_user }}"
password: "{{ vcenter_pass }}"
validate_certs: False
folder: "{{ folder }}"
datacenter: "{{ datacenter_2 }}"
snapshot_name: "{{ snapshot }}"
register: snapshot_result
- name: Assert that VM snapshot is created
assert:
that:
- "snapshot_result.changed"