|
| 1 | +--- |
| 2 | +- name: network setup |
| 3 | + ngine_io.cloudstack.network: |
| 4 | + name: ansible test |
| 5 | + network_offering: DefaultIsolatedNetworkOfferingWithSourceNatService |
| 6 | + network_domain: example.com |
| 7 | + zone: "{{ cs_common_zone_adv }}" |
| 8 | + register: net |
| 9 | +- name: verify network setup |
| 10 | + assert: |
| 11 | + that: |
| 12 | + - net is successful |
| 13 | + |
| 14 | +- name: instance setup |
| 15 | + ngine_io.cloudstack.instance: |
| 16 | + name: "{{ cs_portforward_vm }}" |
| 17 | + template: "{{ cs_common_template }}" |
| 18 | + template_filter: all |
| 19 | + service_offering: "{{ cs_common_service_offering }}" |
| 20 | + zone: "{{ cs_common_zone_adv }}" |
| 21 | + network: "ansible test" |
| 22 | + register: instance |
| 23 | +- name: verify instance setup |
| 24 | + assert: |
| 25 | + that: |
| 26 | + - instance is successful |
| 27 | + |
| 28 | +- name: public ip address setup |
| 29 | + ngine_io.cloudstack.ip_address: |
| 30 | + network: ansible test |
| 31 | + zone: "{{ cs_common_zone_adv }}" |
| 32 | + register: ip_address |
| 33 | +- name: verify public ip address setup |
| 34 | + assert: |
| 35 | + that: |
| 36 | + - ip_address is successful |
| 37 | + |
| 38 | +- name: set ip address as fact |
| 39 | + set_fact: |
| 40 | + cs_portforward_public_ip: "{{ ip_address.ip_address }}" |
| 41 | + |
| 42 | +- name: clear existing port forwarding |
| 43 | + ngine_io.cloudstack.portforward: |
| 44 | + ip_address: "{{ cs_portforward_public_ip }}" |
| 45 | + public_port: 80 |
| 46 | + private_port: 8080 |
| 47 | + state: absent |
| 48 | + zone: "{{ cs_common_zone_adv }}" |
| 49 | + register: pf |
| 50 | +- name: verify clear existing port forwarding |
| 51 | + assert: |
| 52 | + that: |
| 53 | + - pf is successful |
| 54 | + |
| 55 | +- name: test fail if missing params |
| 56 | + action: cs_portforward |
| 57 | + register: pf |
| 58 | + ignore_errors: true |
| 59 | +- name: verify results of fail if missing params |
| 60 | + assert: |
| 61 | + that: |
| 62 | + - pf is failed |
| 63 | + - 'pf.msg.startswith("missing required arguments: ")' |
| 64 | + |
| 65 | +- name: test present port forwarding in check mode |
| 66 | + ngine_io.cloudstack.portforward: |
| 67 | + ip_address: "{{ cs_portforward_public_ip }}" |
| 68 | + public_port: 80 |
| 69 | + vm: "{{ cs_portforward_vm }}" |
| 70 | + private_port: 8080 |
| 71 | + zone: "{{ cs_common_zone_adv }}" |
| 72 | + register: pf |
| 73 | + check_mode: true |
| 74 | +- name: verify results of present port forwarding in check mode |
| 75 | + assert: |
| 76 | + that: |
| 77 | + - pf is successful |
| 78 | + - pf is changed |
| 79 | + |
| 80 | +- name: test present port forwarding |
| 81 | + ngine_io.cloudstack.portforward: |
| 82 | + ip_address: "{{ cs_portforward_public_ip }}" |
| 83 | + public_port: 80 |
| 84 | + vm: "{{ cs_portforward_vm }}" |
| 85 | + private_port: 8080 |
| 86 | + zone: "{{ cs_common_zone_adv }}" |
| 87 | + register: pf |
| 88 | +- name: verify results of present port forwarding |
| 89 | + assert: |
| 90 | + that: |
| 91 | + - pf is successful |
| 92 | + - pf is changed |
| 93 | + - pf.vm_name == cs_portforward_vm |
| 94 | + - pf.ip_address == cs_portforward_public_ip |
| 95 | + - pf.public_port == 80 |
| 96 | + - pf.public_end_port == 80 |
| 97 | + - pf.private_port == 8080 |
| 98 | + - pf.private_end_port == 8080 |
| 99 | + |
| 100 | +- name: test present port forwarding idempotence |
| 101 | + ngine_io.cloudstack.portforward: |
| 102 | + ip_address: "{{ cs_portforward_public_ip }}" |
| 103 | + public_port: 80 |
| 104 | + vm: "{{ cs_portforward_vm }}" |
| 105 | + private_port: 8080 |
| 106 | + zone: "{{ cs_common_zone_adv }}" |
| 107 | + register: pf |
| 108 | +- name: verify results of present port forwarding idempotence |
| 109 | + assert: |
| 110 | + that: |
| 111 | + - pf is successful |
| 112 | + - pf is not changed |
| 113 | + - pf.vm_name == cs_portforward_vm |
| 114 | + - pf.ip_address == cs_portforward_public_ip |
| 115 | + - pf.public_port == 80 |
| 116 | + - pf.public_end_port == 80 |
| 117 | + - pf.private_port == 8080 |
| 118 | + - pf.private_end_port == 8080 |
| 119 | + |
| 120 | +- name: test change port forwarding in check mode |
| 121 | + ngine_io.cloudstack.portforward: |
| 122 | + ip_address: "{{ cs_portforward_public_ip }}" |
| 123 | + public_port: 80 |
| 124 | + vm: "{{ cs_portforward_vm }}" |
| 125 | + private_port: 8888 |
| 126 | + zone: "{{ cs_common_zone_adv }}" |
| 127 | + register: pf |
| 128 | + check_mode: true |
| 129 | +- name: verify results of change port forwarding in check mode |
| 130 | + assert: |
| 131 | + that: |
| 132 | + - pf is successful |
| 133 | + - pf is changed |
| 134 | + - pf.vm_name == cs_portforward_vm |
| 135 | + - pf.ip_address == cs_portforward_public_ip |
| 136 | + - pf.public_port == 80 |
| 137 | + - pf.public_end_port == 80 |
| 138 | + - pf.private_port == 8080 |
| 139 | + - pf.private_end_port == 8080 |
| 140 | + |
| 141 | +- name: test change port forwarding |
| 142 | + ngine_io.cloudstack.portforward: |
| 143 | + ip_address: "{{ cs_portforward_public_ip }}" |
| 144 | + public_port: 80 |
| 145 | + vm: "{{ cs_portforward_vm }}" |
| 146 | + private_port: 8888 |
| 147 | + zone: "{{ cs_common_zone_adv }}" |
| 148 | + register: pf |
| 149 | +- name: verify results of change port forwarding |
| 150 | + assert: |
| 151 | + that: |
| 152 | + - pf is successful |
| 153 | + - pf is changed |
| 154 | + - pf.vm_name == cs_portforward_vm |
| 155 | + - pf.ip_address == cs_portforward_public_ip |
| 156 | + - pf.public_port == 80 |
| 157 | + - pf.public_end_port == 80 |
| 158 | + - pf.private_port == 8888 |
| 159 | + - pf.private_end_port == 8888 |
| 160 | + |
| 161 | +- name: test change port forwarding idempotence |
| 162 | + ngine_io.cloudstack.portforward: |
| 163 | + ip_address: "{{ cs_portforward_public_ip }}" |
| 164 | + public_port: 80 |
| 165 | + vm: "{{ cs_portforward_vm }}" |
| 166 | + private_port: 8888 |
| 167 | + zone: "{{ cs_common_zone_adv }}" |
| 168 | + register: pf |
| 169 | +- name: verify results of change port forwarding idempotence |
| 170 | + assert: |
| 171 | + that: |
| 172 | + - pf is successful |
| 173 | + - pf is not changed |
| 174 | + - pf.vm_name == cs_portforward_vm |
| 175 | + - pf.ip_address == cs_portforward_public_ip |
| 176 | + - pf.public_port == 80 |
| 177 | + - pf.public_end_port == 80 |
| 178 | + - pf.private_port == 8888 |
| 179 | + - pf.private_end_port == 8888 |
| 180 | + |
| 181 | +- name: test absent port forwarding in check mode |
| 182 | + ngine_io.cloudstack.portforward: |
| 183 | + ip_address: "{{ cs_portforward_public_ip }}" |
| 184 | + public_port: 80 |
| 185 | + private_port: 8888 |
| 186 | + state: absent |
| 187 | + zone: "{{ cs_common_zone_adv }}" |
| 188 | + register: pf |
| 189 | + check_mode: true |
| 190 | +- name: verify results of absent port forwarding in check mode |
| 191 | + assert: |
| 192 | + that: |
| 193 | + - pf is successful |
| 194 | + - pf is changed |
| 195 | + - pf.vm_name == cs_portforward_vm |
| 196 | + - pf.ip_address == cs_portforward_public_ip |
| 197 | + - pf.public_port == 80 |
| 198 | + - pf.public_end_port == 80 |
| 199 | + - pf.private_port == 8888 |
| 200 | + - pf.private_end_port == 8888 |
| 201 | + |
| 202 | +- name: test absent port forwarding |
| 203 | + ngine_io.cloudstack.portforward: |
| 204 | + ip_address: "{{ cs_portforward_public_ip }}" |
| 205 | + public_port: 80 |
| 206 | + private_port: 8888 |
| 207 | + state: absent |
| 208 | + zone: "{{ cs_common_zone_adv }}" |
| 209 | + register: pf |
| 210 | +- name: verify results of absent port forwarding |
| 211 | + assert: |
| 212 | + that: |
| 213 | + - pf is successful |
| 214 | + - pf is changed |
| 215 | + - pf.vm_name == cs_portforward_vm |
| 216 | + - pf.ip_address == cs_portforward_public_ip |
| 217 | + - pf.public_port == 80 |
| 218 | + - pf.public_end_port == 80 |
| 219 | + - pf.private_port == 8888 |
| 220 | + - pf.private_end_port == 8888 |
| 221 | + |
| 222 | +- name: test absent port forwarding idempotence |
| 223 | + ngine_io.cloudstack.portforward: |
| 224 | + ip_address: "{{ cs_portforward_public_ip }}" |
| 225 | + public_port: 80 |
| 226 | + private_port: 8888 |
| 227 | + state: absent |
| 228 | + zone: "{{ cs_common_zone_adv }}" |
| 229 | + register: pf |
| 230 | +- name: verify results of absent port forwarding idempotence |
| 231 | + assert: |
| 232 | + that: |
| 233 | + - pf is successful |
| 234 | + - pf is not changed |
| 235 | + |
| 236 | +- name: instance cleanup |
| 237 | + ngine_io.cloudstack.instance: |
| 238 | + name: "{{ cs_portforward_vm }}" |
| 239 | + zone: "{{ cs_common_zone_adv }}" |
| 240 | + state: expunged |
| 241 | + register: instance |
| 242 | +- name: verify instance cleanup |
| 243 | + assert: |
| 244 | + that: |
| 245 | + - instance is successful |
| 246 | + |
| 247 | +- name: network cleanup |
| 248 | + ngine_io.cloudstack.network: |
| 249 | + name: ansible test |
| 250 | + zone: "{{ cs_common_zone_adv }}" |
| 251 | + state: absent |
| 252 | + register: net |
| 253 | +- name: verify network cleanup |
| 254 | + assert: |
| 255 | + that: |
| 256 | + - net is successful |
0 commit comments