Skip to content

Commit

Permalink
Fix snapshot remove null error (#540)
Browse files Browse the repository at this point in the history
Signed-off-by: Yanan Shen <[email protected]>
  • Loading branch information
123lzxm authored Jan 29, 2024
1 parent a18abf1 commit a1b0fec
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions common/vm_remove_snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@
ansible.builtin.debug: var=task_result
when: enable_debug is defined and enable_debug

- block:
- include_tasks: vm_get_snapshot_facts.yml
- name: "Check if the snapshot '{{ snapshot_name }}' is removed"
when: snapshot_remove_state | default('absent') == 'absent'
block:
- name: "Get VM's snapshots"
include_tasks: vm_get_snapshot_facts.yml

- name: "Assert snapshot '{{ snapshot_name }}' not exist"
ansible.builtin.assert:
that:
- item.name != snapshot_name
fail_msg: "Failed to remove snapshot {{ snapshot_name }}"
with_items: "{{ vm_snapshot_facts.guest_snapshots.snapshots }}"
when: snapshot_remove_state | default('absent') == 'absent'
when: vm_snapshot_facts.guest_snapshots | length > 0

0 comments on commit a1b0fec

Please sign in to comment.