| 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 scaleway security_group |
| 7 |
scaleway_security_group: |
| 8 |
state: present |
| 9 |
region: '{{ scaleway_region }}' |
| 10 |
name: test_compute |
| 11 |
description: test_compute |
| 12 |
organization: '{{ scaleway_organization }}' |
| 13 |
stateful: true |
| 14 |
inbound_default_policy: accept |
| 15 |
outbound_default_policy: accept |
| 16 |
organization_default: false |
| 17 |
register: security_group |
| 18 |
|
| 19 |
- debug: var=security_group |
| 20 |
|
| 21 |
- block: |
| 22 |
- name: Create a server with security_group (Check) |
| 23 |
check_mode: true |
| 24 |
scaleway_compute: |
| 25 |
name: '{{ scaleway_name }}' |
| 26 |
state: present |
| 27 |
image: '{{ scaleway_image_id }}' |
| 28 |
organization: '{{ scaleway_organization }}' |
| 29 |
region: '{{ scaleway_region }}' |
| 30 |
commercial_type: '{{ scaleway_commerial_type }}' |
| 31 |
security_group: '{{ security_group.scaleway_security_group.id }}' |
| 32 |
|
| 33 |
register: server_creation_check_task |
| 34 |
|
| 35 |
- debug: var=server_creation_check_task |
| 36 |
|
| 37 |
- assert: |
| 38 |
that: |
| 39 |
- server_creation_check_task is success |
| 40 |
- server_creation_check_task is changed |
| 41 |
|
| 42 |
- name: Create a server |
| 43 |
scaleway_compute: |
| 44 |
name: '{{ scaleway_name }}' |
| 45 |
state: present |
| 46 |
image: '{{ scaleway_image_id }}' |
| 47 |
organization: '{{ scaleway_organization }}' |
| 48 |
region: '{{ scaleway_region }}' |
| 49 |
commercial_type: '{{ scaleway_commerial_type }}' |
| 50 |
security_group: '{{ security_group.scaleway_security_group.id }}' |
| 51 |
wait: true |
| 52 |
|
| 53 |
register: server_creation_task |
| 54 |
|
| 55 |
- debug: var=server_creation_task |
| 56 |
|
| 57 |
- assert: |
| 58 |
that: |
| 59 |
- server_creation_task is success |
| 60 |
- server_creation_task is changed |
| 61 |
|
| 62 |
- name: Create a server with security_group (Confirmation) |
| 63 |
scaleway_compute: |
| 64 |
name: '{{ scaleway_name }}' |
| 65 |
state: present |
| 66 |
image: '{{ scaleway_image_id }}' |
| 67 |
organization: '{{ scaleway_organization }}' |
| 68 |
region: '{{ scaleway_region }}' |
| 69 |
commercial_type: '{{ scaleway_commerial_type }}' |
| 70 |
security_group: '{{ security_group.scaleway_security_group.id }}' |
| 71 |
wait: true |
| 72 |
|
| 73 |
register: server_creation_confirmation_task |
| 74 |
|
| 75 |
- debug: var=server_creation_confirmation_task |
| 76 |
|
| 77 |
- assert: |
| 78 |
that: |
| 79 |
- server_creation_confirmation_task is success |
| 80 |
- server_creation_confirmation_task is not changed |
| 81 |
|
| 82 |
- name: Keep current security_group (Check) |
| 83 |
check_mode: true |
| 84 |
scaleway_compute: |
| 85 |
name: '{{ scaleway_name }}' |
| 86 |
state: present |
| 87 |
image: '{{ scaleway_image_id }}' |
| 88 |
organization: '{{ scaleway_organization }}' |
| 89 |
region: '{{ scaleway_region }}' |
| 90 |
commercial_type: '{{ scaleway_commerial_type }}' |
| 91 |
security_group: '{{ security_group.scaleway_security_group.id }}' |
| 92 |
wait: true |
| 93 |
|
| 94 |
register: server_creation_confirmation_task |
| 95 |
|
| 96 |
- debug: var=server_creation_confirmation_task |
| 97 |
|
| 98 |
- assert: |
| 99 |
that: |
| 100 |
- server_creation_confirmation_task is success |
| 101 |
- server_creation_confirmation_task is not changed |
| 102 |
|
| 103 |
- name: Keep current security_group |
| 104 |
scaleway_compute: |
| 105 |
name: '{{ scaleway_name }}' |
| 106 |
state: present |
| 107 |
image: '{{ scaleway_image_id }}' |
| 108 |
organization: '{{ scaleway_organization }}' |
| 109 |
region: '{{ scaleway_region }}' |
| 110 |
commercial_type: '{{ scaleway_commerial_type }}' |
| 111 |
wait: true |
| 112 |
|
| 113 |
register: server_creation_confirmation_task |
| 114 |
|
| 115 |
- debug: var=server_creation_confirmation_task |
| 116 |
|
| 117 |
- assert: |
| 118 |
that: |
| 119 |
- server_creation_confirmation_task is success |
| 120 |
- server_creation_confirmation_task is not changed |
| 121 |
|
| 122 |
always: |
| 123 |
- name: Destroy it |
| 124 |
scaleway_compute: |
| 125 |
name: '{{ scaleway_name }}' |
| 126 |
state: absent |
| 127 |
image: '{{ scaleway_image_id }}' |
| 128 |
organization: '{{ scaleway_organization }}' |
| 129 |
region: '{{ scaleway_region }}' |
| 130 |
commercial_type: '{{ scaleway_commerial_type }}' |
| 131 |
wait: true |
| 132 |
|
| 133 |
register: server_destroy_task |
| 134 |
|
| 135 |
- debug: var=server_destroy_task |
| 136 |
|
| 137 |
- assert: |
| 138 |
that: |
| 139 |
- server_destroy_task is success |
| 140 |
- server_destroy_task is changed |
| 141 |
|
| 142 |
- name: Create a scaleway security_group |
| 143 |
scaleway_security_group: |
| 144 |
state: absent |
| 145 |
region: '{{ scaleway_region }}' |
| 146 |
name: test_compute |
| 147 |
description: test_compute |
| 148 |
organization: '{{ scaleway_organization }}' |
| 149 |
stateful: true |
| 150 |
inbound_default_policy: accept |
| 151 |
outbound_default_policy: accept |
| 152 |
organization_default: false |