-
Notifications
You must be signed in to change notification settings - Fork 3
/
destroy.yml
55 lines (51 loc) · 1.38 KB
/
destroy.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
---
- hosts: localhost
gather_facts: False
connection: local
vars_files:
- vars.yml
vars:
vcenter_hostname: ""
vcenter_user: ""
vcenter_pass: ""
vmtemplate: ""
vm_name: ""
new_port: ""
inventory_dir: ""
tasks:
- name: Gather Facts of all VMs in Virtual Center or ESXi.
local_action:
module: vmware_vm_facts
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_user }}"
password: "{{ vcenter_pass }}"
validate_certs: False
register: facts
- name: Poweroff Virtual Machines
vmware_guest:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_user }}"
password: "{{ vcenter_pass }}"
validate_certs: no
datacenter: justai-lab
cluster: cluster
uuid: "{{ facts['virtual_machines']['%s'| format(item.name)]['uuid'] }}"
name: "{{ item.name }}"
state: poweredoff
with_items:
- "{{ spec.nodes }}"
delegate_to: localhost
- name: Destory Virtual Machines
vmware_guest:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_user }}"
password: "{{ vcenter_pass }}"
validate_certs: no
datacenter: justai-lab
cluster: cluster
uuid: "{{ facts['virtual_machines']['%s'| format(item.name)]['uuid'] }}"
name: "{{ item.name }}"
state: absent
with_items:
- "{{ spec.nodes }}"
delegate_to: localhost