| 1 |
--- |
| 2 |
#################################################################### |
| 3 |
# WARNING: These are designed specifically for Ansible tests # |
| 4 |
# and should not be used as examples of how to write Ansible roles # |
| 5 |
#################################################################### |
| 6 |
|
| 7 |
# Copyright (c) 2022, Guillaume MARTINEZ <[email protected]> |
| 8 |
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 9 |
# SPDX-License-Identifier: GPL-3.0-or-later |
| 10 |
|
| 11 |
- name: Create container_namespace |
| 12 |
community.general.scaleway_container_namespace: |
| 13 |
state: present |
| 14 |
name: '{{ container_namespace_name }}' |
| 15 |
region: '{{ scaleway_region }}' |
| 16 |
project_id: '{{ scw_project }}' |
| 17 |
description: '{{ description }}' |
| 18 |
register: integration_container_namespace |
| 19 |
|
| 20 |
- name: Create a container (Check) |
| 21 |
check_mode: true |
| 22 |
community.general.scaleway_container: |
| 23 |
state: present |
| 24 |
name: '{{ name }}' |
| 25 |
region: '{{ scaleway_region }}' |
| 26 |
namespace_id: '{{ integration_container_namespace.container_namespace.id }}' |
| 27 |
registry_image: '{{ image }}' |
| 28 |
description: '{{ description }}' |
| 29 |
environment_variables: '{{ environment_variables }}' |
| 30 |
secret_environment_variables: '{{ secret_environment_variables }}' |
| 31 |
port: '{{ port }}' |
| 32 |
register: cn_creation_check_task |
| 33 |
|
| 34 |
- ansible.builtin.debug: |
| 35 |
var: cn_creation_check_task |
| 36 |
|
| 37 |
- name: Check module call result |
| 38 |
ansible.builtin.assert: |
| 39 |
that: |
| 40 |
- cn_creation_check_task is success |
| 41 |
- cn_creation_check_task is changed |
| 42 |
|
| 43 |
- name: Create container |
| 44 |
community.general.scaleway_container: |
| 45 |
state: present |
| 46 |
name: '{{ name }}' |
| 47 |
region: '{{ scaleway_region }}' |
| 48 |
namespace_id: '{{ integration_container_namespace.container_namespace.id }}' |
| 49 |
registry_image: '{{ image }}' |
| 50 |
description: '{{ description }}' |
| 51 |
environment_variables: '{{ environment_variables }}' |
| 52 |
secret_environment_variables: '{{ secret_environment_variables }}' |
| 53 |
port: '{{ port }}' |
| 54 |
register: cn_creation_task |
| 55 |
|
| 56 |
- ansible.builtin.debug: |
| 57 |
var: cn_creation_task |
| 58 |
|
| 59 |
- name: Check module call result |
| 60 |
ansible.builtin.assert: |
| 61 |
that: |
| 62 |
- cn_creation_task is success |
| 63 |
- cn_creation_task is changed |
| 64 |
- cn_creation_task.container.status in ["created", "ready"] |
| 65 |
|
| 66 |
- name: Create container (Confirmation) |
| 67 |
community.general.scaleway_container: |
| 68 |
state: present |
| 69 |
name: '{{ name }}' |
| 70 |
region: '{{ scaleway_region }}' |
| 71 |
namespace_id: '{{ integration_container_namespace.container_namespace.id }}' |
| 72 |
registry_image: '{{ image }}' |
| 73 |
description: '{{ description }}' |
| 74 |
environment_variables: '{{ environment_variables }}' |
| 75 |
secret_environment_variables: '{{ secret_environment_variables }}' |
| 76 |
port: '{{ port }}' |
| 77 |
register: cn_creation_confirmation_task |
| 78 |
|
| 79 |
- ansible.builtin.debug: |
| 80 |
var: cn_creation_confirmation_task |
| 81 |
|
| 82 |
- name: Check module call result |
| 83 |
ansible.builtin.assert: |
| 84 |
that: |
| 85 |
- cn_creation_confirmation_task is success |
| 86 |
- cn_creation_confirmation_task is not changed |
| 87 |
- cn_creation_confirmation_task.container.status in ["created", "ready"] |
| 88 |
|
| 89 |
- name: Update container (Check) |
| 90 |
check_mode: true |
| 91 |
community.general.scaleway_container: |
| 92 |
state: present |
| 93 |
name: '{{ name }}' |
| 94 |
region: '{{ scaleway_region }}' |
| 95 |
namespace_id: '{{ integration_container_namespace.container_namespace.id }}' |
| 96 |
registry_image: '{{ image }}' |
| 97 |
description: '{{ updated_description }}' |
| 98 |
environment_variables: '{{ environment_variables }}' |
| 99 |
secret_environment_variables: '{{ secret_environment_variables }}' |
| 100 |
port: '{{ port }}' |
| 101 |
register: cn_update_check_task |
| 102 |
|
| 103 |
- ansible.builtin.debug: |
| 104 |
var: cn_update_check_task |
| 105 |
|
| 106 |
- name: Check module call result |
| 107 |
ansible.builtin.assert: |
| 108 |
that: |
| 109 |
- cn_update_check_task is success |
| 110 |
- cn_update_check_task is changed |
| 111 |
|
| 112 |
- name: Update container |
| 113 |
community.general.scaleway_container: |
| 114 |
state: present |
| 115 |
name: '{{ name }}' |
| 116 |
region: '{{ scaleway_region }}' |
| 117 |
namespace_id: '{{ integration_container_namespace.container_namespace.id }}' |
| 118 |
registry_image: '{{ image }}' |
| 119 |
description: '{{ updated_description }}' |
| 120 |
environment_variables: '{{ environment_variables }}' |
| 121 |
secret_environment_variables: '{{ secret_environment_variables }}' |
| 122 |
port: '{{ port }}' |
| 123 |
register: cn_update_task |
| 124 |
|
| 125 |
- ansible.builtin.debug: |
| 126 |
var: cn_update_task |
| 127 |
|
| 128 |
- name: Check module call result |
| 129 |
ansible.builtin.assert: |
| 130 |
that: |
| 131 |
- cn_update_task is success |
| 132 |
- cn_update_task is changed |
| 133 |
- cn_update_task.container.status in ["created", "ready"] |
| 134 |
|
| 135 |
- name: Update container (Confirmation) |
| 136 |
community.general.scaleway_container: |
| 137 |
state: present |
| 138 |
name: '{{ name }}' |
| 139 |
region: '{{ scaleway_region }}' |
| 140 |
namespace_id: '{{ integration_container_namespace.container_namespace.id }}' |
| 141 |
registry_image: '{{ image }}' |
| 142 |
description: '{{ updated_description }}' |
| 143 |
environment_variables: '{{ environment_variables }}' |
| 144 |
secret_environment_variables: '{{ secret_environment_variables }}' |
| 145 |
port: '{{ port }}' |
| 146 |
register: cn_update_confirmation_task |
| 147 |
|
| 148 |
- ansible.builtin.debug: |
| 149 |
var: cn_update_confirmation_task |
| 150 |
|
| 151 |
- name: Check module call result |
| 152 |
ansible.builtin.assert: |
| 153 |
that: |
| 154 |
- cn_update_confirmation_task is success |
| 155 |
- cn_update_confirmation_task is not changed |
| 156 |
- cn_update_confirmation_task.container.status in ["created", "ready"] |
| 157 |
|
| 158 |
- name: Update container secret variables (Check) |
| 159 |
check_mode: true |
| 160 |
community.general.scaleway_container: |
| 161 |
state: present |
| 162 |
name: '{{ name }}' |
| 163 |
region: '{{ scaleway_region }}' |
| 164 |
namespace_id: '{{ integration_container_namespace.container_namespace.id }}' |
| 165 |
registry_image: '{{ image }}' |
| 166 |
description: '{{ updated_description }}' |
| 167 |
environment_variables: '{{ environment_variables }}' |
| 168 |
secret_environment_variables: '{{ updated_secret_environment_variables }}' |
| 169 |
port: '{{ port }}' |
| 170 |
register: cn_update_secret_check_task |
| 171 |
|
| 172 |
- ansible.builtin.debug: |
| 173 |
var: cn_update_secret_check_task |
| 174 |
|
| 175 |
- name: Check module call result |
| 176 |
ansible.builtin.assert: |
| 177 |
that: |
| 178 |
- cn_update_secret_check_task is success |
| 179 |
- cn_update_secret_check_task is changed |
| 180 |
|
| 181 |
- name: Update container secret variables |
| 182 |
community.general.scaleway_container: |
| 183 |
state: present |
| 184 |
name: '{{ name }}' |
| 185 |
region: '{{ scaleway_region }}' |
| 186 |
namespace_id: '{{ integration_container_namespace.container_namespace.id }}' |
| 187 |
registry_image: '{{ image }}' |
| 188 |
description: '{{ updated_description }}' |
| 189 |
environment_variables: '{{ environment_variables }}' |
| 190 |
secret_environment_variables: '{{ updated_secret_environment_variables }}' |
| 191 |
port: '{{ port }}' |
| 192 |
register: cn_update_secret_task |
| 193 |
|
| 194 |
- ansible.builtin.debug: |
| 195 |
var: cn_update_secret_task |
| 196 |
|
| 197 |
- name: Check module call result |
| 198 |
ansible.builtin.assert: |
| 199 |
that: |
| 200 |
- cn_update_secret_task is success |
| 201 |
- cn_update_secret_task is changed |
| 202 |
- cn_update_secret_task.container.status in ["created", "ready"] |
| 203 |
- "'hashed_value' in cn_update_secret_task.container.secret_environment_variables[0]" |
| 204 |
|
| 205 |
- name: Update container secret variables (Confirmation) |
| 206 |
community.general.scaleway_container: |
| 207 |
state: present |
| 208 |
name: '{{ name }}' |
| 209 |
region: '{{ scaleway_region }}' |
| 210 |
namespace_id: '{{ integration_container_namespace.container_namespace.id }}' |
| 211 |
registry_image: '{{ image }}' |
| 212 |
description: '{{ updated_description }}' |
| 213 |
environment_variables: '{{ environment_variables }}' |
| 214 |
secret_environment_variables: '{{ updated_secret_environment_variables }}' |
| 215 |
port: '{{ port }}' |
| 216 |
register: cn_update_secret_confirmation_task |
| 217 |
|
| 218 |
- ansible.builtin.debug: |
| 219 |
var: cn_update_secret_confirmation_task |
| 220 |
|
| 221 |
- name: Check module call result |
| 222 |
ansible.builtin.assert: |
| 223 |
that: |
| 224 |
- cn_update_secret_confirmation_task is success |
| 225 |
- cn_update_secret_confirmation_task is not changed |
| 226 |
- cn_update_secret_confirmation_task.container.status == "ready" |
| 227 |
- "'hashed_value' in cn_update_secret_confirmation_task.container.secret_environment_variables[0]" |
| 228 |
|
| 229 |
- name: Delete container (Check) |
| 230 |
check_mode: true |
| 231 |
community.general.scaleway_container: |
| 232 |
state: absent |
| 233 |
name: '{{ name }}' |
| 234 |
region: '{{ scaleway_region }}' |
| 235 |
description: '{{ description }}' |
| 236 |
namespace_id: '{{ integration_container_namespace.container_namespace.id }}' |
| 237 |
registry_image: '{{ image }}' |
| 238 |
register: cn_deletion_check_task |
| 239 |
|
| 240 |
- ansible.builtin.debug: |
| 241 |
var: cn_deletion_check_task |
| 242 |
|
| 243 |
- name: Check module call result |
| 244 |
ansible.builtin.assert: |
| 245 |
that: |
| 246 |
- cn_deletion_check_task is success |
| 247 |
- cn_deletion_check_task is changed |
| 248 |
|
| 249 |
- name: Delete container |
| 250 |
community.general.scaleway_container: |
| 251 |
state: absent |
| 252 |
name: '{{ name }}' |
| 253 |
region: '{{ scaleway_region }}' |
| 254 |
description: '{{ description }}' |
| 255 |
namespace_id: '{{ integration_container_namespace.container_namespace.id }}' |
| 256 |
registry_image: '{{ image }}' |
| 257 |
register: cn_deletion_task |
| 258 |
|
| 259 |
- name: Check module call result |
| 260 |
ansible.builtin.assert: |
| 261 |
that: |
| 262 |
- cn_deletion_task is success |
| 263 |
- cn_deletion_task is changed |
| 264 |
|
| 265 |
- name: Delete container (Confirmation) |
| 266 |
community.general.scaleway_container: |
| 267 |
state: absent |
| 268 |
name: '{{ name }}' |
| 269 |
region: '{{ scaleway_region }}' |
| 270 |
description: '{{ description }}' |
| 271 |
namespace_id: '{{ integration_container_namespace.container_namespace.id }}' |
| 272 |
registry_image: '{{ image }}' |
| 273 |
register: cn_deletion_confirmation_task |
| 274 |
|
| 275 |
- ansible.builtin.debug: |
| 276 |
var: cn_deletion_confirmation_task |
| 277 |
|
| 278 |
- name: Check module call result |
| 279 |
ansible.builtin.assert: |
| 280 |
that: |
| 281 |
- cn_deletion_confirmation_task is success |
| 282 |
- cn_deletion_confirmation_task is not changed |
| 283 |
|
| 284 |
- name: Delete container namespace |
| 285 |
community.general.scaleway_container_namespace: |
| 286 |
state: absent |
| 287 |
name: '{{ container_namespace_name }}' |
| 288 |
region: '{{ scaleway_region }}' |
| 289 |
description: '{{ description }}' |
| 290 |
project_id: '{{ scw_project }}' |