| 1 |
--- |
| 2 |
- name: Create subnet in check mode |
| 3 |
cloudscale_ch.cloud.subnet: |
| 4 |
cidr: '{{ cloudscale_subnet_cidr }}' |
| 5 |
network: |
| 6 |
name: '{{ cloudscale_resource_prefix }}-net' |
| 7 |
zone: '{{ cloudscale_test_zone }}' |
| 8 |
tags: |
| 9 |
project: ansible-test |
| 10 |
stage: production |
| 11 |
sla: 24-7 |
| 12 |
register: snet |
| 13 |
check_mode: yes |
| 14 |
- name: 'VERIFY: Create subnet in check mode' |
| 15 |
assert: |
| 16 |
that: |
| 17 |
- snet is changed |
| 18 |
- snet.cidr == cloudscale_subnet_cidr |
| 19 |
- not snet.uuid |
| 20 |
|
| 21 |
- name: Create subnet |
| 22 |
cloudscale_ch.cloud.subnet: |
| 23 |
cidr: '{{ cloudscale_subnet_cidr }}' |
| 24 |
network: |
| 25 |
name: '{{ cloudscale_resource_prefix }}-net' |
| 26 |
zone: '{{ cloudscale_test_zone }}' |
| 27 |
tags: |
| 28 |
project: ansible-test |
| 29 |
stage: production |
| 30 |
sla: 24-7 |
| 31 |
register: snet |
| 32 |
- name: 'VERIFY: Create subnet' |
| 33 |
assert: |
| 34 |
that: |
| 35 |
- snet is changed |
| 36 |
- snet.cidr == cloudscale_subnet_cidr |
| 37 |
- snet.uuid is defined |
| 38 |
- snet.tags.project == 'ansible-test' |
| 39 |
- snet.tags.stage == 'production' |
| 40 |
- snet.tags.sla == '24-7' |
| 41 |
- snet.network.zone.slug == cloudscale_test_zone |
| 42 |
|
| 43 |
- name: Remember subnet uuid |
| 44 |
set_fact: |
| 45 |
subnet_uuid: '{{ snet.uuid }}' |
| 46 |
|
| 47 |
- name: Create subnet idempotence |
| 48 |
cloudscale_ch.cloud.subnet: |
| 49 |
cidr: '{{ cloudscale_subnet_cidr }}' |
| 50 |
network: |
| 51 |
name: '{{ cloudscale_resource_prefix }}-net' |
| 52 |
zone: '{{ cloudscale_test_zone }}' |
| 53 |
tags: |
| 54 |
project: ansible-test |
| 55 |
stage: production |
| 56 |
sla: 24-7 |
| 57 |
register: snet |
| 58 |
- name: 'VERIFY: Create subnet idempotence' |
| 59 |
assert: |
| 60 |
that: |
| 61 |
- snet is not changed |
| 62 |
- snet.cidr == cloudscale_subnet_cidr |
| 63 |
- snet.uuid == subnet_uuid |
| 64 |
- snet.tags.project == 'ansible-test' |
| 65 |
- snet.tags.stage == 'production' |
| 66 |
- snet.tags.sla == '24-7' |
| 67 |
- snet.network.zone.slug == cloudscale_test_zone |
| 68 |
|
| 69 |
- name: Update subnet in check mode |
| 70 |
cloudscale_ch.cloud.subnet: |
| 71 |
cidr: '{{ cloudscale_subnet_cidr }}' |
| 72 |
network: |
| 73 |
name: '{{ cloudscale_resource_prefix }}-net' |
| 74 |
zone: '{{ cloudscale_test_zone }}' |
| 75 |
tags: |
| 76 |
project: ansible-test |
| 77 |
stage: staging |
| 78 |
sla: 8-5 |
| 79 |
register: snet |
| 80 |
check_mode: yes |
| 81 |
- name: 'VERIFY: Update subnet in check mode' |
| 82 |
assert: |
| 83 |
that: |
| 84 |
- snet is changed |
| 85 |
- snet.cidr == cloudscale_subnet_cidr |
| 86 |
- snet.uuid == subnet_uuid |
| 87 |
- snet.tags.project == 'ansible-test' |
| 88 |
- snet.tags.stage == 'production' |
| 89 |
- snet.tags.sla == '24-7' |
| 90 |
- snet.network.zone.slug == cloudscale_test_zone |
| 91 |
|
| 92 |
- name: Update subnet |
| 93 |
cloudscale_ch.cloud.subnet: |
| 94 |
cidr: '{{ cloudscale_subnet_cidr }}' |
| 95 |
network: |
| 96 |
name: '{{ cloudscale_resource_prefix }}-net' |
| 97 |
zone: '{{ cloudscale_test_zone }}' |
| 98 |
tags: |
| 99 |
project: ansible-test |
| 100 |
stage: staging |
| 101 |
sla: 8-5 |
| 102 |
register: snet |
| 103 |
- name: 'VERIFY: Update subnet' |
| 104 |
assert: |
| 105 |
that: |
| 106 |
- snet is changed |
| 107 |
- snet.cidr == cloudscale_subnet_cidr |
| 108 |
- snet.uuid == subnet_uuid |
| 109 |
- snet.tags.project == 'ansible-test' |
| 110 |
- snet.tags.stage == 'staging' |
| 111 |
- snet.tags.sla == '8-5' |
| 112 |
- snet.network.zone.slug == cloudscale_test_zone |
| 113 |
|
| 114 |
- name: Update subnet idempotence |
| 115 |
cloudscale_ch.cloud.subnet: |
| 116 |
uuid: '{{ subnet_uuid }}' |
| 117 |
cidr: '{{ cloudscale_subnet_cidr }}' |
| 118 |
network: |
| 119 |
name: '{{ cloudscale_resource_prefix }}-net' |
| 120 |
zone: '{{ cloudscale_test_zone }}' |
| 121 |
tags: |
| 122 |
project: ansible-test |
| 123 |
stage: staging |
| 124 |
sla: 8-5 |
| 125 |
register: snet |
| 126 |
- name: 'VERIFY: Update subnet idempotence' |
| 127 |
assert: |
| 128 |
that: |
| 129 |
- snet is not changed |
| 130 |
- snet.cidr == cloudscale_subnet_cidr |
| 131 |
- snet.uuid == subnet_uuid |
| 132 |
- snet.tags.project == 'ansible-test' |
| 133 |
- snet.tags.stage == 'staging' |
| 134 |
- snet.tags.sla == '8-5' |
| 135 |
- snet.network.zone.slug == cloudscale_test_zone |
| 136 |
|
| 137 |
- name: Update subnet by Network UUID |
| 138 |
cloudscale_ch.cloud.subnet: |
| 139 |
cidr: '{{ cloudscale_subnet_cidr }}' |
| 140 |
network: |
| 141 |
uuid: '{{ net.uuid }}' |
| 142 |
dns_servers: |
| 143 |
- 9.9.9.9 |
| 144 |
- 8.8.8.8 |
| 145 |
gateway_address: 192.168.23.1 |
| 146 |
register: snet |
| 147 |
- name: 'VERIFY: Update subnet' |
| 148 |
assert: |
| 149 |
that: |
| 150 |
- snet is changed |
| 151 |
- snet.cidr == cloudscale_subnet_cidr |
| 152 |
- snet.uuid == subnet_uuid |
| 153 |
- snet.dns_servers == ['9.9.9.9', '8.8.8.8'] |
| 154 |
- snet.gateway_address == '192.168.23.1' |
| 155 |
- snet.tags.project == 'ansible-test' |
| 156 |
- snet.tags.stage == 'staging' |
| 157 |
- snet.tags.sla == '8-5' |
| 158 |
- snet.network.zone.slug == cloudscale_test_zone |
| 159 |
|
| 160 |
- name: Update subnet by Network UUID idempotence |
| 161 |
cloudscale_ch.cloud.subnet: |
| 162 |
cidr: '{{ cloudscale_subnet_cidr }}' |
| 163 |
network: |
| 164 |
uuid: '{{ net.uuid }}' |
| 165 |
dns_servers: |
| 166 |
- 9.9.9.9 |
| 167 |
- 8.8.8.8 |
| 168 |
gateway_address: 192.168.23.1 |
| 169 |
register: snet |
| 170 |
- name: 'VERIFY: Update subnet' |
| 171 |
assert: |
| 172 |
that: |
| 173 |
- snet is not changed |
| 174 |
- snet.cidr == cloudscale_subnet_cidr |
| 175 |
- snet.uuid == subnet_uuid |
| 176 |
- snet.dns_servers == ['9.9.9.9', '8.8.8.8'] |
| 177 |
- snet.gateway_address == '192.168.23.1' |
| 178 |
- snet.tags.project == 'ansible-test' |
| 179 |
- snet.tags.stage == 'staging' |
| 180 |
- snet.tags.sla == '8-5' |
| 181 |
- snet.network.zone.slug == cloudscale_test_zone |
| 182 |
|
| 183 |
- name: Reset DNS servers in subnet |
| 184 |
cloudscale_ch.cloud.subnet: |
| 185 |
cidr: '{{ cloudscale_subnet_cidr }}' |
| 186 |
network: |
| 187 |
uuid: '{{ net.uuid }}' |
| 188 |
gateway_address: 192.168.23.1 |
| 189 |
reset: true |
| 190 |
register: snet |
| 191 |
- name: 'VERIFY: Update subnet' |
| 192 |
assert: |
| 193 |
that: |
| 194 |
- snet is changed |
| 195 |
- snet.cidr == cloudscale_subnet_cidr |
| 196 |
- snet.uuid == subnet_uuid |
| 197 |
- snet.dns_servers != ['9.9.9.9', '8.8.8.8'] |
| 198 |
- snet.gateway_address == '192.168.23.1' |
| 199 |
- snet.tags.project == 'ansible-test' |
| 200 |
- snet.tags.stage == 'staging' |
| 201 |
- snet.tags.sla == '8-5' |
| 202 |
- snet.network.zone.slug == cloudscale_test_zone |
| 203 |
|
| 204 |
- name: Delete subnet in check mode |
| 205 |
cloudscale_ch.cloud.subnet: |
| 206 |
uuid: "{{ snet.uuid }}" |
| 207 |
state: absent |
| 208 |
register: snet |
| 209 |
check_mode: yes |
| 210 |
- name: 'VERIFY: Delete subnet in check mode' |
| 211 |
assert: |
| 212 |
that: |
| 213 |
- snet is changed |
| 214 |
- snet.cidr == cloudscale_subnet_cidr |
| 215 |
- snet.uuid == subnet_uuid |
| 216 |
- snet.state == "present" |
| 217 |
- snet.network.zone.slug == cloudscale_test_zone |
| 218 |
|
| 219 |
- name: Delete subnet |
| 220 |
cloudscale_ch.cloud.subnet: |
| 221 |
uuid: "{{ snet.uuid }}" |
| 222 |
state: absent |
| 223 |
register: snet |
| 224 |
- name: 'VERIFY: Delete subnet' |
| 225 |
assert: |
| 226 |
that: |
| 227 |
- snet is changed |
| 228 |
- snet.cidr == cloudscale_subnet_cidr |
| 229 |
- snet.uuid == subnet_uuid |
| 230 |
- snet.state == "absent" |
| 231 |
- snet.network.zone.slug == cloudscale_test_zone |
| 232 |
|
| 233 |
- name: Delete subnet idempotence |
| 234 |
cloudscale_ch.cloud.subnet: |
| 235 |
uuid: "{{ snet.uuid }}" |
| 236 |
state: absent |
| 237 |
register: snet |
| 238 |
- name: 'VERIFY: Delete subnet idempotence' |
| 239 |
assert: |
| 240 |
that: |
| 241 |
- snet is not changed |
| 242 |
- snet.uuid == subnet_uuid |
| 243 |
- snet.state == "absent" |