-
Notifications
You must be signed in to change notification settings - Fork 0
/
deletevm.yaml
28 lines (27 loc) · 937 Bytes
/
deletevm.yaml
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
---
- name: Remove virtual machine
hosts: localhost
gather_facts: no
environment:
# VMWARE_HOST: "{{ vcenter_hostname }}"
# VMWARE_USER: "{{ vcenter_username }}"
# VMWARE_PASSWORD: "{{ vcenter_password }}"
VMWARE_VALIDATE_CERTS: no
vars:
pod_folder: "{{ organization_folder }}/{{ pod_folder_name }}"
# pod_folder_name: "oca-{{ pod_number}}: {{ pod_name }}"
pod_folder_name: "oca-{{ '%03d' % pod_number }}"
# vm_name: "oca-{{ pod_number }}-{{ vm_number }}: {{ vm_template }}"
tasks:
- set_fact:
vm_name: "oca-{{ '%03d' % pod_number }}-{{ '%03d' % vm_number }}"
datacenter: "{{ vcenter_datacenter }}"
- name: Remove VM
vmware_guest:
validate_certs: no
cluster: "{{ vcenter_cluster }}"
name: "oca-{{ '%03d' % pod_number }}-{{ '%03d' % vm_number }}"
force: true
state: "absent"
delegate_to: localhost
register: facts