|
| 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 nic |
| 55 | + ngine_io.cloudstack.instance_nic: |
| 56 | + vm: "instance-nic-vm" |
| 57 | + network: "net_nic2" |
| 58 | + ip_address: 10.100.124.42 |
| 59 | + zone: "{{ cs_common_zone_adv }}" |
| 60 | + register: nic |
| 61 | +- name: verify test create nic |
| 62 | + assert: |
| 63 | + that: |
| 64 | + - nic is successful |
| 65 | + - nic.ip_address == "10.100.124.42" |
| 66 | + - nic.netmask == "255.255.255.0" |
| 67 | + - nic.network == "net_nic2" |
| 68 | + - nic.vm == "instance-nic-vm" |
| 69 | + - nic.zone == cs_common_zone_adv |
| 70 | + - nic.mac_address is defined |
| 71 | + |
| 72 | +- name: setup remove secondary ip |
| 73 | + ngine_io.cloudstack.instance_nic_secondaryip: |
| 74 | + vm: "instance-nic-vm" |
| 75 | + network: "net_nic2" |
| 76 | + vm_guest_ip: 10.100.124.43 |
| 77 | + zone: "{{ cs_common_zone_adv }}" |
| 78 | + state: absent |
| 79 | + register: sip |
| 80 | +- name: verify setup remove secondary ip |
| 81 | + assert: |
| 82 | + that: |
| 83 | + - sip is successful |
| 84 | + |
| 85 | +- name: test add secondary ip in check mode |
| 86 | + ngine_io.cloudstack.instance_nic_secondaryip: |
| 87 | + vm: "instance-nic-vm" |
| 88 | + network: "net_nic2" |
| 89 | + vm_guest_ip: 10.100.124.43 |
| 90 | + zone: "{{ cs_common_zone_adv }}" |
| 91 | + check_mode: true |
| 92 | + register: sip |
| 93 | +- name: verify test add secondary ip in check mode |
| 94 | + assert: |
| 95 | + that: |
| 96 | + - sip is successful |
| 97 | + - sip is changed |
| 98 | + - sip.network == "net_nic2" |
| 99 | + - sip.vm == "instance-nic-vm" |
| 100 | + - sip.zone == cs_common_zone_adv |
| 101 | + |
| 102 | +- name: test add secondary ip |
| 103 | + ngine_io.cloudstack.instance_nic_secondaryip: |
| 104 | + vm: "instance-nic-vm" |
| 105 | + network: "net_nic2" |
| 106 | + vm_guest_ip: 10.100.124.43 |
| 107 | + zone: "{{ cs_common_zone_adv }}" |
| 108 | + register: sip |
| 109 | +- name: verify test add secondary ip |
| 110 | + assert: |
| 111 | + that: |
| 112 | + - sip is successful |
| 113 | + - sip is changed |
| 114 | + - sip.vm_guest_ip == "10.100.124.43" |
| 115 | + - sip.network == "net_nic2" |
| 116 | + - sip.vm == "instance-nic-vm" |
| 117 | + - sip.zone == cs_common_zone_adv |
| 118 | + |
| 119 | +- name: test add secondary ip idempotence |
| 120 | + ngine_io.cloudstack.instance_nic_secondaryip: |
| 121 | + vm: "instance-nic-vm" |
| 122 | + network: "net_nic2" |
| 123 | + vm_guest_ip: 10.100.124.43 |
| 124 | + zone: "{{ cs_common_zone_adv }}" |
| 125 | + register: sip |
| 126 | +- name: verify test add secondary ip idempotence |
| 127 | + assert: |
| 128 | + that: |
| 129 | + - sip is successful |
| 130 | + - sip is not changed |
| 131 | + - sip.vm_guest_ip == "10.100.124.43" |
| 132 | + - sip.network == "net_nic2" |
| 133 | + - sip.vm == "instance-nic-vm" |
| 134 | + - sip.zone == cs_common_zone_adv |
| 135 | + |
| 136 | +- name: test remove secondary ip in check mode |
| 137 | + ngine_io.cloudstack.instance_nic_secondaryip: |
| 138 | + vm: "instance-nic-vm" |
| 139 | + network: "net_nic2" |
| 140 | + vm_guest_ip: 10.100.124.43 |
| 141 | + zone: "{{ cs_common_zone_adv }}" |
| 142 | + state: absent |
| 143 | + check_mode: true |
| 144 | + register: sip |
| 145 | +- name: verify test remove secondary ip in check mode |
| 146 | + assert: |
| 147 | + that: |
| 148 | + - sip is successful |
| 149 | + - sip is changed |
| 150 | + - sip.vm_guest_ip == "10.100.124.43" |
| 151 | + - sip.network == "net_nic2" |
| 152 | + - sip.vm == "instance-nic-vm" |
| 153 | + - sip.zone == cs_common_zone_adv |
| 154 | + |
| 155 | +- name: test remove secondary ip |
| 156 | + ngine_io.cloudstack.instance_nic_secondaryip: |
| 157 | + vm: "instance-nic-vm" |
| 158 | + network: "net_nic2" |
| 159 | + vm_guest_ip: 10.100.124.43 |
| 160 | + zone: "{{ cs_common_zone_adv }}" |
| 161 | + state: absent |
| 162 | + register: sip |
| 163 | +- name: verify test remove secondary ip |
| 164 | + assert: |
| 165 | + that: |
| 166 | + - sip is successful |
| 167 | + - sip is changed |
| 168 | + - sip.vm_guest_ip == "10.100.124.43" |
| 169 | + - sip.network == "net_nic2" |
| 170 | + - sip.vm == "instance-nic-vm" |
| 171 | + - sip.zone == cs_common_zone_adv |
| 172 | + |
| 173 | +- name: test remove secondary ip idempotence |
| 174 | + ngine_io.cloudstack.instance_nic_secondaryip: |
| 175 | + vm: "instance-nic-vm" |
| 176 | + network: "net_nic2" |
| 177 | + vm_guest_ip: 10.100.124.43 |
| 178 | + zone: "{{ cs_common_zone_adv }}" |
| 179 | + state: absent |
| 180 | + register: sip |
| 181 | +- name: verify test remove secondary ip idempotence |
| 182 | + assert: |
| 183 | + that: |
| 184 | + - sip is successful |
| 185 | + - sip is not changed |
| 186 | + - sip.network == "net_nic2" |
| 187 | + - sip.vm == "instance-nic-vm" |
| 188 | + - sip.zone == cs_common_zone_adv |
| 189 | + |
| 190 | +- name: cleanup instance |
| 191 | + ngine_io.cloudstack.instance: |
| 192 | + name: "instance-nic-vm" |
| 193 | + zone: "{{ cs_common_zone_adv }}" |
| 194 | + state: expunged |
| 195 | + register: instance |
| 196 | +- name: verify cleanup instance |
| 197 | + assert: |
| 198 | + that: |
| 199 | + - instance is successful |
| 200 | + |
| 201 | +- name: cleanup network |
| 202 | + ngine_io.cloudstack.network: |
| 203 | + name: "net_nic" |
| 204 | + zone: "{{ cs_common_zone_adv }}" |
| 205 | + state: absent |
| 206 | + register: net |
| 207 | +- name: verify cleanup network |
| 208 | + assert: |
| 209 | + that: |
| 210 | + - net is successful |
| 211 | + |
| 212 | +- name: cleanup network 2 |
| 213 | + ngine_io.cloudstack.network: |
| 214 | + name: "net_nic2" |
| 215 | + zone: "{{ cs_common_zone_adv }}" |
| 216 | + state: absent |
| 217 | + register: net |
| 218 | +- name: verify cleanup network 2 |
| 219 | + assert: |
| 220 | + that: |
| 221 | + - net is successful |
0 commit comments