ansible/test/integration/targets/prepare_vmware_tests/tasks/teardown.yml
Gonéri Le Bouder 964783fbd2 vmware_guest: speed up vmware_guest tests
- Use predictable VM name during the tests (test_vm1, test_vm2 and
  test_vm2). This to simplify the teardown of the newly created resource
  before the next test.
- Update the documentation to explain the new requirement
- Avoid VM creation with `with_items` when it's not mandatory. This to:
    - speed up the test execution, our hypervisors have limited resources
    - simplify the teardown
- Remove `create_d1_c1_f0_env.yml`, the test was just testing how Ansible
  pass environment variables.
- Correct the name for the `f0` variable (`f1`)
- Fix the DVS tests, the hosts can now reach the dvswitch1 vswitch
- Provision the VM with a poweroff status, this to improve the
  idempotency and sleep up the tests
- Avoid the use of `prepare_vmware_tests` to prepare virtual machines
  when we just need one machine
2019-07-26 14:07:01 +02:00

116 lines
3.1 KiB
YAML

---
- name: Remove the VM prepared by prepare_vmware_tests
vmware_guest:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: no
name: "{{ item.name }}"
force: yes
state: absent
with_items: '{{ virtual_machines + virtual_machines_in_cluster }}'
- name: Remove the test_vm* VMs
vmware_guest:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: no
name: "{{ item }}"
force: yes
state: absent
with_items:
- test_vm1
- test_vm2
- test_vm3
- 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
hostname: '{{ item }}'
username: '{{ esxi_user }}'
password: '{{ esxi_password }}'
switch_name: "{{ switch1 }}"
state: absent
with_items: "{{ esxi_hosts }}"
ignore_errors: yes
- name: Remove ESXi Hosts to vCenter
vmware_host:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter_name: '{{ dc1 }}'
cluster_name: ccr1
esxi_hostname: '{{ item }}'
esxi_username: '{{ esxi_user }}'
esxi_password: '{{ esxi_password }}'
state: absent
validate_certs: no
with_items: "{{ esxi_hosts }}"
ignore_errors: yes
- name: Umount NFS datastores to ESXi (1/2)
vmware_host_datastore:
hostname: '{{ item }}'
username: '{{ esxi_user }}'
password: '{{ esxi_password }}'
esxi_hostname: '{{ item }}' # Won't be necessary with https://github.com/ansible/ansible/pull/56516
datastore_name: '{{ ds1 }}'
state: absent
validate_certs: no
with_items: "{{ esxi_hosts }}"
- name: Umount NFS datastores to ESXi (2/2)
vmware_host_datastore:
hostname: '{{ item }}'
username: '{{ esxi_user }}'
password: '{{ esxi_password }}'
esxi_hostname: '{{ item }}' # Won't be necessary with https://github.com/ansible/ansible/pull/56516
datastore_name: '{{ ds2 }}'
state: absent
validate_certs: no
with_items: "{{ esxi_hosts }}"
- name: Delete a datastore cluster to datacenter
vmware_datastore_cluster:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
validate_certs: no
datacenter_name: "{{ dc1 }}"
datastore_cluster_name: '{{ item }}'
state: absent
with_items:
- DSC1
- DSC2
ignore_errors: yes
- 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