2019-04-24 19:02:21 +02:00
|
|
|
---
|
2019-05-16 15:36:48 +02:00
|
|
|
- name: Remove VM
|
2019-04-24 19:02:21 +02:00
|
|
|
vmware_guest:
|
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
password: "{{ vcenter_password }}"
|
|
|
|
validate_certs: no
|
|
|
|
cluster: "{{ ccr1 }}"
|
2019-05-16 15:36:48 +02:00
|
|
|
name: "{{ item.name }}"
|
2019-04-24 19:02:21 +02:00
|
|
|
force: yes
|
|
|
|
state: absent
|
2019-05-16 15:36:48 +02:00
|
|
|
with_items: '{{ virtual_machines + virtual_machines_in_cluster }}'
|
2019-04-24 19:02:21 +02:00
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: Remove the DVSwitch
|
|
|
|
vmware_dvswitch:
|
|
|
|
validate_certs: no
|
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
password: "{{ vcenter_password }}"
|
|
|
|
datacenter_name: '{{ dc1 }}'
|
|
|
|
switch_name: '{{ dvswitch1 }}'
|
|
|
|
state: absent
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: Remove the vSwitches
|
|
|
|
vmware_vswitch:
|
|
|
|
validate_certs: no
|
2019-05-13 20:12:21 +02:00
|
|
|
hostname: '{{ item }}'
|
2019-05-16 15:36:48 +02:00
|
|
|
username: '{{ esxi_user }}'
|
|
|
|
password: '{{ esxi_password }}'
|
2019-04-24 19:02:21 +02:00
|
|
|
switch_name: "{{ switch1 }}"
|
|
|
|
state: absent
|
2019-05-16 15:36:48 +02:00
|
|
|
with_items: "{{ esxi_hosts }}"
|
|
|
|
ignore_errors: yes
|
2019-04-24 19:02:21 +02:00
|
|
|
|
|
|
|
- name: Remove ESXi Hosts to vCenter
|
|
|
|
vmware_host:
|
|
|
|
hostname: '{{ vcenter_hostname }}'
|
|
|
|
username: '{{ vcenter_username }}'
|
|
|
|
password: '{{ vcenter_password }}'
|
|
|
|
datacenter_name: '{{ dc1 }}'
|
|
|
|
cluster_name: ccr1
|
2019-05-13 20:12:21 +02:00
|
|
|
esxi_hostname: '{{ item }}'
|
2019-05-16 15:36:48 +02:00
|
|
|
esxi_username: '{{ esxi_user }}'
|
|
|
|
esxi_password: '{{ esxi_password }}'
|
2019-04-24 19:02:21 +02:00
|
|
|
state: absent
|
|
|
|
validate_certs: no
|
2019-05-16 15:36:48 +02:00
|
|
|
with_items: "{{ esxi_hosts }}"
|
2019-04-24 19:02:21 +02:00
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: Umount NFS datastores to ESXi (1/2)
|
|
|
|
vmware_host_datastore:
|
2019-05-13 20:12:21 +02:00
|
|
|
hostname: '{{ item }}'
|
2019-05-16 15:36:48 +02:00
|
|
|
username: '{{ esxi_user }}'
|
|
|
|
password: '{{ esxi_password }}'
|
|
|
|
esxi_hostname: '{{ item }}' # Won't be necessary with https://github.com/ansible/ansible/pull/56516
|
2019-04-24 19:02:21 +02:00
|
|
|
datastore_name: '{{ ds1 }}'
|
|
|
|
state: absent
|
|
|
|
validate_certs: no
|
2019-05-16 15:36:48 +02:00
|
|
|
with_items: "{{ esxi_hosts }}"
|
2019-04-24 19:02:21 +02:00
|
|
|
|
|
|
|
- name: Umount NFS datastores to ESXi (2/2)
|
|
|
|
vmware_host_datastore:
|
2019-05-13 20:12:21 +02:00
|
|
|
hostname: '{{ item }}'
|
2019-05-16 15:36:48 +02:00
|
|
|
username: '{{ esxi_user }}'
|
|
|
|
password: '{{ esxi_password }}'
|
|
|
|
esxi_hostname: '{{ item }}' # Won't be necessary with https://github.com/ansible/ansible/pull/56516
|
2019-04-24 19:02:21 +02:00
|
|
|
datastore_name: '{{ ds2 }}'
|
|
|
|
state: absent
|
|
|
|
validate_certs: no
|
2019-05-16 15:36:48 +02:00
|
|
|
with_items: "{{ esxi_hosts }}"
|
2019-04-24 19:02:21 +02:00
|
|
|
|
|
|
|
- name: Remove the datacenter
|
|
|
|
vmware_datacenter:
|
|
|
|
validate_certs: no
|
|
|
|
hostname: '{{ vcenter_hostname }}'
|
|
|
|
username: '{{ vcenter_username }}'
|
|
|
|
password: '{{ vcenter_password }}'
|
|
|
|
datacenter_name: '{{ item }}'
|
|
|
|
state: absent
|
|
|
|
when: vcsim is not defined
|
|
|
|
with_items:
|
|
|
|
- '{{ dc1 }}'
|
|
|
|
- datacenter_0001
|
|
|
|
|
|
|
|
- name: kill vcsim
|
|
|
|
uri:
|
|
|
|
url: "http://{{ vcsim }}:5000/killall"
|
|
|
|
when: vcsim is defined
|