-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrhv_vm_remove.yml
43 lines (40 loc) · 963 Bytes
/
rhv_vm_remove.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
---
- name: Remove VM on RHV
hosts: localhost
connection: local
gather_facts: false
pre_tasks:
- name: Login to RHV
ovirt_auth:
hostname: "{{ rhvm_fqdn }}"
username: "{{ rhvm_user }}"
password: "{{ rhvm_password }}"
ca_file: "{{ rhvm_cafile | default(omit) }}"
insecure: "{{ rhvm_insecure | default(true) }}"
tags:
- always
vars:
datacenter: Default
vm_names: "{{ vm_name.split(',') }}"
tasks:
- name: Stop VM
ovirt_vm:
auth: "{{ ovirt_auth }}"
name: "{{ item }}"
state: stopped
wait: yes
loop: "{{ vm_names }}"
- name: Delete VM
ovirt_vm:
auth: "{{ ovirt_auth }}"
name: "{{ item }}"
state: absent
wait: yes
loop: "{{ vm_names }}"
post_tasks:
- name: Logout from RHV
ovirt_auth:
state: absent
ovirt_auth: "{{ ovirt_auth }}"
tags:
- always