|
7 | 7 |
|
8 | 8 | # Test0001: Try to delete the non-existent snapshot
|
9 | 9 | - name: 0001 - Delete non-existent snapshot
|
10 |
| - vmware_guest_snapshot: |
| 10 | + community.vmware.vmware_guest_snapshot: |
11 | 11 | validate_certs: false
|
12 | 12 | hostname: '{{ vcenter_hostname }}'
|
13 | 13 | username: '{{ vcenter_username }}'
|
|
20 | 20 |
|
21 | 21 | # Test0002: Create two snapshots
|
22 | 22 | - name: 0002 - Create snapshot
|
23 |
| - vmware_guest_snapshot: |
| 23 | + community.vmware.vmware_guest_snapshot: |
24 | 24 | validate_certs: false
|
25 | 25 | hostname: '{{ vcenter_hostname }}'
|
26 | 26 | username: '{{ vcenter_username }}'
|
|
37 | 37 |
|
38 | 38 | # Test0003: Reanme a to c
|
39 | 39 | - name: 0003 - Rename snapshot
|
40 |
| - vmware_guest_snapshot: |
| 40 | + community.vmware.vmware_guest_snapshot: |
41 | 41 | validate_certs: false
|
42 | 42 | hostname: '{{ vcenter_hostname }}'
|
43 | 43 | username: '{{ vcenter_username }}'
|
|
51 | 51 |
|
52 | 52 | # Test0004: Create snap_a again
|
53 | 53 | - name: 0004 - Re-create snapshot a
|
54 |
| - vmware_guest_snapshot: |
| 54 | + community.vmware.vmware_guest_snapshot: |
55 | 55 | validate_certs: false
|
56 | 56 | hostname: '{{ vcenter_hostname }}'
|
57 | 57 | username: '{{ vcenter_username }}'
|
|
65 | 65 |
|
66 | 66 | # Test0005: Change description of snap_c
|
67 | 67 | - name: 0005 - Change description of snap_c
|
68 |
| - vmware_guest_snapshot: |
| 68 | + community.vmware.vmware_guest_snapshot: |
69 | 69 | validate_certs: false
|
70 | 70 | hostname: '{{ vcenter_hostname }}'
|
71 | 71 | username: '{{ vcenter_username }}'
|
|
79 | 79 |
|
80 | 80 | # Test0006: Delete snap_b with child remove
|
81 | 81 | - name: 0006 - Delete snap_b with child remove
|
82 |
| - vmware_guest_snapshot: |
| 82 | + community.vmware.vmware_guest_snapshot: |
83 | 83 | validate_certs: false
|
84 | 84 | hostname: '{{ vcenter_hostname }}'
|
85 | 85 | username: '{{ vcenter_username }}'
|
|
93 | 93 |
|
94 | 94 | # Test0007: Delete all snapshots
|
95 | 95 | - name: 0007 - Delete all snapshots
|
96 |
| - vmware_guest_snapshot: |
| 96 | + community.vmware.vmware_guest_snapshot: |
97 | 97 | validate_certs: false
|
98 | 98 | hostname: '{{ vcenter_hostname }}'
|
99 | 99 | username: '{{ vcenter_username }}'
|
|
105 | 105 |
|
106 | 106 | # Test0008: Create snap_a again and revert to it
|
107 | 107 | - name: 0008 - Re-create snapshot a
|
108 |
| - vmware_guest_snapshot: |
| 108 | + community.vmware.vmware_guest_snapshot: |
109 | 109 | validate_certs: false
|
110 | 110 | hostname: '{{ vcenter_hostname }}'
|
111 | 111 | username: '{{ vcenter_username }}'
|
|
118 | 118 | description: "snap named a"
|
119 | 119 |
|
120 | 120 | - name: 0008 - Revert to snap_a
|
121 |
| - vmware_guest_snapshot: |
| 121 | + community.vmware.vmware_guest_snapshot: |
122 | 122 | validate_certs: false
|
123 | 123 | hostname: '{{ vcenter_hostname }}'
|
124 | 124 | username: '{{ vcenter_username }}'
|
|
131 | 131 |
|
132 | 132 | # Test0009: Create snap_a and check in result
|
133 | 133 | - name: 0009 - create snapshot a
|
134 |
| - vmware_guest_snapshot: |
| 134 | + community.vmware.vmware_guest_snapshot: |
135 | 135 | validate_certs: false
|
136 | 136 | hostname: '{{ vcenter_hostname }}'
|
137 | 137 | username: '{{ vcenter_username }}'
|
|
144 | 144 | description: "snap named a"
|
145 | 145 | register: snapshot_details
|
146 | 146 |
|
147 |
| -- debug: var=snapshot_details |
| 147 | +- ansible.builtin.debug: var=snapshot_details |
148 | 148 |
|
149 | 149 | - name: Check if snapshot details available or not
|
150 |
| - assert: |
| 150 | + ansible.builtin.assert: |
151 | 151 | that:
|
152 | 152 | - "snapshot_details['msg'] == 'Snapshot named [snap_a] already exists and is current.'"
|
153 | 153 |
|
154 | 154 | # Test0011: Failure sceanrios - when name and UUID is not specified
|
155 | 155 | - name: 0011 - name and UUID is missing
|
156 |
| - vmware_guest_snapshot: |
| 156 | + community.vmware.vmware_guest_snapshot: |
157 | 157 | validate_certs: false
|
158 | 158 | hostname: '{{ vcenter_hostname }}'
|
159 | 159 | username: '{{ vcenter_username }}'
|
|
166 | 166 | ignore_errors: true
|
167 | 167 |
|
168 | 168 | - name: Check if error is shown
|
169 |
| - assert: |
| 169 | + ansible.builtin.assert: |
170 | 170 | that:
|
171 | 171 | - "'one of the following is required: name, uuid' in snapshot_failure_details['msg']"
|
172 | 172 | - "snapshot_failure_details.changed == false"
|
| 173 | + |
| 174 | +# Test0010 : Test for revert and remove a snapshot to specify snapshot_id |
| 175 | +- name: 0012 - Create snapshot |
| 176 | + community.vmware.vmware_guest_snapshot: |
| 177 | + validate_certs: false |
| 178 | + hostname: '{{ vcenter_hostname }}' |
| 179 | + username: '{{ vcenter_username }}' |
| 180 | + password: '{{ vcenter_password }}' |
| 181 | + datacenter: "{{ dc1 }}" |
| 182 | + name: "{{ virtual_machines[0].name }}" |
| 183 | + folder: "{{ virtual_machines[0].folder }}" |
| 184 | + state: present |
| 185 | + snapshot_name: "snap_{{item}}" |
| 186 | + description: "snap named {{item}}" |
| 187 | + with_items: |
| 188 | + - b |
| 189 | + - c |
| 190 | + register: snapshot_creation_result0012 |
| 191 | + |
| 192 | +- name: Create the snapshot_ids variable |
| 193 | + ansible.builtin.set_fact: |
| 194 | + snapshot_ids: >- |
| 195 | + {{ snapshot_ids | default([]) |
| 196 | + + [({ |
| 197 | + 'name': item.snapshot_results.current_snapshot.name, |
| 198 | + 'snapshot_id': item.snapshot_results.current_snapshot.id |
| 199 | + })] |
| 200 | + }} |
| 201 | + loop: "{{ snapshot_creation_result0012.results }}" |
| 202 | + |
| 203 | +- name: 0013 - Revert to snap_b with snapshot_id |
| 204 | + community.vmware.vmware_guest_snapshot: |
| 205 | + validate_certs: false |
| 206 | + hostname: '{{ vcenter_hostname }}' |
| 207 | + username: '{{ vcenter_username }}' |
| 208 | + password: '{{ vcenter_password }}' |
| 209 | + datacenter: "{{ dc1 }}" |
| 210 | + name: "{{ virtual_machines[0].name }}" |
| 211 | + folder: "{{ virtual_machines[0].folder }}" |
| 212 | + state: revert |
| 213 | + snapshot_id: "{{ item.snapshot_id }}" |
| 214 | + loop: "{{ snapshot_ids }}" |
| 215 | + when: |
| 216 | + - item.name == "snap_b" |
| 217 | + register: revert_snapshot_with_id_result |
| 218 | + |
| 219 | +- name: Make sure whether reverted with snapshot_id |
| 220 | + ansible.builtin.assert: |
| 221 | + that: |
| 222 | + - item.changed is sameas true |
| 223 | + loop: "{{ revert_snapshot_with_id_result.results }}" |
| 224 | + when: |
| 225 | + - item.item.name == "snap_b" |
| 226 | + |
| 227 | +- name: 0014 - Remove snap_b with snapshot_id |
| 228 | + community.vmware.vmware_guest_snapshot: |
| 229 | + validate_certs: false |
| 230 | + hostname: '{{ vcenter_hostname }}' |
| 231 | + username: '{{ vcenter_username }}' |
| 232 | + password: '{{ vcenter_password }}' |
| 233 | + datacenter: "{{ dc1 }}" |
| 234 | + name: "{{ virtual_machines[0].name }}" |
| 235 | + folder: "{{ virtual_machines[0].folder }}" |
| 236 | + state: absent |
| 237 | + snapshot_id: "{{ item.snapshot_id }}" |
| 238 | + loop: "{{ snapshot_ids }}" |
| 239 | + when: |
| 240 | + - item.name == "snap_b" |
| 241 | + register: remove_snapshot_with_id_result |
| 242 | + |
| 243 | +- name: Make sure whether removed with snapshot_id |
| 244 | + ansible.builtin.assert: |
| 245 | + that: |
| 246 | + - item.changed is sameas true |
| 247 | + loop: "{{ remove_snapshot_with_id_result.results }}" |
| 248 | + when: |
| 249 | + - item.item.name == "snap_b" |
0 commit comments