Skip to content

Commit fe29d2a

Browse files
Merge pull request #6531 from sjug/perfscale-2110-scope-vm-teardown
PERFSCALE-2110: Ansible: scope create-vm teardown to target VM
2 parents 4ce2bef + 57520f6 commit fe29d2a

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

ansible/roles/create-vm/tasks/main.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,17 @@
66
command: list_vms
77
register: all_vms
88

9-
- name: find VMs that start with "microshift-*"
10-
set_fact:
11-
vm_match: "{{ all_vms.list_vms | join(' ') | regex_findall('microshift-\\S+', multiline=True, ignorecase=True) }}"
12-
13-
- name: destroy microshift VM
9+
- name: destroy target VM if present
1410
community.libvirt.virt:
15-
name: "{{ item }}"
11+
name: "{{ vm_name }}"
1612
state: destroyed
17-
loop: "{{ vm_match }}"
13+
when: vm_name in (all_vms.list_vms | default([]))
1814

19-
- name: undefine microshift VM
15+
- name: undefine target VM if present
2016
community.libvirt.virt:
21-
name: "{{ item }}"
17+
name: "{{ vm_name }}"
2218
command: undefine
23-
loop: "{{ vm_match }}"
19+
when: vm_name in (all_vms.list_vms | default([]))
2420

2521
- name: find create-vm.sh
2622
ansible.builtin.find:

0 commit comments

Comments
 (0)