forked from oatakan/ansible-demo-playbooks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphpipam_teardown_vmware.yml
27 lines (26 loc) · 1.05 KB
/
phpipam_teardown_vmware.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
- hosts: all
become: no
gather_facts: no
tasks:
- name: poweroff vm
vmware_guest:
hostname: "{{ lookup('env', 'VMWARE_HOST') }}"
username: "{{ lookup('env', 'VMWARE_USER') }}"
password: "{{ lookup('env', 'VMWARE_PASSWORD') }}"
validate_certs: no
name: "{{ inventory_hostname }}"
uuid: "{{ hostvars[inventory_hostname].config.uuid }}"
state: poweredoff
delegate_to: 127.0.0.1
when: ('phpipam' in inventory_hostname) and (hostvars[inventory_hostname].config.uuid in inventory_hostname)
- name: delete vm
vmware_guest:
hostname: "{{ lookup('env', 'VMWARE_HOST') }}"
username: "{{ lookup('env', 'VMWARE_USER') }}"
password: "{{ lookup('env', 'VMWARE_PASSWORD') }}"
validate_certs: no
name: "{{ inventory_hostname }}"
uuid: "{{ hostvars[inventory_hostname].config.uuid }}"
state: absent
delegate_to: 127.0.0.1
when: ('phpipam' in inventory_hostname) and (hostvars[inventory_hostname].config.uuid in inventory_hostname)