|
| 1 | +--- |
| 2 | +- name: ensure instance is expunged |
| 3 | + ngine_io.cloudstack.instance: |
| 4 | + name: "{{ cs_resource_prefix }}-vm-lb" |
| 5 | + zone: "{{ cs_common_zone_adv }}" |
| 6 | + state: expunged |
| 7 | + register: instance |
| 8 | +- name: verify ensure instance is expunged |
| 9 | + assert: |
| 10 | + that: |
| 11 | + - instance is successful |
| 12 | + |
| 13 | +- name: ensure network is absent |
| 14 | + ngine_io.cloudstack.network: |
| 15 | + name: "{{ cs_resource_prefix }}_net_lb" |
| 16 | + zone: "{{ cs_common_zone_adv }}" |
| 17 | + state: absent |
| 18 | + register: lb_net |
| 19 | +- name: verify ensure network is absent |
| 20 | + assert: |
| 21 | + that: |
| 22 | + - lb_net is successful |
| 23 | + |
| 24 | +- name: test create network for lb |
| 25 | + ngine_io.cloudstack.network: |
| 26 | + name: "{{ cs_resource_prefix }}_net_lb" |
| 27 | + zone: "{{ cs_common_zone_adv }}" |
| 28 | + network_offering: Offering for Isolated networks with Source Nat service enabled |
| 29 | + register: lb_net |
| 30 | +- name: verify test create network for lb |
| 31 | + assert: |
| 32 | + that: |
| 33 | + - lb_net is successful |
| 34 | + - lb_net is changed |
| 35 | + - lb_net.name == cs_resource_prefix + "_net_lb" |
| 36 | + |
| 37 | +- name: setup instance in lb |
| 38 | + ngine_io.cloudstack.instance: |
| 39 | + name: "{{ cs_resource_prefix }}-vm-lb" |
| 40 | + template: "{{ cs_common_template }}" |
| 41 | + service_offering: "{{ cs_common_service_offering }}" |
| 42 | + zone: "{{ cs_common_zone_adv }}" |
| 43 | + network: "{{ cs_resource_prefix }}_net_lb" |
| 44 | + register: instance |
| 45 | + until: instance is success |
| 46 | + retries: 20 |
| 47 | + delay: 5 |
| 48 | +- name: verify setup instance in lb |
| 49 | + assert: |
| 50 | + that: |
| 51 | + - instance is successful |
| 52 | + - instance is changed |
| 53 | + - instance.name == cs_resource_prefix + "-vm-lb" |
| 54 | + - instance.state == "Running" |
| 55 | + |
| 56 | +- name: setup get ip address for lb |
| 57 | + ngine_io.cloudstack.ip_address: |
| 58 | + network: "{{ cs_resource_prefix }}_net_lb" |
| 59 | + zone: "{{ cs_common_zone_adv }}" |
| 60 | + register: ip_address |
| 61 | +- name: verify setup get ip address in lb |
| 62 | + assert: |
| 63 | + that: |
| 64 | + - ip_address is successful |
| 65 | + |
| 66 | +- name: setup lb rule absent |
| 67 | + ngine_io.cloudstack.lb_rule: |
| 68 | + name: "{{ cs_resource_prefix }}_lb" |
| 69 | + public_ip: "{{ ip_address.ip_address }}" |
| 70 | + state: absent |
| 71 | + register: lb |
| 72 | +- name: verify setup lb rule absent |
| 73 | + assert: |
| 74 | + that: |
| 75 | + - lb is successful |
| 76 | + |
| 77 | +- name: test rule requires params |
| 78 | + ngine_io.cloudstack.lb_rule: |
| 79 | + ignore_errors: true |
| 80 | + register: lb |
| 81 | +- name: verify test rule requires params |
| 82 | + assert: |
| 83 | + that: |
| 84 | + - lb is failed |
| 85 | + - "lb.msg.startswith('missing required arguments: ')" |
| 86 | + |
| 87 | +- name: test create rule in check mode |
| 88 | + ngine_io.cloudstack.lb_rule: |
| 89 | + name: "{{ cs_resource_prefix }}_lb" |
| 90 | + public_ip: "{{ ip_address.ip_address }}" |
| 91 | + algorithm: roundrobin |
| 92 | + public_port: 80 |
| 93 | + private_port: 8080 |
| 94 | + register: lb |
| 95 | + check_mode: true |
| 96 | +- name: verify test create rule in check mode |
| 97 | + assert: |
| 98 | + that: |
| 99 | + - lb is successful |
| 100 | + - lb is changed |
| 101 | + |
| 102 | +- name: test create rule |
| 103 | + ngine_io.cloudstack.lb_rule: |
| 104 | + name: "{{ cs_resource_prefix }}_lb" |
| 105 | + public_ip: "{{ ip_address.ip_address }}" |
| 106 | + algorithm: roundrobin |
| 107 | + public_port: 80 |
| 108 | + private_port: 8080 |
| 109 | + register: lb |
| 110 | +- name: verify test create rule |
| 111 | + assert: |
| 112 | + that: |
| 113 | + - lb is successful |
| 114 | + - lb is changed |
| 115 | + - lb.name == cs_resource_prefix + "_lb" |
| 116 | + - lb.algorithm == "roundrobin" |
| 117 | + - lb.public_ip == ip_address.ip_address |
| 118 | + - lb.public_port == 80 |
| 119 | + - lb.private_port == 8080 |
| 120 | + |
| 121 | +- name: test create rule idempotence |
| 122 | + ngine_io.cloudstack.lb_rule: |
| 123 | + name: "{{ cs_resource_prefix }}_lb" |
| 124 | + public_ip: "{{ ip_address.ip_address }}" |
| 125 | + algorithm: roundrobin |
| 126 | + public_port: 80 |
| 127 | + private_port: 8080 |
| 128 | + register: lb |
| 129 | +- name: verify test create rule idempotence |
| 130 | + assert: |
| 131 | + that: |
| 132 | + - lb is successful |
| 133 | + - lb is not changed |
| 134 | + - lb.name == cs_resource_prefix + "_lb" |
| 135 | + - lb.algorithm == "roundrobin" |
| 136 | + - lb.public_ip == ip_address.ip_address |
| 137 | + - lb.public_port == 80 |
| 138 | + - lb.private_port == 8080 |
| 139 | + |
| 140 | +- name: test update rule in check mode |
| 141 | + ngine_io.cloudstack.lb_rule: |
| 142 | + name: "{{ cs_resource_prefix }}_lb" |
| 143 | + public_ip: "{{ ip_address.ip_address }}" |
| 144 | + algorithm: source |
| 145 | + public_port: 80 |
| 146 | + private_port: 8080 |
| 147 | + register: lb |
| 148 | + check_mode: true |
| 149 | +- name: verify test update rule in check mode |
| 150 | + assert: |
| 151 | + that: |
| 152 | + - lb is successful |
| 153 | + - lb is changed |
| 154 | + - lb.name == cs_resource_prefix + "_lb" |
| 155 | + - lb.algorithm == "roundrobin" |
| 156 | + - lb.public_ip == ip_address.ip_address |
| 157 | + - lb.public_port == 80 |
| 158 | + - lb.private_port == 8080 |
| 159 | + |
| 160 | +- name: test update rule |
| 161 | + ngine_io.cloudstack.lb_rule: |
| 162 | + name: "{{ cs_resource_prefix }}_lb" |
| 163 | + public_ip: "{{ ip_address.ip_address }}" |
| 164 | + algorithm: source |
| 165 | + public_port: 80 |
| 166 | + private_port: 8080 |
| 167 | + register: lb |
| 168 | +- name: verify test update rule |
| 169 | + assert: |
| 170 | + that: |
| 171 | + - lb is successful |
| 172 | + - lb is changed |
| 173 | + - lb.name == cs_resource_prefix + "_lb" |
| 174 | + - lb.algorithm == "source" |
| 175 | + - lb.public_ip == ip_address.ip_address |
| 176 | + - lb.public_port == 80 |
| 177 | + - lb.private_port == 8080 |
| 178 | + |
| 179 | +- name: test update rule idempotence |
| 180 | + ngine_io.cloudstack.lb_rule: |
| 181 | + name: "{{ cs_resource_prefix }}_lb" |
| 182 | + public_ip: "{{ ip_address.ip_address }}" |
| 183 | + algorithm: source |
| 184 | + public_port: 80 |
| 185 | + private_port: 8080 |
| 186 | + register: lb |
| 187 | +- name: verify test update rule idempotence |
| 188 | + assert: |
| 189 | + that: |
| 190 | + - lb is successful |
| 191 | + - lb is not changed |
| 192 | + - lb.name == cs_resource_prefix + "_lb" |
| 193 | + - lb.algorithm == "source" |
| 194 | + - lb.public_ip == ip_address.ip_address |
| 195 | + - lb.public_port == 80 |
| 196 | + - lb.private_port == 8080 |
| 197 | + |
| 198 | +- name: test rule member requires params |
| 199 | + ngine_io.cloudstack.lb_rule_member: |
| 200 | + ignore_errors: true |
| 201 | + register: lb |
| 202 | +- name: verify test rule requires params |
| 203 | + assert: |
| 204 | + that: |
| 205 | + - lb is failed |
| 206 | + - "lb.msg.startswith('missing required arguments: ')" |
| 207 | + |
| 208 | +- name: test add members to rule in check mode |
| 209 | + ngine_io.cloudstack.lb_rule_member: |
| 210 | + name: "{{ cs_resource_prefix }}_lb" |
| 211 | + vm: "{{ cs_resource_prefix }}-vm-lb" |
| 212 | + register: lb |
| 213 | + check_mode: true |
| 214 | +- name: verify add members to rule in check mode |
| 215 | + assert: |
| 216 | + that: |
| 217 | + - lb is successful |
| 218 | + - lb is changed |
| 219 | + - lb.name == cs_resource_prefix + "_lb" |
| 220 | + - lb.algorithm == "source" |
| 221 | + - lb.public_ip == ip_address.ip_address |
| 222 | + - lb.public_port == 80 |
| 223 | + - lb.private_port == 8080 |
| 224 | + - cs_resource_prefix + "-vm-lb" not in lb.vms |
| 225 | + |
| 226 | +- name: test add members to rule |
| 227 | + ngine_io.cloudstack.lb_rule_member: |
| 228 | + name: "{{ cs_resource_prefix }}_lb" |
| 229 | + vm: "{{ cs_resource_prefix }}-vm-lb" |
| 230 | + register: lb |
| 231 | +- name: verify add members to rule |
| 232 | + assert: |
| 233 | + that: |
| 234 | + - lb is successful |
| 235 | + - lb is changed |
| 236 | + - lb.name == cs_resource_prefix + "_lb" |
| 237 | + - lb.algorithm == "source" |
| 238 | + - lb.public_ip == ip_address.ip_address |
| 239 | + - lb.public_port == 80 |
| 240 | + - lb.private_port == 8080 |
| 241 | + - cs_resource_prefix + "-vm-lb" in lb.vms |
| 242 | + |
| 243 | +- name: test add members to rule idempotence |
| 244 | + ngine_io.cloudstack.lb_rule_member: |
| 245 | + name: "{{ cs_resource_prefix }}_lb" |
| 246 | + vm: "{{ cs_resource_prefix }}-vm-lb" |
| 247 | + register: lb |
| 248 | +- name: verify add members to rule idempotence |
| 249 | + assert: |
| 250 | + that: |
| 251 | + - lb is successful |
| 252 | + - lb is not changed |
| 253 | + - lb.name == cs_resource_prefix + "_lb" |
| 254 | + - lb.algorithm == "source" |
| 255 | + - lb.public_ip == ip_address.ip_address |
| 256 | + - lb.public_port == 80 |
| 257 | + - lb.private_port == 8080 |
| 258 | + - cs_resource_prefix + "-vm-lb" in lb.vms |
| 259 | + |
| 260 | +- name: test remove members to rule in check mode |
| 261 | + ngine_io.cloudstack.lb_rule_member: |
| 262 | + name: "{{ cs_resource_prefix }}_lb" |
| 263 | + vm: "{{ cs_resource_prefix }}-vm-lb" |
| 264 | + state: absent |
| 265 | + register: lb |
| 266 | + check_mode: true |
| 267 | +- name: verify remove members to rule in check mode |
| 268 | + assert: |
| 269 | + that: |
| 270 | + - lb is successful |
| 271 | + - lb is changed |
| 272 | + - lb.name == cs_resource_prefix + "_lb" |
| 273 | + - lb.algorithm == "source" |
| 274 | + - lb.public_ip == ip_address.ip_address |
| 275 | + - lb.public_port == 80 |
| 276 | + - lb.private_port == 8080 |
| 277 | + - cs_resource_prefix + "-vm-lb" in lb.vms |
| 278 | + |
| 279 | +- name: test remove members to rule |
| 280 | + ngine_io.cloudstack.lb_rule_member: |
| 281 | + name: "{{ cs_resource_prefix }}_lb" |
| 282 | + vm: "{{ cs_resource_prefix }}-vm-lb" |
| 283 | + state: absent |
| 284 | + register: lb |
| 285 | +- name: verify remove members to rule |
| 286 | + assert: |
| 287 | + that: |
| 288 | + - lb is successful |
| 289 | + - lb is changed |
| 290 | + - lb.name == cs_resource_prefix + "_lb" |
| 291 | + - lb.algorithm == "source" |
| 292 | + - lb.public_ip == ip_address.ip_address |
| 293 | + - lb.public_port == 80 |
| 294 | + - lb.private_port == 8080 |
| 295 | + - cs_resource_prefix + "-vm-lb" not in lb.vms |
| 296 | + |
| 297 | +- name: test remove members to rule idempotence |
| 298 | + ngine_io.cloudstack.lb_rule_member: |
| 299 | + name: "{{ cs_resource_prefix }}_lb" |
| 300 | + vm: "{{ cs_resource_prefix }}-vm-lb" |
| 301 | + state: absent |
| 302 | + register: lb |
| 303 | +- name: verify remove members to rule |
| 304 | + assert: |
| 305 | + that: |
| 306 | + - lb is successful |
| 307 | + - lb is not changed |
| 308 | + |
| 309 | +- name: test remove rule in check mode |
| 310 | + ngine_io.cloudstack.lb_rule: |
| 311 | + name: "{{ cs_resource_prefix }}_lb" |
| 312 | + public_ip: "{{ ip_address.ip_address }}" |
| 313 | + state: absent |
| 314 | + register: lb |
| 315 | + check_mode: true |
| 316 | +- name: verify remove rule in check mode |
| 317 | + assert: |
| 318 | + that: |
| 319 | + - lb is successful |
| 320 | + - lb is changed |
| 321 | + - lb.name == cs_resource_prefix + "_lb" |
| 322 | + - lb.algorithm == "source" |
| 323 | + - lb.public_ip == ip_address.ip_address |
| 324 | + - lb.public_port == 80 |
| 325 | + - lb.private_port == 8080 |
| 326 | + |
| 327 | +- name: test remove rule |
| 328 | + ngine_io.cloudstack.lb_rule: |
| 329 | + name: "{{ cs_resource_prefix }}_lb" |
| 330 | + public_ip: "{{ ip_address.ip_address }}" |
| 331 | + state: absent |
| 332 | + register: lb |
| 333 | +- name: verify remove rule |
| 334 | + assert: |
| 335 | + that: |
| 336 | + - lb is successful |
| 337 | + - lb is changed |
| 338 | + - lb.name == cs_resource_prefix + "_lb" |
| 339 | + - lb.algorithm == "source" |
| 340 | + - lb.public_ip == ip_address.ip_address |
| 341 | + - lb.public_port == 80 |
| 342 | + - lb.private_port == 8080 |
| 343 | + |
| 344 | +- name: test remove rule idempotence |
| 345 | + ngine_io.cloudstack.lb_rule: |
| 346 | + name: "{{ cs_resource_prefix }}_lb" |
| 347 | + public_ip: "{{ ip_address.ip_address }}" |
| 348 | + state: absent |
| 349 | + register: lb |
| 350 | +- name: verify remove rule idempotence |
| 351 | + assert: |
| 352 | + that: |
| 353 | + - lb is successful |
| 354 | + - lb is not changed |
| 355 | + |
| 356 | +- name: cleanup ip address |
| 357 | + ngine_io.cloudstack.ip_address: |
| 358 | + network: "{{ cs_resource_prefix }}_net_lb" |
| 359 | + zone: "{{ cs_common_zone_adv }}" |
| 360 | + ip_address: "{{ ip_address.ip_address }}" |
| 361 | + state: absent |
| 362 | + register: ip_address |
| 363 | +- name: verify cleanup ip address |
| 364 | + assert: |
| 365 | + that: |
| 366 | + - ip_address is successful |
| 367 | + - instance is changed |
| 368 | + |
| 369 | +- name: cleanup instance |
| 370 | + ngine_io.cloudstack.instance: |
| 371 | + name: "{{ cs_resource_prefix }}-vm-lb" |
| 372 | + zone: "{{ cs_common_zone_adv }}" |
| 373 | + state: expunged |
| 374 | + register: instance |
| 375 | +- name: verify cleanup instance |
| 376 | + assert: |
| 377 | + that: |
| 378 | + - instance is successful |
| 379 | + - instance is changed |
| 380 | + |
| 381 | +- name: cleanup network |
| 382 | + ngine_io.cloudstack.network: |
| 383 | + name: "{{ cs_resource_prefix }}_net_lb" |
| 384 | + zone: "{{ cs_common_zone_adv }}" |
| 385 | + state: absent |
| 386 | + register: lb_net |
| 387 | +- name: verify cleanup network |
| 388 | + assert: |
| 389 | + that: |
| 390 | + - lb_net is successful |
| 391 | + - lb_net is changed |
0 commit comments