|
| 1 | +--- |
| 2 | +- name: setup ensure the test network is absent |
| 3 | + ngine_io.cloudstack.network: |
| 4 | + name: ipaddr_test_network |
| 5 | + state: absent |
| 6 | + zone: "{{ cs_common_zone_adv }}" |
| 7 | + |
| 8 | +- name: setup create the test network |
| 9 | + ngine_io.cloudstack.network: |
| 10 | + name: ipaddr_test_network |
| 11 | + network_offering: DefaultIsolatedNetworkOfferingWithSourceNatService |
| 12 | + state: present |
| 13 | + zone: "{{ cs_common_zone_adv }}" |
| 14 | + register: base_network |
| 15 | +- name: setup verify create the test network |
| 16 | + assert: |
| 17 | + that: |
| 18 | + - base_network is successful |
| 19 | + |
| 20 | +- name: setup instance to get network in implementation state |
| 21 | + ngine_io.cloudstack.instance: |
| 22 | + name: "{{ cs_resource_prefix }}-vm-cs-ip-address" |
| 23 | + template: "{{ cs_common_template }}" |
| 24 | + service_offering: "{{ cs_common_service_offering }}" |
| 25 | + zone: "{{ cs_common_zone_adv }}" |
| 26 | + networks: |
| 27 | + - "{{ base_network.name }}" |
| 28 | + register: instance |
| 29 | + until: instance is success |
| 30 | + retries: 20 |
| 31 | + delay: 5 |
| 32 | +- name: verify instance setup |
| 33 | + assert: |
| 34 | + that: |
| 35 | + - instance is successful |
| 36 | + |
| 37 | +- name: setup clean ip_address with tags |
| 38 | + ngine_io.cloudstack.ip_address: |
| 39 | + state: absent |
| 40 | + tags: |
| 41 | + - key: unique_id |
| 42 | + value: "adacd65e-7868-5ebf-9f8b-e6e0ea779861" |
| 43 | + network: ipaddr_test_network |
| 44 | + zone: "{{ cs_common_zone_adv }}" |
| 45 | + |
| 46 | +- name: setup associate ip_address for SNAT |
| 47 | + ngine_io.cloudstack.ip_address: |
| 48 | + network: ipaddr_test_network |
| 49 | + zone: "{{ cs_common_zone_adv }}" |
| 50 | + register: ip_address_snat |
| 51 | + |
| 52 | +- name: test associate ip_address in check mode |
| 53 | + ngine_io.cloudstack.ip_address: |
| 54 | + network: ipaddr_test_network |
| 55 | + zone: "{{ cs_common_zone_adv }}" |
| 56 | + check_mode: true |
| 57 | + register: ip_address |
| 58 | +- name: verify test associate ip_address in check mode |
| 59 | + assert: |
| 60 | + that: |
| 61 | + - ip_address is successful |
| 62 | + - ip_address is changed |
| 63 | + |
| 64 | +- name: test associate ip_address |
| 65 | + ngine_io.cloudstack.ip_address: |
| 66 | + network: ipaddr_test_network |
| 67 | + zone: "{{ cs_common_zone_adv }}" |
| 68 | + register: ip_address |
| 69 | +- name: verify test associate ip_address |
| 70 | + assert: |
| 71 | + that: |
| 72 | + - ip_address is successful |
| 73 | + - ip_address is changed |
| 74 | + - ip_address.ip_address is defined |
| 75 | + |
| 76 | +- name: test associate ip_address with tags in check mode |
| 77 | + ngine_io.cloudstack.ip_address: |
| 78 | + network: ipaddr_test_network |
| 79 | + tags: |
| 80 | + - key: unique_id |
| 81 | + value: "adacd65e-7868-5ebf-9f8b-e6e0ea779861" |
| 82 | + zone: "{{ cs_common_zone_adv }}" |
| 83 | + register: ip_address_tag |
| 84 | + check_mode: true |
| 85 | +- name: verify test associate ip_address with tags in check mode |
| 86 | + assert: |
| 87 | + that: |
| 88 | + - ip_address_tag is successful |
| 89 | + - ip_address_tag is changed |
| 90 | + |
| 91 | +- name: test associate ip_address with tags |
| 92 | + ngine_io.cloudstack.ip_address: |
| 93 | + network: ipaddr_test_network |
| 94 | + tags: |
| 95 | + - key: unique_id |
| 96 | + value: "adacd65e-7868-5ebf-9f8b-e6e0ea779861" |
| 97 | + zone: "{{ cs_common_zone_adv }}" |
| 98 | + register: ip_address_tag |
| 99 | +- name: verify test associate ip_address with tags |
| 100 | + assert: |
| 101 | + that: |
| 102 | + - ip_address_tag is successful |
| 103 | + - ip_address_tag is changed |
| 104 | + - ip_address_tag.ip_address is defined |
| 105 | + - ip_address_tag.tags.0.key == "unique_id" |
| 106 | + - ip_address_tag.tags.0.value == "adacd65e-7868-5ebf-9f8b-e6e0ea779861" |
| 107 | + |
| 108 | +- name: test associate ip_address with tags idempotence |
| 109 | + ngine_io.cloudstack.ip_address: |
| 110 | + network: ipaddr_test_network |
| 111 | + tags: |
| 112 | + - key: unique_id |
| 113 | + value: "adacd65e-7868-5ebf-9f8b-e6e0ea779861" |
| 114 | + zone: "{{ cs_common_zone_adv }}" |
| 115 | + register: ip_address_tag |
| 116 | +- name: verify test associate ip_address with tags idempotence |
| 117 | + assert: |
| 118 | + that: |
| 119 | + - ip_address_tag is successful |
| 120 | + - ip_address_tag is not changed |
| 121 | + - ip_address_tag.ip_address is defined |
| 122 | + - ip_address_tag.state == "Allocated" |
| 123 | + - ip_address_tag.tags.0.key == "unique_id" |
| 124 | + - ip_address_tag.tags.0.value == "adacd65e-7868-5ebf-9f8b-e6e0ea779861" |
| 125 | + |
| 126 | +- name: test disassiociate ip_address with missing param ip_address |
| 127 | + ngine_io.cloudstack.ip_address: |
| 128 | + state: absent |
| 129 | + network: ipaddr_test_network |
| 130 | + zone: "{{ cs_common_zone_adv }}" |
| 131 | + ignore_errors: true |
| 132 | + register: ip_address_err |
| 133 | +- name: verify test disassiociate ip_address with missing param ip_address |
| 134 | + assert: |
| 135 | + that: |
| 136 | + - ip_address_err is failed |
| 137 | + - 'ip_address_err.msg == "state is absent but any of the following are missing: ip_address, tags"' |
| 138 | + |
| 139 | +- name: test disassociate ip_address in check mode |
| 140 | + ngine_io.cloudstack.ip_address: |
| 141 | + state: absent |
| 142 | + ip_address: "{{ ip_address.ip_address }}" |
| 143 | + network: ipaddr_test_network |
| 144 | + zone: "{{ cs_common_zone_adv }}" |
| 145 | + check_mode: true |
| 146 | + register: ip_address |
| 147 | +- name: verify test disassociate ip_address in check mode |
| 148 | + assert: |
| 149 | + that: |
| 150 | + - ip_address is successful |
| 151 | + - ip_address is changed |
| 152 | + |
| 153 | +- name: test disassociate ip_address |
| 154 | + ngine_io.cloudstack.ip_address: |
| 155 | + state: absent |
| 156 | + ip_address: "{{ ip_address.ip_address }}" |
| 157 | + network: ipaddr_test_network |
| 158 | + zone: "{{ cs_common_zone_adv }}" |
| 159 | + register: ip_address |
| 160 | +- name: verify test disassociate ip_address |
| 161 | + assert: |
| 162 | + that: |
| 163 | + - ip_address is successful |
| 164 | + - ip_address is changed |
| 165 | + |
| 166 | +- name: test disassociate ip_address idempotence |
| 167 | + ngine_io.cloudstack.ip_address: |
| 168 | + state: absent |
| 169 | + ip_address: "{{ ip_address.ip_address }}" |
| 170 | + network: ipaddr_test_network |
| 171 | + zone: "{{ cs_common_zone_adv }}" |
| 172 | + register: ip_address |
| 173 | +- name: verify test disassociate ip_address idempotence |
| 174 | + assert: |
| 175 | + that: |
| 176 | + - ip_address is successful |
| 177 | + - ip_address is not changed |
| 178 | + |
| 179 | +- name: test disassociate ip_address with tags with check mode |
| 180 | + ngine_io.cloudstack.ip_address: |
| 181 | + state: absent |
| 182 | + tags: |
| 183 | + - key: unique_id |
| 184 | + value: "adacd65e-7868-5ebf-9f8b-e6e0ea779861" |
| 185 | + network: ipaddr_test_network |
| 186 | + zone: "{{ cs_common_zone_adv }}" |
| 187 | + check_mode: true |
| 188 | + register: ip_address |
| 189 | +- name: verify test disassociate ip_address with tags in check mode |
| 190 | + assert: |
| 191 | + that: |
| 192 | + - ip_address is successful |
| 193 | + - ip_address is changed |
| 194 | + |
| 195 | +- name: test disassociate ip_address with tags |
| 196 | + ngine_io.cloudstack.ip_address: |
| 197 | + state: absent |
| 198 | + tags: |
| 199 | + - key: unique_id |
| 200 | + value: "adacd65e-7868-5ebf-9f8b-e6e0ea779861" |
| 201 | + network: ipaddr_test_network |
| 202 | + zone: "{{ cs_common_zone_adv }}" |
| 203 | + register: ip_address |
| 204 | +- name: verify test disassociate ip_address with tags |
| 205 | + assert: |
| 206 | + that: |
| 207 | + - ip_address is successful |
| 208 | + - ip_address is changed |
| 209 | + |
| 210 | +- name: test disassociate ip_address with tags idempotence |
| 211 | + ngine_io.cloudstack.ip_address: |
| 212 | + state: absent |
| 213 | + tags: |
| 214 | + - key: unique_id |
| 215 | + value: "adacd65e-7868-5ebf-9f8b-e6e0ea779861" |
| 216 | + network: ipaddr_test_network |
| 217 | + zone: "{{ cs_common_zone_adv }}" |
| 218 | + register: ip_address |
| 219 | +- name: verify test disassociate ip_address with tags idempotence |
| 220 | + assert: |
| 221 | + that: |
| 222 | + - ip_address is successful |
| 223 | + - ip_address is not changed |
| 224 | + |
| 225 | +- name: cleanup instance |
| 226 | + ngine_io.cloudstack.instance: |
| 227 | + name: "{{ cs_resource_prefix }}-vm-cs-ip-address" |
| 228 | + zone: "{{ cs_common_zone_adv }}" |
| 229 | + state: expunged |
| 230 | + register: instance |
| 231 | +- name: verify instance cleanup |
| 232 | + assert: |
| 233 | + that: |
| 234 | + - instance is successful |
| 235 | + |
| 236 | +- name: clean the test network |
| 237 | + ngine_io.cloudstack.network: |
| 238 | + name: ipaddr_test_network |
| 239 | + state: absent |
| 240 | + zone: "{{ cs_common_zone_adv }}" |
0 commit comments