|
| 1 | +--- |
| 2 | +- name: setup instance |
| 3 | + ngine_io.cloudstack.instance: |
| 4 | + name: "{{ cs_resource_prefix }}-vm-snapshot" |
| 5 | + template: "{{ test_cs_instance_template }}" |
| 6 | + service_offering: "{{ test_cs_instance_offering_1 }}" |
| 7 | + zone: "{{ cs_common_zone_basic }}" |
| 8 | + register: instance |
| 9 | +- name: verify create instance |
| 10 | + assert: |
| 11 | + that: |
| 12 | + - instance is successful |
| 13 | + |
| 14 | +- name: ensure no snapshot exists |
| 15 | + ngine_io.cloudstack.instance_snapshot: |
| 16 | + name: "{{ cs_resource_prefix }}_snapshot" |
| 17 | + vm: "{{ cs_resource_prefix }}-vm-snapshot" |
| 18 | + zone: "{{ cs_common_zone_basic }}" |
| 19 | + state: absent |
| 20 | + register: snap |
| 21 | +- name: verify setup |
| 22 | + assert: |
| 23 | + that: |
| 24 | + - snap is successful |
| 25 | + |
| 26 | +- name: test fail if missing name |
| 27 | + ngine_io.cloudstack.instance_snapshot: |
| 28 | + zone: "{{ cs_common_zone_basic }}" |
| 29 | + register: snap |
| 30 | + ignore_errors: true |
| 31 | +- name: verify results of fail if missing params |
| 32 | + assert: |
| 33 | + that: |
| 34 | + - snap is failed |
| 35 | + - 'snap.msg.startswith("missing required arguments: ")' |
| 36 | + |
| 37 | +- name: test create snapshot in check mode |
| 38 | + ngine_io.cloudstack.instance_snapshot: |
| 39 | + name: "{{ cs_resource_prefix }}_snapshot" |
| 40 | + vm: "{{ cs_resource_prefix }}-vm-snapshot" |
| 41 | + zone: "{{ cs_common_zone_basic }}" |
| 42 | + snapshot_memory: yes |
| 43 | + register: snap |
| 44 | + check_mode: true |
| 45 | +- name: verify test create snapshot in check mode |
| 46 | + assert: |
| 47 | + that: |
| 48 | + - snap is changed |
| 49 | + |
| 50 | +- name: test create snapshot |
| 51 | + ngine_io.cloudstack.instance_snapshot: |
| 52 | + name: "{{ cs_resource_prefix }}_snapshot" |
| 53 | + vm: "{{ cs_resource_prefix }}-vm-snapshot" |
| 54 | + zone: "{{ cs_common_zone_basic }}" |
| 55 | + snapshot_memory: yes |
| 56 | + register: snap |
| 57 | +- name: verify test create snapshot |
| 58 | + assert: |
| 59 | + that: |
| 60 | + - snap is changed |
| 61 | + - snap.display_name == cs_resource_prefix + "_snapshot" |
| 62 | + |
| 63 | +- name: test create snapshot idempotence |
| 64 | + ngine_io.cloudstack.instance_snapshot: |
| 65 | + name: "{{ cs_resource_prefix }}_snapshot" |
| 66 | + vm: "{{ cs_resource_prefix }}-vm-snapshot" |
| 67 | + zone: "{{ cs_common_zone_basic }}" |
| 68 | + snapshot_memory: yes |
| 69 | + register: snap |
| 70 | +- name: verify test create snapshot idempotence |
| 71 | + assert: |
| 72 | + that: |
| 73 | + - snap is not changed |
| 74 | + - snap.display_name == cs_resource_prefix + "_snapshot" |
| 75 | + |
| 76 | +- name: test revert snapshot in check mode |
| 77 | + ngine_io.cloudstack.instance_snapshot: |
| 78 | + name: "{{ cs_resource_prefix }}_snapshot" |
| 79 | + vm: "{{ cs_resource_prefix }}-vm-snapshot" |
| 80 | + zone: "{{ cs_common_zone_basic }}" |
| 81 | + state: revert |
| 82 | + register: snap |
| 83 | + check_mode: true |
| 84 | +- name: verify test revert snapshot in check mode |
| 85 | + assert: |
| 86 | + that: |
| 87 | + - snap is changed |
| 88 | + - snap.display_name == cs_resource_prefix + "_snapshot" |
| 89 | + |
| 90 | +- name: test fail revert unknown snapshot |
| 91 | + ngine_io.cloudstack.instance_snapshot: |
| 92 | + name: "{{ cs_resource_prefix }}_snapshot_unknown" |
| 93 | + vm: "{{ cs_resource_prefix }}-vm-snapshot" |
| 94 | + zone: "{{ cs_common_zone_basic }}" |
| 95 | + state: revert |
| 96 | + register: snap |
| 97 | + ignore_errors: true |
| 98 | +- name: verify test fail revert unknown snapshot |
| 99 | + assert: |
| 100 | + that: |
| 101 | + - snap is failed |
| 102 | + - snap.msg == "snapshot not found, could not revert VM" |
| 103 | + |
| 104 | +- name: test revert snapshot |
| 105 | + ngine_io.cloudstack.instance_snapshot: |
| 106 | + name: "{{ cs_resource_prefix }}_snapshot" |
| 107 | + vm: "{{ cs_resource_prefix }}-vm-snapshot" |
| 108 | + zone: "{{ cs_common_zone_basic }}" |
| 109 | + state: revert |
| 110 | + register: snap |
| 111 | +- name: verify test revert snapshot |
| 112 | + assert: |
| 113 | + that: |
| 114 | + - snap is changed |
| 115 | + - snap.display_name == cs_resource_prefix + "_snapshot" |
| 116 | + |
| 117 | +- name: test remove snapshot in check mode |
| 118 | + ngine_io.cloudstack.instance_snapshot: |
| 119 | + name: "{{ cs_resource_prefix }}_snapshot" |
| 120 | + vm: "{{ cs_resource_prefix }}-vm-snapshot" |
| 121 | + zone: "{{ cs_common_zone_basic }}" |
| 122 | + state: absent |
| 123 | + register: snap |
| 124 | + check_mode: true |
| 125 | +- name: verify test remove snapshot in check mode |
| 126 | + assert: |
| 127 | + that: |
| 128 | + - snap is changed |
| 129 | + - snap.display_name == cs_resource_prefix + "_snapshot" |
| 130 | + |
| 131 | +- name: test remove snapshot |
| 132 | + ngine_io.cloudstack.instance_snapshot: |
| 133 | + name: "{{ cs_resource_prefix }}_snapshot" |
| 134 | + vm: "{{ cs_resource_prefix }}-vm-snapshot" |
| 135 | + zone: "{{ cs_common_zone_basic }}" |
| 136 | + state: absent |
| 137 | + register: snap |
| 138 | +- name: verify test remove snapshot |
| 139 | + assert: |
| 140 | + that: |
| 141 | + - snap is changed |
| 142 | + - snap.display_name == cs_resource_prefix + "_snapshot" |
| 143 | + |
| 144 | +- name: test remove snapshot idempotence |
| 145 | + ngine_io.cloudstack.instance_snapshot: |
| 146 | + name: "{{ cs_resource_prefix }}_snapshot" |
| 147 | + vm: "{{ cs_resource_prefix }}-vm-snapshot" |
| 148 | + zone: "{{ cs_common_zone_basic }}" |
| 149 | + state: absent |
| 150 | + register: snap |
| 151 | +- name: verify test remove snapshot idempotence |
| 152 | + assert: |
| 153 | + that: |
| 154 | + - snap is not changed |
| 155 | + |
| 156 | +- name: cleanup instance |
| 157 | + ngine_io.cloudstack.instance: |
| 158 | + name: "{{ cs_resource_prefix }}-vm-snapshot" |
| 159 | + zone: "{{ cs_common_zone_basic }}" |
| 160 | + state: expunged |
| 161 | + register: instance |
| 162 | +- name: verify destroy instance |
| 163 | + assert: |
| 164 | + that: |
| 165 | + - instance is successful |
0 commit comments