[Scaleway] Add module to manage container namespaces (#5416)

* [Scaleway] Add module to manage container namespaces

Signed-off-by: Lunik <lunik@tiwabbit.fr>

* Fix CI

Signed-off-by: Lunik <lunik@tiwabbit.fr>

* fix botmeta

Signed-off-by: Lunik <lunik@tiwabbit.fr>

* fix typo in loop var name

Signed-off-by: Lunik <lunik@tiwabbit.fr>

* Add missing required lib check

Signed-off-by: Lunik <lunik@tiwabbit.fr>

* fix integration tests assertions

Signed-off-by: Lunik <lunik@tiwabbit.fr>

Signed-off-by: Lunik <lunik@tiwabbit.fr>
This commit is contained in:
Guillaume MARTINEZ 2022-11-05 21:44:33 +01:00 committed by GitHub
parent db7e5f12f5
commit 1e17ec13b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 774 additions and 0 deletions

View file

@ -0,0 +1,6 @@
# Copyright (c) 2022, Guillaume MARTINEZ <lunik@tiwabbit.fr>
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
cloud/scaleway
unsupported

View file

@ -0,0 +1,15 @@
---
# Copyright (c) 2022, Guillaume MARTINEZ <lunik@tiwabbit.fr>
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
scaleway_region: fr-par
name: cn-ansible-test
description: Container namespace used for testing scaleway_container_namespace ansible module
updated_description: Container namespace used for testing scaleway_container_namespace ansible module (Updated description)
environment_variables:
MY_VAR: my_value
secret_environment_variables:
MY_SECRET_VAR: my_secret_value
updated_secret_environment_variables:
MY_SECRET_VAR: my_other_secret_value

View file

@ -0,0 +1,255 @@
---
####################################################################
# WARNING: These are designed specifically for Ansible tests #
# and should not be used as examples of how to write Ansible roles #
####################################################################
# Copyright (c) 2022, Guillaume MARTINEZ <lunik@tiwabbit.fr>
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
- name: Create a container namespace (Check)
check_mode: yes
community.general.scaleway_container_namespace:
state: present
name: '{{ name }}'
region: '{{ scaleway_region }}'
project_id: '{{ scw_project }}'
description: '{{ description }}'
environment_variables: '{{ environment_variables }}'
secret_environment_variables: '{{ secret_environment_variables }}'
register: cn_creation_check_task
- ansible.builtin.debug:
var: cn_creation_check_task
- name: Check module call result
ansible.builtin.assert:
that:
- cn_creation_check_task is success
- cn_creation_check_task is changed
- name: Create container_namespace
community.general.scaleway_container_namespace:
state: present
name: '{{ name }}'
region: '{{ scaleway_region }}'
project_id: '{{ scw_project }}'
description: '{{ description }}'
environment_variables: '{{ environment_variables }}'
secret_environment_variables: '{{ secret_environment_variables }}'
register: cn_creation_task
- ansible.builtin.debug:
var: cn_creation_task
- name: Check module call result
ansible.builtin.assert:
that:
- cn_creation_task is success
- cn_creation_task is changed
- cn_creation_task.container_namespace.status == "ready"
- name: Create container namespace (Confirmation)
community.general.scaleway_container_namespace:
state: present
name: '{{ name }}'
region: '{{ scaleway_region }}'
project_id: '{{ scw_project }}'
description: '{{ description }}'
environment_variables: '{{ environment_variables }}'
secret_environment_variables: '{{ secret_environment_variables }}'
register: cn_creation_confirmation_task
- ansible.builtin.debug:
var: cn_creation_confirmation_task
- name: Check module call result
ansible.builtin.assert:
that:
- cn_creation_confirmation_task is success
- cn_creation_confirmation_task is not changed
- cn_creation_confirmation_task.container_namespace.status == "ready"
- name: Update container namespace (Check)
check_mode: yes
community.general.scaleway_container_namespace:
state: present
name: '{{ name }}'
region: '{{ scaleway_region }}'
project_id: '{{ scw_project }}'
description: '{{ updated_description }}'
environment_variables: '{{ environment_variables }}'
secret_environment_variables: '{{ secret_environment_variables }}'
register: cn_update_check_task
- ansible.builtin.debug:
var: cn_update_check_task
- name: Check module call result
ansible.builtin.assert:
that:
- cn_update_check_task is success
- cn_update_check_task is changed
- name: Update container namespace
community.general.scaleway_container_namespace:
state: present
name: '{{ name }}'
region: '{{ scaleway_region }}'
project_id: '{{ scw_project }}'
description: '{{ updated_description }}'
environment_variables: '{{ environment_variables }}'
secret_environment_variables: '{{ secret_environment_variables }}'
register: cn_update_task
- ansible.builtin.debug:
var: cn_update_task
- name: Check module call result
ansible.builtin.assert:
that:
- cn_update_task is success
- cn_update_task is changed
- cn_update_task.container_namespace.status == "ready"
- name: Update container namespace (Confirmation)
community.general.scaleway_container_namespace:
state: present
name: '{{ name }}'
region: '{{ scaleway_region }}'
project_id: '{{ scw_project }}'
description: '{{ updated_description }}'
environment_variables: '{{ environment_variables }}'
secret_environment_variables: '{{ secret_environment_variables }}'
register: cn_update_confirmation_task
- ansible.builtin.debug:
var: cn_update_confirmation_task
- name: Check module call result
ansible.builtin.assert:
that:
- cn_update_confirmation_task is success
- cn_update_confirmation_task is not changed
- cn_update_confirmation_task.container_namespace.status == "ready"
- name: Update container namespace secret variables (Check)
check_mode: yes
community.general.scaleway_container_namespace:
state: present
name: '{{ name }}'
region: '{{ scaleway_region }}'
project_id: '{{ scw_project }}'
description: '{{ updated_description }}'
environment_variables: '{{ environment_variables }}'
secret_environment_variables: '{{ updated_secret_environment_variables }}'
register: cn_update_secret_check_task
- ansible.builtin.debug:
var: cn_update_secret_check_task
- name: Check module call result
ansible.builtin.assert:
that:
- cn_update_secret_check_task is success
- cn_update_secret_check_task is changed
- name: Update container namespace secret variables
community.general.scaleway_container_namespace:
state: present
name: '{{ name }}'
region: '{{ scaleway_region }}'
project_id: '{{ scw_project }}'
description: '{{ updated_description }}'
environment_variables: '{{ environment_variables }}'
secret_environment_variables: '{{ updated_secret_environment_variables }}'
register: cn_update_secret_task
- ansible.builtin.debug:
var: cn_update_secret_task
- name: Check module call result
ansible.builtin.assert:
that:
- cn_update_secret_task is success
- cn_update_secret_task is changed
- cn_update_secret_task.container_namespace.status == "ready"
- "'hashed_value' in cn_update_secret_task.container_namespace.secret_environment_variables[0]"
- name: Update container namespace secret variables (Confirmation)
community.general.scaleway_container_namespace:
state: present
name: '{{ name }}'
region: '{{ scaleway_region }}'
project_id: '{{ scw_project }}'
description: '{{ updated_description }}'
environment_variables: '{{ environment_variables }}'
secret_environment_variables: '{{ updated_secret_environment_variables }}'
register: cn_update_secret_congfirmation_task
- ansible.builtin.debug:
var: cn_update_secret_confirmation_task
- name: Check module call result
ansible.builtin.assert:
that:
- cn_update_secret_confirmation_task is success
- cn_update_secret_confirmation_task is not changed
- cn_update_secret_confirmation_task.container_namespace.status == "ready"
- "'hashed_value' in cn_update_secret_confirmation_task.container_namespace.secret_environment_variables[0]"
- name: Delete container namespace (Check)
check_mode: yes
community.general.scaleway_container_namespace:
state: absent
name: '{{ name }}'
region: '{{ scaleway_region }}'
description: '{{ description }}'
project_id: '{{ scw_project }}'
register: cn_deletion_check_task
- ansible.builtin.debug:
var: cn_deletion_check_task
- name: Check module call result
ansible.builtin.assert:
that:
- cn_deletion_check_task is success
- cn_deletion_check_task is changed
- name: Delete container namespace
community.general.scaleway_container_namespace:
state: absent
name: '{{ name }}'
region: '{{ scaleway_region }}'
description: '{{ description }}'
project_id: '{{ scw_project }}'
register: cn_deletion_task
- ansible.builtin.debug:
var: cn_deletion_task
- name: Check module call result
ansible.builtin.assert:
that:
- cn_deletion_task is success
- cn_deletion_task is changed
- name: Delete container namespace (Confirmation)
community.general.scaleway_container_namespace:
state: absent
name: '{{ name }}'
region: '{{ scaleway_region }}'
description: '{{ description }}'
project_id: '{{ scw_project }}'
register: cn_deletion_confirmation_task
- ansible.builtin.debug:
var: cn_deletion_confirmation_task
- name: Check module call result
ansible.builtin.assert:
that:
- cn_deletion_confirmation_task is success
- cn_deletion_confirmation_task is not changed

View file

@ -0,0 +1,6 @@
# Copyright (c) 2022, Guillaume MARTINEZ <lunik@tiwabbit.fr>
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
cloud/scaleway
unsupported

View file

@ -0,0 +1,13 @@
---
# Copyright (c) 2022, Guillaume MARTINEZ <lunik@tiwabbit.fr>
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
scaleway_region: fr-par
name: cn-ansible-test
description: Container namespace used for testing scaleway_container_namespace_info ansible module
updated_description: Container namespace used for testing scaleway_container_namespace_info ansible module (Updated description)
environment_variables:
MY_VAR: my_value
secret_environment_variables:
MY_SECRET_VAR: my_secret_value

View file

@ -0,0 +1,41 @@
---
####################################################################
# WARNING: These are designed specifically for Ansible tests #
# and should not be used as examples of how to write Ansible roles #
####################################################################
# Copyright (c) 2022, Guillaume MARTINEZ <lunik@tiwabbit.fr>
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
- name: Create container_namespace
community.general.scaleway_container_namespace:
state: present
name: '{{ name }}'
region: '{{ scaleway_region }}'
project_id: '{{ scw_project }}'
description: '{{ description }}'
- name: Get container namespace info
community.general.scaleway_container_namespace_info:
name: '{{ name }}'
region: '{{ scaleway_region }}'
project_id: '{{ scw_project }}'
register: cn_info_task
- ansible.builtin.debug:
var: cn_info_task
- name: Check module call result
ansible.builtin.assert:
that:
- cn_info_task is success
- cn_info_task is not changed
- name: Delete container namespace
community.general.scaleway_container_namespace:
state: absent
name: '{{ name }}'
region: '{{ scaleway_region }}'
description: '{{ description }}'
project_id: '{{ scw_project }}'