| 1 |
--- |
| 2 |
# Copyright (c) Ansible Project |
| 3 |
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 4 |
# SPDX-License-Identifier: GPL-3.0-or-later |
| 5 |
|
| 6 |
- name: Create a server (Check) |
| 7 |
check_mode: true |
| 8 |
scaleway_compute: |
| 9 |
name: '{{ scaleway_name }}' |
| 10 |
state: present |
| 11 |
image: '{{ scaleway_image_id }}' |
| 12 |
organization: '{{ scaleway_organization }}' |
| 13 |
region: '{{ scaleway_region }}' |
| 14 |
commercial_type: '{{ scaleway_commerial_type }}' |
| 15 |
|
| 16 |
register: server_creation_check_task |
| 17 |
|
| 18 |
- debug: var=server_creation_check_task |
| 19 |
|
| 20 |
- assert: |
| 21 |
that: |
| 22 |
- server_creation_check_task is success |
| 23 |
- server_creation_check_task is changed |
| 24 |
|
| 25 |
- name: Create a server |
| 26 |
scaleway_compute: |
| 27 |
name: '{{ scaleway_name }}' |
| 28 |
state: present |
| 29 |
image: '{{ scaleway_image_id }}' |
| 30 |
organization: '{{ scaleway_organization }}' |
| 31 |
region: '{{ scaleway_region }}' |
| 32 |
commercial_type: '{{ scaleway_commerial_type }}' |
| 33 |
wait: true |
| 34 |
|
| 35 |
register: server_creation_task |
| 36 |
|
| 37 |
- debug: var=server_creation_task |
| 38 |
|
| 39 |
- assert: |
| 40 |
that: |
| 41 |
- server_creation_task is success |
| 42 |
- server_creation_task is changed |
| 43 |
|
| 44 |
- name: Create a server (Confirmation) |
| 45 |
scaleway_compute: |
| 46 |
name: '{{ scaleway_name }}' |
| 47 |
state: present |
| 48 |
image: '{{ scaleway_image_id }}' |
| 49 |
organization: '{{ scaleway_organization }}' |
| 50 |
region: '{{ scaleway_region }}' |
| 51 |
commercial_type: '{{ scaleway_commerial_type }}' |
| 52 |
wait: true |
| 53 |
|
| 54 |
register: server_creation_confirmation_task |
| 55 |
|
| 56 |
- debug: var=server_creation_confirmation_task |
| 57 |
|
| 58 |
- assert: |
| 59 |
that: |
| 60 |
- server_creation_confirmation_task is success |
| 61 |
- server_creation_confirmation_task is not changed |
| 62 |
|
| 63 |
- name: Patch server tags (Check) |
| 64 |
check_mode: true |
| 65 |
scaleway_compute: |
| 66 |
name: '{{ scaleway_name }}' |
| 67 |
state: present |
| 68 |
image: '{{ scaleway_image_id }}' |
| 69 |
organization: '{{ scaleway_organization }}' |
| 70 |
region: '{{ scaleway_region }}' |
| 71 |
commercial_type: '{{ scaleway_commerial_type }}' |
| 72 |
tags: |
| 73 |
- test |
| 74 |
- www |
| 75 |
register: server_patching_check_task |
| 76 |
|
| 77 |
- debug: var=server_patching_check_task |
| 78 |
|
| 79 |
- assert: |
| 80 |
that: |
| 81 |
- server_patching_check_task is success |
| 82 |
- server_patching_check_task is changed |
| 83 |
|
| 84 |
- name: Patch server tags |
| 85 |
scaleway_compute: |
| 86 |
name: '{{ scaleway_name }}' |
| 87 |
state: present |
| 88 |
image: '{{ scaleway_image_id }}' |
| 89 |
organization: '{{ scaleway_organization }}' |
| 90 |
region: '{{ scaleway_region }}' |
| 91 |
commercial_type: '{{ scaleway_commerial_type }}' |
| 92 |
wait: true |
| 93 |
tags: |
| 94 |
- test |
| 95 |
- www |
| 96 |
register: server_patching_task |
| 97 |
|
| 98 |
- debug: var=server_patching_task |
| 99 |
|
| 100 |
- assert: |
| 101 |
that: |
| 102 |
- server_patching_task is success |
| 103 |
- server_patching_task is changed |
| 104 |
|
| 105 |
- name: Patch server tags (Confirmation) |
| 106 |
scaleway_compute: |
| 107 |
name: '{{ scaleway_name }}' |
| 108 |
state: present |
| 109 |
image: '{{ scaleway_image_id }}' |
| 110 |
organization: '{{ scaleway_organization }}' |
| 111 |
region: '{{ scaleway_region }}' |
| 112 |
commercial_type: '{{ scaleway_commerial_type }}' |
| 113 |
wait: true |
| 114 |
tags: |
| 115 |
- test |
| 116 |
- www |
| 117 |
register: server_patching_confirmation_task |
| 118 |
|
| 119 |
- debug: var=server_patching_confirmation_task |
| 120 |
|
| 121 |
- assert: |
| 122 |
that: |
| 123 |
- server_patching_confirmation_task is success |
| 124 |
- server_patching_confirmation_task is not changed |
| 125 |
|
| 126 |
- name: Run it (Check mode) |
| 127 |
check_mode: true |
| 128 |
scaleway_compute: |
| 129 |
name: '{{ scaleway_name }}' |
| 130 |
state: running |
| 131 |
image: '{{ scaleway_image_id }}' |
| 132 |
organization: '{{ scaleway_organization }}' |
| 133 |
region: '{{ scaleway_region }}' |
| 134 |
commercial_type: '{{ scaleway_commerial_type }}' |
| 135 |
tags: |
| 136 |
- test |
| 137 |
- www |
| 138 |
register: server_run_check_task |
| 139 |
|
| 140 |
- debug: var=server_run_check_task |
| 141 |
|
| 142 |
- assert: |
| 143 |
that: |
| 144 |
- server_run_check_task is success |
| 145 |
- server_run_check_task is changed |
| 146 |
|
| 147 |
- name: Run it |
| 148 |
scaleway_compute: |
| 149 |
name: '{{ scaleway_name }}' |
| 150 |
state: running |
| 151 |
image: '{{ scaleway_image_id }}' |
| 152 |
organization: '{{ scaleway_organization }}' |
| 153 |
region: '{{ scaleway_region }}' |
| 154 |
commercial_type: '{{ scaleway_commerial_type }}' |
| 155 |
wait: true |
| 156 |
tags: |
| 157 |
- test |
| 158 |
- www |
| 159 |
register: server_run_task |
| 160 |
|
| 161 |
- debug: var=server_run_task |
| 162 |
|
| 163 |
- assert: |
| 164 |
that: |
| 165 |
- server_run_task is success |
| 166 |
- server_run_task is changed |
| 167 |
|
| 168 |
- name: Run it |
| 169 |
scaleway_compute: |
| 170 |
name: '{{ scaleway_name }}' |
| 171 |
state: running |
| 172 |
image: '{{ scaleway_image_id }}' |
| 173 |
organization: '{{ scaleway_organization }}' |
| 174 |
region: '{{ scaleway_region }}' |
| 175 |
commercial_type: '{{ scaleway_commerial_type }}' |
| 176 |
wait: true |
| 177 |
tags: |
| 178 |
- test |
| 179 |
- www |
| 180 |
register: server_run_confirmation_task |
| 181 |
|
| 182 |
- debug: var=server_run_confirmation_task |
| 183 |
|
| 184 |
- assert: |
| 185 |
that: |
| 186 |
- server_run_confirmation_task is success |
| 187 |
- server_run_confirmation_task is not changed |
| 188 |
|
| 189 |
- name: Reboot it (Check mode) |
| 190 |
check_mode: true |
| 191 |
scaleway_compute: |
| 192 |
name: '{{ scaleway_name }}' |
| 193 |
state: restarted |
| 194 |
image: '{{ scaleway_image_id }}' |
| 195 |
organization: '{{ scaleway_organization }}' |
| 196 |
region: '{{ scaleway_region }}' |
| 197 |
commercial_type: '{{ scaleway_commerial_type }}' |
| 198 |
tags: |
| 199 |
- test |
| 200 |
- www |
| 201 |
register: server_reboot_check_task |
| 202 |
|
| 203 |
- debug: var=server_reboot_check_task |
| 204 |
|
| 205 |
- assert: |
| 206 |
that: |
| 207 |
- server_reboot_check_task is success |
| 208 |
- server_reboot_check_task is changed |
| 209 |
|
| 210 |
- name: Reboot it |
| 211 |
scaleway_compute: |
| 212 |
name: '{{ scaleway_name }}' |
| 213 |
state: restarted |
| 214 |
image: '{{ scaleway_image_id }}' |
| 215 |
organization: '{{ scaleway_organization }}' |
| 216 |
region: '{{ scaleway_region }}' |
| 217 |
commercial_type: '{{ scaleway_commerial_type }}' |
| 218 |
wait: true |
| 219 |
tags: |
| 220 |
- test |
| 221 |
- www |
| 222 |
register: server_reboot_task |
| 223 |
|
| 224 |
- debug: var=server_reboot_task |
| 225 |
|
| 226 |
- assert: |
| 227 |
that: |
| 228 |
- server_reboot_task is success |
| 229 |
- server_reboot_task is changed |
| 230 |
|
| 231 |
- name: Stop it (Check mode) |
| 232 |
check_mode: true |
| 233 |
scaleway_compute: |
| 234 |
name: '{{ scaleway_name }}' |
| 235 |
state: stopped |
| 236 |
image: '{{ scaleway_image_id }}' |
| 237 |
organization: '{{ scaleway_organization }}' |
| 238 |
region: '{{ scaleway_region }}' |
| 239 |
commercial_type: '{{ scaleway_commerial_type }}' |
| 240 |
tags: |
| 241 |
- test |
| 242 |
- www |
| 243 |
register: server_stop_check_task |
| 244 |
|
| 245 |
- debug: var=server_stop_check_task |
| 246 |
|
| 247 |
- assert: |
| 248 |
that: |
| 249 |
- server_stop_check_task is success |
| 250 |
- server_stop_check_task is changed |
| 251 |
|
| 252 |
- name: Stop it |
| 253 |
scaleway_compute: |
| 254 |
name: '{{ scaleway_name }}' |
| 255 |
state: stopped |
| 256 |
image: '{{ scaleway_image_id }}' |
| 257 |
organization: '{{ scaleway_organization }}' |
| 258 |
region: '{{ scaleway_region }}' |
| 259 |
commercial_type: '{{ scaleway_commerial_type }}' |
| 260 |
wait: true |
| 261 |
tags: |
| 262 |
- test |
| 263 |
- www |
| 264 |
register: server_stop_task |
| 265 |
|
| 266 |
- debug: var=server_stop_task |
| 267 |
|
| 268 |
- assert: |
| 269 |
that: |
| 270 |
- server_stop_task is success |
| 271 |
- server_stop_task is changed |
| 272 |
|
| 273 |
- name: Stop it (Confirmation) |
| 274 |
scaleway_compute: |
| 275 |
name: '{{ scaleway_name }}' |
| 276 |
state: stopped |
| 277 |
image: '{{ scaleway_image_id }}' |
| 278 |
organization: '{{ scaleway_organization }}' |
| 279 |
region: '{{ scaleway_region }}' |
| 280 |
commercial_type: '{{ scaleway_commerial_type }}' |
| 281 |
wait: true |
| 282 |
tags: |
| 283 |
- test |
| 284 |
- www |
| 285 |
register: server_stop_confirmation_task |
| 286 |
|
| 287 |
- debug: var=server_stop_confirmation_task |
| 288 |
|
| 289 |
- assert: |
| 290 |
that: |
| 291 |
- server_stop_confirmation_task is success |
| 292 |
- server_stop_confirmation_task is not changed |
| 293 |
|
| 294 |
- name: Destroy it (Check mode) |
| 295 |
check_mode: true |
| 296 |
scaleway_compute: |
| 297 |
name: '{{ scaleway_name }}' |
| 298 |
state: absent |
| 299 |
image: '{{ scaleway_image_id }}' |
| 300 |
organization: '{{ scaleway_organization }}' |
| 301 |
region: '{{ scaleway_region }}' |
| 302 |
commercial_type: '{{ scaleway_commerial_type }}' |
| 303 |
tags: |
| 304 |
- test |
| 305 |
- www |
| 306 |
register: server_destroy_check_task |
| 307 |
|
| 308 |
- debug: var=server_destroy_check_task |
| 309 |
|
| 310 |
- assert: |
| 311 |
that: |
| 312 |
- server_destroy_check_task is success |
| 313 |
- server_destroy_check_task is changed |
| 314 |
|
| 315 |
- name: Destroy it |
| 316 |
scaleway_compute: |
| 317 |
name: '{{ scaleway_name }}' |
| 318 |
state: absent |
| 319 |
image: '{{ scaleway_image_id }}' |
| 320 |
organization: '{{ scaleway_organization }}' |
| 321 |
region: '{{ scaleway_region }}' |
| 322 |
commercial_type: '{{ scaleway_commerial_type }}' |
| 323 |
wait: true |
| 324 |
tags: |
| 325 |
- test |
| 326 |
- www |
| 327 |
register: server_destroy_task |
| 328 |
|
| 329 |
- debug: var=server_destroy_task |
| 330 |
|
| 331 |
- assert: |
| 332 |
that: |
| 333 |
- server_destroy_task is success |
| 334 |
- server_destroy_task is changed |
| 335 |
|
| 336 |
- name: Destroy it (Confirmation) |
| 337 |
scaleway_compute: |
| 338 |
name: '{{ scaleway_name }}' |
| 339 |
state: absent |
| 340 |
image: '{{ scaleway_image_id }}' |
| 341 |
organization: '{{ scaleway_organization }}' |
| 342 |
region: '{{ scaleway_region }}' |
| 343 |
commercial_type: '{{ scaleway_commerial_type }}' |
| 344 |
wait: true |
| 345 |
tags: |
| 346 |
- test |
| 347 |
- www |
| 348 |
register: server_destroy_confirmation_task |
| 349 |
|
| 350 |
- debug: var=server_destroy_confirmation_task |
| 351 |
|
| 352 |
- assert: |
| 353 |
that: |
| 354 |
- server_destroy_confirmation_task is success |
| 355 |
- server_destroy_confirmation_task is not changed |
| 356 |
|
| 357 |
- name: Testing for unauthorized organization |
| 358 |
ignore_errors: true |
| 359 |
scaleway_compute: |
| 360 |
name: '{{ scaleway_name }}' |
| 361 |
state: present |
| 362 |
image: '{{ scaleway_image_id }}' |
| 363 |
organization: this-organization-does-not-exists |
| 364 |
region: '{{ scaleway_region }}' |
| 365 |
commercial_type: '{{ scaleway_commerial_type }}' |
| 366 |
register: unauthorized_organization_task |
| 367 |
|
| 368 |
- debug: var=unauthorized_organization_task |
| 369 |
|
| 370 |
- assert: |
| 371 |
that: |
| 372 |
- unauthorized_organization_task is not success |
| 373 |
- unauthorized_organization_task is not changed |
| 374 |
|
| 375 |
- name: Testing for unexisting image |
| 376 |
ignore_errors: true |
| 377 |
scaleway_compute: |
| 378 |
name: '{{ scaleway_name }}' |
| 379 |
state: present |
| 380 |
image: this-image-does-not-exists |
| 381 |
organization: '{{ scaleway_organization }}' |
| 382 |
region: '{{ scaleway_region }}' |
| 383 |
commercial_type: '{{ scaleway_commerial_type }}' |
| 384 |
register: unexisting_image_check |
| 385 |
|
| 386 |
- debug: var=unexisting_image_check |
| 387 |
|
| 388 |
- assert: |
| 389 |
that: |
| 390 |
- unexisting_image_check is not success |
| 391 |
- unexisting_image_check is not changed |
| 392 |
- unexisting_image_check.msg == "Error in getting image this-image-does-not-exists on https://cp-{{scaleway_region}}.scaleway.com" |