|
| 1 | +--- |
| 2 | +- name: setup network |
| 3 | + ngine_io.cloudstack.network: |
| 4 | + name: "net_nic" |
| 5 | + zone: "{{ cs_common_zone_adv }}" |
| 6 | + network_offering: DefaultSharedNetworkOffering |
| 7 | + network_domain: example.com |
| 8 | + vlan: 1234 |
| 9 | + start_ip: 10.100.123.11 |
| 10 | + end_ip: 10.100.123.250 |
| 11 | + gateway: 10.100.123.1 |
| 12 | + netmask: 255.255.255.0 |
| 13 | + register: net |
| 14 | +- name: verify setup network |
| 15 | + assert: |
| 16 | + that: |
| 17 | + - net is successful |
| 18 | + - net.name == "net_nic" |
| 19 | + |
| 20 | +- name: setup instance |
| 21 | + ngine_io.cloudstack.instance: |
| 22 | + name: "instance-nic-vm" |
| 23 | + template: "{{ cs_common_template }}" |
| 24 | + service_offering: "{{ cs_common_service_offering }}" |
| 25 | + zone: "{{ cs_common_zone_adv }}" |
| 26 | + network: "net_nic" |
| 27 | + state: stopped |
| 28 | + register: instance |
| 29 | +- name: verify setup instance |
| 30 | + assert: |
| 31 | + that: |
| 32 | + - instance is successful |
| 33 | + - instance.name == "instance-nic-vm" |
| 34 | + - instance.state == "Stopped" |
| 35 | + |
| 36 | +- name: setup network 2 |
| 37 | + ngine_io.cloudstack.network: |
| 38 | + name: "net_nic2" |
| 39 | + zone: "{{ cs_common_zone_adv }}" |
| 40 | + network_offering: DefaultSharedNetworkOffering |
| 41 | + network_domain: example.com |
| 42 | + vlan: 1235 |
| 43 | + start_ip: 10.100.124.11 |
| 44 | + end_ip: 10.100.124.250 |
| 45 | + gateway: 10.100.124.1 |
| 46 | + netmask: 255.255.255.0 |
| 47 | + register: net |
| 48 | +- name: verify setup network 2 |
| 49 | + assert: |
| 50 | + that: |
| 51 | + - net is successful |
| 52 | + - net.name == "net_nic2" |
| 53 | + |
| 54 | +- name: setup absent nic |
| 55 | + ngine_io.cloudstack.instance_nic: |
| 56 | + vm: "instance-nic-vm" |
| 57 | + network: "net_nic2" |
| 58 | + zone: "{{ cs_common_zone_adv }}" |
| 59 | + state: absent |
| 60 | + register: nic |
| 61 | +- name: verify setup absent nic |
| 62 | + assert: |
| 63 | + that: |
| 64 | + - nic is successful |
| 65 | + |
| 66 | +- name: test fail missing params |
| 67 | + ngine_io.cloudstack.instance_nic: |
| 68 | + ignore_errors: true |
| 69 | + register: nic |
| 70 | +- name: verify test fail missing params |
| 71 | + assert: |
| 72 | + that: |
| 73 | + - nic is failed |
| 74 | + - "nic.msg.startswith('missing required arguments: ')" |
| 75 | + |
| 76 | +- name: test create nic in check mode |
| 77 | + ngine_io.cloudstack.instance_nic: |
| 78 | + vm: "instance-nic-vm" |
| 79 | + network: "net_nic2" |
| 80 | + zone: "{{ cs_common_zone_adv }}" |
| 81 | + check_mode: yes |
| 82 | + register: nic |
| 83 | +- name: verify test create nic in check mode |
| 84 | + assert: |
| 85 | + that: |
| 86 | + - nic is successful |
| 87 | + - nic is changed |
| 88 | + - nic.network == "net_nic2" |
| 89 | + - nic.vm == "instance-nic-vm" |
| 90 | + - nic.zone == cs_common_zone_adv |
| 91 | + |
| 92 | +- name: test create nic |
| 93 | + ngine_io.cloudstack.instance_nic: |
| 94 | + vm: "instance-nic-vm" |
| 95 | + network: "net_nic2" |
| 96 | + ip_address: 10.100.124.42 |
| 97 | + zone: "{{ cs_common_zone_adv }}" |
| 98 | + register: nic |
| 99 | +- name: verify test create nic |
| 100 | + assert: |
| 101 | + that: |
| 102 | + - nic is successful |
| 103 | + - nic is changed |
| 104 | + - nic.ip_address == "10.100.124.42" |
| 105 | + - nic.netmask == "255.255.255.0" |
| 106 | + - nic.network == "net_nic2" |
| 107 | + - nic.vm == "instance-nic-vm" |
| 108 | + - nic.zone == cs_common_zone_adv |
| 109 | + - nic.mac_address is defined |
| 110 | + |
| 111 | +- name: test create nic idempotence |
| 112 | + ngine_io.cloudstack.instance_nic: |
| 113 | + vm: "instance-nic-vm" |
| 114 | + network: "net_nic2" |
| 115 | + ip_address: 10.100.124.42 |
| 116 | + zone: "{{ cs_common_zone_adv }}" |
| 117 | + register: nic |
| 118 | +- name: verify test create nic idempotence |
| 119 | + assert: |
| 120 | + that: |
| 121 | + - nic is successful |
| 122 | + - nic is not changed |
| 123 | + - nic.ip_address == "10.100.124.42" |
| 124 | + - nic.netmask == "255.255.255.0" |
| 125 | + - nic.network == "net_nic2" |
| 126 | + - nic.vm == "instance-nic-vm" |
| 127 | + - nic.zone == cs_common_zone_adv |
| 128 | + - nic.mac_address is defined |
| 129 | + |
| 130 | +- name: test create nic without ip address idempotence |
| 131 | + ngine_io.cloudstack.instance_nic: |
| 132 | + vm: "instance-nic-vm" |
| 133 | + network: "net_nic2" |
| 134 | + zone: "{{ cs_common_zone_adv }}" |
| 135 | + register: nic |
| 136 | +- name: verify test create nic without ip address idempotence |
| 137 | + assert: |
| 138 | + that: |
| 139 | + - nic is successful |
| 140 | + - nic is not changed |
| 141 | + - nic.ip_address == "10.100.124.42" |
| 142 | + - nic.netmask == "255.255.255.0" |
| 143 | + - nic.network == "net_nic2" |
| 144 | + - nic.vm == "instance-nic-vm" |
| 145 | + - nic.zone == cs_common_zone_adv |
| 146 | + - nic.mac_address is defined |
| 147 | + |
| 148 | +- name: test update nic in check mode |
| 149 | + ngine_io.cloudstack.instance_nic: |
| 150 | + vm: "instance-nic-vm" |
| 151 | + network: "net_nic2" |
| 152 | + ip_address: 10.100.124.23 |
| 153 | + zone: "{{ cs_common_zone_adv }}" |
| 154 | + check_mode: yes |
| 155 | + register: nic |
| 156 | +- name: verify test update nic in check mode |
| 157 | + assert: |
| 158 | + that: |
| 159 | + - nic is successful |
| 160 | + - nic is changed |
| 161 | + - nic.ip_address == "10.100.124.42" |
| 162 | + - nic.netmask == "255.255.255.0" |
| 163 | + - nic.network == "net_nic2" |
| 164 | + - nic.vm == "instance-nic-vm" |
| 165 | + - nic.zone == cs_common_zone_adv |
| 166 | + - nic.mac_address is defined |
| 167 | + |
| 168 | +- name: test update nic |
| 169 | + ngine_io.cloudstack.instance_nic: |
| 170 | + vm: "instance-nic-vm" |
| 171 | + network: "net_nic2" |
| 172 | + ip_address: 10.100.124.23 |
| 173 | + zone: "{{ cs_common_zone_adv }}" |
| 174 | + register: nic |
| 175 | +- name: verify test update nic |
| 176 | + assert: |
| 177 | + that: |
| 178 | + - nic is successful |
| 179 | + - nic is changed |
| 180 | + - nic.ip_address == "10.100.124.23" |
| 181 | + - nic.netmask == "255.255.255.0" |
| 182 | + - nic.network == "net_nic2" |
| 183 | + - nic.vm == "instance-nic-vm" |
| 184 | + - nic.zone == cs_common_zone_adv |
| 185 | + - nic.mac_address is defined |
| 186 | + |
| 187 | +- name: test update nic idempotence |
| 188 | + ngine_io.cloudstack.instance_nic: |
| 189 | + vm: "instance-nic-vm" |
| 190 | + network: "net_nic2" |
| 191 | + ip_address: 10.100.124.23 |
| 192 | + zone: "{{ cs_common_zone_adv }}" |
| 193 | + register: nic |
| 194 | +- name: verify test update nic idempotence |
| 195 | + assert: |
| 196 | + that: |
| 197 | + - nic is successful |
| 198 | + - nic is not changed |
| 199 | + - nic.ip_address == "10.100.124.23" |
| 200 | + - nic.netmask == "255.255.255.0" |
| 201 | + - nic.network == "net_nic2" |
| 202 | + - nic.vm == "instance-nic-vm" |
| 203 | + - nic.zone == cs_common_zone_adv |
| 204 | + - nic.mac_address is defined |
| 205 | + |
| 206 | +- name: test update nic without ip address idempotence |
| 207 | + ngine_io.cloudstack.instance_nic: |
| 208 | + vm: "instance-nic-vm" |
| 209 | + network: "net_nic2" |
| 210 | + zone: "{{ cs_common_zone_adv }}" |
| 211 | + register: nic |
| 212 | +- name: verify test update nic without ip address idempotence |
| 213 | + assert: |
| 214 | + that: |
| 215 | + - nic is successful |
| 216 | + - nic is not changed |
| 217 | + - nic.ip_address == "10.100.124.23" |
| 218 | + - nic.netmask == "255.255.255.0" |
| 219 | + - nic.network == "net_nic2" |
| 220 | + - nic.vm == "instance-nic-vm" |
| 221 | + - nic.zone == cs_common_zone_adv |
| 222 | + - nic.mac_address is defined |
| 223 | + |
| 224 | +- name: test remove nic in check mode |
| 225 | + ngine_io.cloudstack.instance_nic: |
| 226 | + vm: "instance-nic-vm" |
| 227 | + network: "net_nic2" |
| 228 | + zone: "{{ cs_common_zone_adv }}" |
| 229 | + state: absent |
| 230 | + check_mode: yes |
| 231 | + register: nic |
| 232 | +- name: verify test remove nic in check mode |
| 233 | + assert: |
| 234 | + that: |
| 235 | + - nic is successful |
| 236 | + - nic is changed |
| 237 | + - nic.ip_address == "10.100.124.23" |
| 238 | + - nic.netmask == "255.255.255.0" |
| 239 | + - nic.network == "net_nic2" |
| 240 | + - nic.vm == "instance-nic-vm" |
| 241 | + - nic.zone == cs_common_zone_adv |
| 242 | + - nic.mac_address is defined |
| 243 | + |
| 244 | +- name: test remove nic |
| 245 | + ngine_io.cloudstack.instance_nic: |
| 246 | + vm: "instance-nic-vm" |
| 247 | + network: "net_nic2" |
| 248 | + zone: "{{ cs_common_zone_adv }}" |
| 249 | + state: absent |
| 250 | + register: nic |
| 251 | +- name: verify test remove nic |
| 252 | + assert: |
| 253 | + that: |
| 254 | + - nic is successful |
| 255 | + - nic is changed |
| 256 | + - nic.ip_address == "10.100.124.23" |
| 257 | + - nic.netmask == "255.255.255.0" |
| 258 | + - nic.network == "net_nic2" |
| 259 | + - nic.vm == "instance-nic-vm" |
| 260 | + - nic.zone == cs_common_zone_adv |
| 261 | + - nic.mac_address is defined |
| 262 | + |
| 263 | +- name: test remove nic idempotence |
| 264 | + ngine_io.cloudstack.instance_nic: |
| 265 | + vm: "instance-nic-vm" |
| 266 | + network: "net_nic2" |
| 267 | + zone: "{{ cs_common_zone_adv }}" |
| 268 | + state: absent |
| 269 | + register: nic |
| 270 | +- name: verify test remove nic idempotence |
| 271 | + assert: |
| 272 | + that: |
| 273 | + - nic is successful |
| 274 | + - nic is not changed |
| 275 | + |
| 276 | +- name: cleanup instance |
| 277 | + ngine_io.cloudstack.instance: |
| 278 | + name: "instance-nic-vm" |
| 279 | + zone: "{{ cs_common_zone_adv }}" |
| 280 | + state: expunged |
| 281 | + register: instance |
| 282 | +- name: verify cleanup instance |
| 283 | + assert: |
| 284 | + that: |
| 285 | + - instance is successful |
| 286 | + |
| 287 | +- name: cleanup network |
| 288 | + ngine_io.cloudstack.network: |
| 289 | + name: "net_nic" |
| 290 | + zone: "{{ cs_common_zone_adv }}" |
| 291 | + state: absent |
| 292 | + register: net |
| 293 | +- name: verify cleanup network |
| 294 | + assert: |
| 295 | + that: |
| 296 | + - net is successful |
| 297 | + |
| 298 | +- name: cleanup network 2 |
| 299 | + ngine_io.cloudstack.network: |
| 300 | + name: "net_nic2" |
| 301 | + zone: "{{ cs_common_zone_adv }}" |
| 302 | + state: absent |
| 303 | + register: net |
| 304 | +- name: verify cleanup network 2 |
| 305 | + assert: |
| 306 | + that: |
| 307 | + - net is successful |
0 commit comments