summaryrefslogtreecommitdiffstats
path: root/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests
diff options
context:
space:
mode:
Diffstat (limited to 'collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests')
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/cloud-config-cloudscale.ini.template2
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/aliases1
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/defaults/main.yml20
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_floating_ips.yml19
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_networks.yml17
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_objects_users.yml17
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_server_groups.yml17
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_servers.yml24
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_volumes.yml17
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/main.yml6
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/meta/main.yml3
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/tasks/deprecation_warning.yml12
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/tasks/floating_ip.yml158
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/tasks/main.yml38
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/tasks/unassigned.yml27
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/network/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/network/meta/main.yml3
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/network/tasks/failures.yml44
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/network/tasks/main.yml8
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/network/tasks/tests.yml159
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/objects_user/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/objects_user/meta/main.yml3
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/objects_user/tasks/failures.yml44
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/objects_user/tasks/main.yml8
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/objects_user/tasks/tests.yml151
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/defaults/main.yml2
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/meta/main.yml3
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/tasks/failures.yml53
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/tasks/main.yml11
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/tasks/tests.yml676
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server_group/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server_group/meta/main.yml3
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server_group/tasks/failures.yml45
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server_group/tasks/main.yml8
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server_group/tasks/tests.yml180
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/defaults/main.yml2
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/meta/main.yml3
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/tasks/failures.yml82
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/tasks/main.yml10
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/tasks/setup.yml13
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/tasks/tests.yml243
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/meta/main.yml3
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/cleanup.yml5
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/failures.yml38
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/main.yml12
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/setup.yml9
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/tests.yml260
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/requirements.txt1
-rw-r--r--collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/sanity/ignore-2.10.txt0
53 files changed, 2474 insertions, 0 deletions
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/cloud-config-cloudscale.ini.template b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/cloud-config-cloudscale.ini.template
new file mode 100644
index 00000000..5fa5d5fc
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/cloud-config-cloudscale.ini.template
@@ -0,0 +1,2 @@
+[default]
+cloudscale_api_token = @API_TOKEN
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/aliases b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/aliases
new file mode 100644
index 00000000..136c05e0
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/aliases
@@ -0,0 +1 @@
+hidden
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/defaults/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/defaults/main.yml
new file mode 100644
index 00000000..6a51b89c
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/defaults/main.yml
@@ -0,0 +1,20 @@
+---
+# The image to use for test servers
+cloudscale_test_image: 'debian-10'
+
+# Alternate test image to use if a different image is required
+cloudscale_alt_test_image: 'ubuntu-20.04'
+
+# The flavor to use for test servers
+cloudscale_test_flavor: 'flex-2'
+
+# SSH key to use for test servers
+cloudscale_test_ssh_key: |
+ ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSPmiqkvDH1/+MDAVDZT8381aYqp73Odz8cnD5hegNhqtXajqtiH0umVg7HybX3wt1HjcrwKJovZURcIbbcDvzdH2bnYbF93T4OLXA0bIfuIp6M86x1iutFtXdpN3TTicINrmSXEE2Ydm51iMu77B08ZERjVaToya2F7vC+egfoPvibf7OLxE336a5tPCywavvNihQjL8sjgpDT5AAScjb3YqK/6VLeQ18Ggt8/ufINsYkb+9/Ji/3OcGFeflnDXq80vPUyF3u4iIylob6RSZenC38cXmQB05tRNxS1B6BXCjMRdy0v4pa7oKM2GA4ADKpNrr0RI9ed+peRFwmsclH test@ansible
+
+# The zone to use to test servers
+cloudscale_test_zone: 'lpg1'
+cloudscale_test_alt_zone: 'rma1'
+
+# The region to use to request floating IPs
+cloudscale_test_region: 'lpg'
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_floating_ips.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_floating_ips.yml
new file mode 100644
index 00000000..66360859
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_floating_ips.yml
@@ -0,0 +1,19 @@
+---
+- name: List all floating IPs
+ uri:
+ url: 'https://api.cloudscale.ch/v1/floating-ips'
+ headers:
+ Authorization: 'Bearer {{ cloudscale_api_token }}'
+ status_code: 200
+ register: floating_ip_list
+
+- name: Remove all floating IPs created by this test run
+ cloudscale_ch.cloud.floating_ip:
+ # TODO: fix
+ # ip: '{{ item.network | ipaddr("address") }}'
+ ip: '{{ item.network.split("/")[0] }}'
+ state: 'absent'
+ when: "cloudscale_resource_prefix in (item.reverse_ptr | string ) or ('ansible_name' in item.tags and cloudscale_resource_prefix in item.tags['ansible_name'])"
+ with_items: '{{ floating_ip_list.json }}'
+ loop_control:
+ label: '{{ item.reverse_ptr }} ({{ item.network }})'
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_networks.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_networks.yml
new file mode 100644
index 00000000..e02c83b1
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_networks.yml
@@ -0,0 +1,17 @@
+---
+- name: List all networks
+ uri:
+ url: 'https://api.cloudscale.ch/v1/networks'
+ headers:
+ Authorization: 'Bearer {{ cloudscale_api_token }}'
+ status_code: 200
+ register: network_list
+
+- name: Remove all networks created by this test run
+ cloudscale_ch.cloud.network:
+ uuid: '{{ item.uuid }}'
+ state: absent
+ when: cloudscale_resource_prefix in item.name
+ with_items: '{{ network_list.json }}'
+ loop_control:
+ label: '{{ item.name }} ({{ item.uuid }})'
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_objects_users.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_objects_users.yml
new file mode 100644
index 00000000..2ddb1743
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_objects_users.yml
@@ -0,0 +1,17 @@
+---
+- name: List all objects users
+ uri:
+ url: 'https://api.cloudscale.ch/v1/objects-users'
+ headers:
+ Authorization: 'Bearer {{ cloudscale_api_token }}'
+ status_code: 200
+ register: objects_user_list
+
+- name: Remove all objects users created by this test run
+ cloudscale_ch.cloud.objects_user:
+ id: '{{ item.id }}'
+ state: absent
+ when: cloudscale_resource_prefix in item.display_name
+ with_items: '{{ objects_user_list.json }}'
+ loop_control:
+ label: '{{ item.display_name }} ({{ item.id }})'
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_server_groups.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_server_groups.yml
new file mode 100644
index 00000000..cc85b137
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_server_groups.yml
@@ -0,0 +1,17 @@
+---
+- name: List all server groups
+ uri:
+ url: 'https://api.cloudscale.ch/v1/server-groups'
+ headers:
+ Authorization: 'Bearer {{ cloudscale_api_token }}'
+ status_code: 200
+ register: server_group_list
+
+- name: Remove all server groups created by this test run
+ cloudscale_ch.cloud.server_group:
+ uuid: '{{ item.uuid }}'
+ state: absent
+ when: cloudscale_resource_prefix in item.name
+ with_items: '{{ server_group_list.json }}'
+ loop_control:
+ label: '{{ item.name }} ({{ item.uuid }})'
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_servers.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_servers.yml
new file mode 100644
index 00000000..d8c3a0fa
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_servers.yml
@@ -0,0 +1,24 @@
+---
+- name: List all servers
+ uri:
+ url: 'https://api.cloudscale.ch/v1/servers'
+ headers:
+ Authorization: 'Bearer {{ cloudscale_api_token }}'
+ status_code: 200
+ register: server_list
+ until: server_list is not failed
+ retries: 5
+ delay: 3
+
+- name: Remove all servers created by this test run
+ cloudscale_ch.cloud.server:
+ uuid: '{{ item.uuid }}'
+ state: 'absent'
+ when: cloudscale_resource_prefix in item.name
+ with_items: '{{ server_list.json }}'
+ register: res
+ loop_control:
+ label: '{{ item.name }} ({{ item.uuid }})'
+ until: res is not failed
+ retries: 5
+ delay: 3
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_volumes.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_volumes.yml
new file mode 100644
index 00000000..7ce17ba3
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/cleanup_volumes.yml
@@ -0,0 +1,17 @@
+---
+- name: List all volumes
+ uri:
+ url: 'https://api.cloudscale.ch/v1/volumes'
+ headers:
+ Authorization: 'Bearer {{ cloudscale_api_token }}'
+ status_code: 200
+ register: volume_list
+
+- name: Remove all volumes created by this test run
+ cloudscale_ch.cloud.volume:
+ uuid: '{{ item.uuid }}'
+ state: 'absent'
+ when: cloudscale_resource_prefix in item.name
+ with_items: '{{ volume_list.json }}'
+ loop_control:
+ label: '{{ item.name }} ({{ item.uuid }})'
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/main.yml
new file mode 100644
index 00000000..fa0be6eb
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/common/tasks/main.yml
@@ -0,0 +1,6 @@
+---
+# Password to use for test server
+# This has to be set as a fact, otherwise a new password will be generated
+# on every variable access.
+- set_fact:
+ cloudscale_test_password: "{{ lookup('password', '/dev/null length=15 chars=ascii_letters') }}"
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/aliases b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/aliases
new file mode 100644
index 00000000..c200a3d2
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/aliases
@@ -0,0 +1,2 @@
+cloud/cloudscale
+unsupported
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/meta/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/meta/main.yml
new file mode 100644
index 00000000..2083f0e1
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - common
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/tasks/deprecation_warning.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/tasks/deprecation_warning.yml
new file mode 100644
index 00000000..f950a8f0
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/tasks/deprecation_warning.yml
@@ -0,0 +1,12 @@
+---
+# TODO: To be removed with 2.0.0
+- name: Test deprecations
+ cloudscale_ch.cloud.floating_ip:
+ ip_version: 4
+ register: floating_ip
+ check_mode: true
+- name: Verify test deprecations
+ assert:
+ that:
+ - floating_ip is changed
+ - "'deprecations' in floating_ip"
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/tasks/floating_ip.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/tasks/floating_ip.yml
new file mode 100644
index 00000000..d58d19b6
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/tasks/floating_ip.yml
@@ -0,0 +1,158 @@
+- name: Request regional floating IP in check mode
+ cloudscale_ch.cloud.floating_ip:
+ name: '{{ cloudscale_resource_prefix }}-floating-ip'
+ server: '{{ test01.uuid }}'
+ ip_version: '{{ item.ip_version }}'
+ reverse_ptr: '{{ item.reverse_ptr | default(omit) }}'
+ prefix_length: '{{ item.prefix_length | default(omit) }}'
+ region: '{{ cloudscale_test_region }}'
+ tags:
+ project: ansible-test
+ stage: production
+ sla: 24-7
+ check_mode: true
+ register: floating_ip
+- name: Verify request floating IP in check mode
+ assert:
+ that:
+ - floating_ip is changed
+ - floating_ip.state == 'absent'
+
+- name: Request regional floating IP
+ cloudscale_ch.cloud.floating_ip:
+ name: '{{ cloudscale_resource_prefix }}-floating-ip'
+ server: '{{ test01.uuid }}'
+ ip_version: '{{ item.ip_version }}'
+ reverse_ptr: '{{ item.reverse_ptr | default(omit) }}'
+ prefix_length: '{{ item.prefix_length | default(omit) }}'
+ region: '{{ cloudscale_test_region }}'
+ tags:
+ project: ansible-test
+ stage: production
+ sla: 24-7
+ register: floating_ip
+- name: Verify request regional floating IP
+ assert:
+ that:
+ - floating_ip is changed
+ - floating_ip.region.slug == cloudscale_test_region
+ # - (item.ip_version == 4 and floating_ip.ip | ipv4) or (item.ip_version == 6 and floating_ip.ip | ipv6)
+ - floating_ip.server == test01.uuid
+ - floating_ip.tags.project == 'ansible-test'
+ - floating_ip.tags.stage == 'production'
+ - floating_ip.tags.sla == '24-7'
+
+- name: Request regional floating IP idempotence
+ cloudscale_ch.cloud.floating_ip:
+ name: '{{ cloudscale_resource_prefix }}-floating-ip'
+ server: '{{ test01.uuid }}'
+ ip_version: '{{ item.ip_version }}'
+ reverse_ptr: '{{ item.reverse_ptr | default(omit) }}'
+ prefix_length: '{{ item.prefix_length | default(omit) }}'
+ region: '{{ cloudscale_test_region }}'
+ tags:
+ project: ansible-test
+ stage: production
+ sla: 24-7
+ register: floating_ip_idempotence
+- name: Verify request regional floating IP idempotence
+ assert:
+ that:
+ - floating_ip_idempotence is not changed
+ - floating_ip_idempotence.server == test01.uuid
+ - floating_ip.region.slug == cloudscale_test_region
+ - floating_ip.tags.project == 'ansible-test'
+ - floating_ip.tags.stage == 'production'
+ - floating_ip.tags.sla == '24-7'
+
+- name: Request regional floating IP different IP version in check mode
+ cloudscale_ch.cloud.floating_ip:
+ name: '{{ cloudscale_resource_prefix }}-floating-ip'
+ ip_version: '{{ 6 if item.ip_version == 4 else 4 }}'
+ reverse_ptr: '{{ item.reverse_ptr | default(omit) }}'
+ prefix_length: '{{ item.prefix_length | default(omit) }}'
+ region: '{{ cloudscale_test_region }}'
+ tags:
+ project: ansible-test
+ stage: production
+ sla: 24-7
+ register: floating_ip_version_differ
+ check_mode: true
+- name: Verify Request regional floating IP different IP version in check mode
+ assert:
+ that:
+ - floating_ip_version_differ is changed
+ - not floating_ip_version_differ.network
+
+- name: Request global floating IP
+ cloudscale_ch.cloud.floating_ip:
+ name: '{{ cloudscale_resource_prefix }}-global-floating-ip'
+ ip_version: '{{ item.ip_version }}'
+ reverse_ptr: '{{ item.reverse_ptr | default(omit) }}'
+ prefix_length: '{{ item.prefix_length | default(omit) }}'
+ type: 'global'
+ register: global_floating_ip
+- name: Verify global floating IP
+ assert:
+ that:
+ - global_floating_ip is changed
+ - global_floating_ip.region == None
+ - global_floating_ip.type == 'global'
+ # - (item.ip_version == 4 and global_floating_ip.ip | ipv4) or (item.ip_version == 6 and global_floating_ip.ip | ipv6)
+ - not global_floating_ip.server
+
+- name: Remove global floating IP
+ cloudscale_ch.cloud.floating_ip:
+ ip: '{{ global_floating_ip.ip }}'
+ state: 'absent'
+ register: global_floating_ip
+- name: Verify release of global floating IP
+ assert:
+ that:
+ - global_floating_ip is changed
+ - global_floating_ip.state == 'absent'
+
+- name: Move floating IP to second server
+ cloudscale_ch.cloud.floating_ip:
+ server: '{{ test02.uuid }}'
+ ip: '{{ floating_ip.ip }}'
+ register: move_ip
+- name: Verify move floating IPv4 to second server
+ assert:
+ that:
+ - move_ip is changed
+ - move_ip.server == test02.uuid
+
+- name: Remove floating IP in check mode
+ cloudscale_ch.cloud.floating_ip:
+ ip: '{{ floating_ip.ip }}'
+ state: 'absent'
+ register: release_ip
+ check_mode: true
+- name: Verify Remove floating IP in check mode
+ assert:
+ that:
+ - release_ip is changed
+ - release_ip.state == 'present'
+
+- name: Remove floating IP
+ cloudscale_ch.cloud.floating_ip:
+ ip: '{{ floating_ip.ip }}'
+ state: 'absent'
+ register: release_ip
+- name: Verify Remove floating IP
+ assert:
+ that:
+ - release_ip is changed
+ - release_ip.state == 'absent'
+
+- name: Remove floating IP idempotence
+ cloudscale_ch.cloud.floating_ip:
+ ip: '{{ floating_ip.ip }}'
+ state: 'absent'
+ register: release_ip
+- name: Verify Remove floating IP idempotence
+ assert:
+ that:
+ - release_ip is not changed
+ - release_ip.state == 'absent'
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/tasks/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/tasks/main.yml
new file mode 100644
index 00000000..67be9eb5
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/tasks/main.yml
@@ -0,0 +1,38 @@
+---
+- import_tasks: deprecation_warning.yml
+
+- name: Cloudscale floating IP tests
+ block:
+ - name: Create a server
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test01'
+ flavor: '{{ cloudscale_test_flavor }}'
+ image: '{{ cloudscale_test_image }}'
+ ssh_keys: '{{ cloudscale_test_ssh_key }}'
+ zone: '{{ cloudscale_test_zone }}'
+ register: test01
+
+ - name: Create a second server
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test02'
+ flavor: '{{ cloudscale_test_flavor }}'
+ image: '{{ cloudscale_test_image }}'
+ ssh_keys: '{{ cloudscale_test_ssh_key }}'
+ zone: '{{ cloudscale_test_zone }}'
+ register: test02
+
+ - include_tasks: floating_ip.yml
+ loop:
+ - { 'ip_version': 4, 'reverse_ptr': '{{ cloudscale_resource_prefix }}-4.example.com' }
+ - { 'ip_version': 6, 'reverse_ptr': '{{ cloudscale_resource_prefix }}-6.example.com' }
+ - { 'ip_version': 6, 'prefix_length': 56 }
+
+ - import_tasks: unassigned.yml
+
+ always:
+ - import_role:
+ name: common
+ tasks_from: cleanup_servers
+ - import_role:
+ name: common
+ tasks_from: cleanup_floating_ips
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/tasks/unassigned.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/tasks/unassigned.yml
new file mode 100644
index 00000000..4ee4ed08
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/floating_ip/tasks/unassigned.yml
@@ -0,0 +1,27 @@
+---
+- name: Assign Floating IP to server test01
+ cloudscale_ch.cloud.floating_ip:
+ name: '{{ cloudscale_resource_prefix }}-unassigned'
+ ip_version: 6
+ server: '{{ test01.uuid }}'
+ reverse_ptr: '{{ cloudscale_resource_prefix }}-unassigned.example.com'
+ region: '{{ cloudscale_test_region }}'
+ register: floating_ip
+
+# The only way to have an unassigned floating IP is to delete the server
+# where the floating IP is currently assigned.
+- name: Delete server test01
+ cloudscale_ch.cloud.server:
+ uuid: '{{ test01.uuid }}'
+ state: 'absent'
+
+- name: Do not fail if floating IP is unassigned
+ cloudscale_ch.cloud.floating_ip:
+ ip: '{{ floating_ip.ip }}'
+ register: floating_ip_not_fail
+- name: Verify do not fail if floating IP is unassigned
+ assert:
+ that:
+ - floating_ip_not_fail is successful
+ - floating_ip_not_fail is not changed
+ - floating_ip_not_fail.server == None
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/network/aliases b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/network/aliases
new file mode 100644
index 00000000..c200a3d2
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/network/aliases
@@ -0,0 +1,2 @@
+cloud/cloudscale
+unsupported
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/network/meta/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/network/meta/main.yml
new file mode 100644
index 00000000..2083f0e1
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/network/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - common
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/network/tasks/failures.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/network/tasks/failures.yml
new file mode 100644
index 00000000..57efebd5
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/network/tasks/failures.yml
@@ -0,0 +1,44 @@
+---
+- name: Fail missing params
+ cloudscale_ch.cloud.network:
+ register: net
+ ignore_errors: True
+- name: 'VERIFY: Fail name and UUID'
+ assert:
+ that:
+ - net is failed
+
+- name: Create two networks with the same name
+ uri:
+ url: 'https://api.cloudscale.ch/v1/networks'
+ method: POST
+ headers:
+ Authorization: 'Bearer {{ cloudscale_api_token }}'
+ body:
+ name: '{{ cloudscale_resource_prefix }}-duplicate'
+ body_format: json
+ status_code: 201
+ register: duplicate
+ with_sequence: count=2
+
+- name: Try access to duplicate name
+ cloudscale_ch.cloud.network:
+ name: '{{ cloudscale_resource_prefix }}-duplicate'
+ register: net
+ ignore_errors: True
+- name: 'VERIFY: Try access to duplicate name'
+ assert:
+ that:
+ - net is failed
+ - net.msg.startswith("More than one networks resource with 'name' exists")
+
+- name: Fail network creation with UUID
+ cloudscale_ch.cloud.network:
+ uuid: ea3b39a3-77a8-4d0b-881d-0bb00a1e7f48
+ register: net
+ ignore_errors: True
+- name: 'VERIFY: Fail network creation with UUID'
+ assert:
+ that:
+ - net is failed
+ - net.msg.startswith("state is present but all of the following are missing")
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/network/tasks/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/network/tasks/main.yml
new file mode 100644
index 00000000..a89bd140
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/network/tasks/main.yml
@@ -0,0 +1,8 @@
+---
+- block:
+ - import_tasks: failures.yml
+ - import_tasks: tests.yml
+ always:
+ - import_role:
+ name: common
+ tasks_from: cleanup_networks
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/network/tasks/tests.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/network/tasks/tests.yml
new file mode 100644
index 00000000..926a452d
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/network/tasks/tests.yml
@@ -0,0 +1,159 @@
+---
+- name: Create network in check mode
+ cloudscale_ch.cloud.network:
+ name: '{{ cloudscale_resource_prefix }}-net'
+ tags:
+ project: ansible-test
+ stage: production
+ sla: 24-7
+ register: net
+ check_mode: yes
+- name: 'VERIFY: Create network in check mode'
+ assert:
+ that:
+ - net is changed
+ - net.name == '{{ cloudscale_resource_prefix }}-net'
+ - not net.uuid
+
+- name: Create network
+ cloudscale_ch.cloud.network:
+ name: '{{ cloudscale_resource_prefix }}-net'
+ zone: '{{ cloudscale_test_zone }}'
+ tags:
+ project: ansible-test
+ stage: production
+ sla: 24-7
+ register: net
+- name: 'VERIFY: Create network'
+ assert:
+ that:
+ - net is changed
+ - net.mtu == 9000
+ - net.name == '{{ cloudscale_resource_prefix }}-net'
+ - net.zone.slug == cloudscale_test_zone
+ - net.uuid
+ - net.tags.project == 'ansible-test'
+ - net.tags.stage == 'production'
+ - net.tags.sla == '24-7'
+
+- name: Remember uuid
+ set_fact:
+ network_uuid: '{{ net.uuid }}'
+
+- name: Create network idempotence
+ cloudscale_ch.cloud.network:
+ name: '{{ cloudscale_resource_prefix }}-net'
+ zone: '{{ cloudscale_test_zone }}'
+ tags:
+ project: ansible-test
+ stage: production
+ sla: 24-7
+ register: net
+- name: 'VERIFY: Create network idempotence'
+ assert:
+ that:
+ - net is not changed
+ - net.name == '{{ cloudscale_resource_prefix }}-net'
+ - net.zone.slug == cloudscale_test_zone
+ - net.uuid == network_uuid
+ - net.tags.project == 'ansible-test'
+ - net.tags.stage == 'production'
+ - net.tags.sla == '24-7'
+
+- name: Update network in check mode
+ cloudscale_ch.cloud.network:
+ uuid: '{{ network_uuid }}'
+ name: '{{ cloudscale_resource_prefix }}-net2'
+ tags:
+ project: ansible-test
+ stage: staging
+ sla: 8-5
+ register: net
+ check_mode: yes
+- name: 'VERIFY: Update network in check mode'
+ assert:
+ that:
+ - net is changed
+ - net.name == '{{ cloudscale_resource_prefix }}-net'
+ - net.uuid == network_uuid
+ - net.zone.slug == cloudscale_test_zone
+ - net.tags.project == 'ansible-test'
+ - net.tags.stage == 'production'
+ - net.tags.sla == '24-7'
+
+- name: Update network
+ cloudscale_ch.cloud.network:
+ uuid: '{{ network_uuid }}'
+ name: '{{ cloudscale_resource_prefix }}-net2'
+ tags:
+ project: ansible-test
+ stage: staging
+ sla: 8-5
+ register: net
+- name: 'VERIFY: Update network'
+ assert:
+ that:
+ - net is changed
+ - net.name == '{{ cloudscale_resource_prefix }}-net2'
+ - net.uuid == network_uuid
+ - net.zone.slug == cloudscale_test_zone
+ - net.tags.project == 'ansible-test'
+ - net.tags.stage == 'staging'
+ - net.tags.sla == '8-5'
+
+- name: Update network idempotence
+ cloudscale_ch.cloud.network:
+ uuid: '{{ network_uuid }}'
+ name: '{{ cloudscale_resource_prefix }}-net2'
+ tags:
+ project: ansible-test
+ stage: staging
+ sla: 8-5
+ register: net
+- name: 'VERIFY: Update network idempotence'
+ assert:
+ that:
+ - net is not changed
+ - net.name == '{{ cloudscale_resource_prefix }}-net2'
+ - net.uuid == network_uuid
+ - net.zone.slug == cloudscale_test_zone
+ - net.tags.project == 'ansible-test'
+ - net.tags.stage == 'staging'
+ - net.tags.sla == '8-5'
+
+- name: Delete network in check mode
+ cloudscale_ch.cloud.network:
+ name: '{{ cloudscale_resource_prefix }}-net2'
+ state: absent
+ register: net
+ check_mode: yes
+- name: 'VERIFY: Delete network in check mode'
+ assert:
+ that:
+ - net is changed
+ - net.name == '{{ cloudscale_resource_prefix }}-net2'
+ - net.uuid == network_uuid
+
+- name: Delete network
+ cloudscale_ch.cloud.network:
+ name: '{{ cloudscale_resource_prefix }}-net2'
+ state: absent
+ register: net
+- name: 'VERIFY: Delete network'
+ assert:
+ that:
+ - net is changed
+ - net.name == '{{ cloudscale_resource_prefix }}-net2'
+ - net.uuid == network_uuid
+
+- name: Delete network idempotence
+ cloudscale_ch.cloud.network:
+ name: '{{ cloudscale_resource_prefix }}-net2'
+ state: absent
+ register: net
+- name: 'VERIFY: Delete network idempotence'
+ assert:
+ that:
+ - net is not changed
+ - net.name == '{{ cloudscale_resource_prefix }}-net2'
+ - not net.uuid
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/objects_user/aliases b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/objects_user/aliases
new file mode 100644
index 00000000..c200a3d2
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/objects_user/aliases
@@ -0,0 +1,2 @@
+cloud/cloudscale
+unsupported
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/objects_user/meta/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/objects_user/meta/main.yml
new file mode 100644
index 00000000..2083f0e1
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/objects_user/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - common
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/objects_user/tasks/failures.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/objects_user/tasks/failures.yml
new file mode 100644
index 00000000..42d22d0d
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/objects_user/tasks/failures.yml
@@ -0,0 +1,44 @@
+---
+- name: Fail missing params
+ cloudscale_ch.cloud.objects_user:
+ register: obj
+ ignore_errors: True
+- name: 'VERIFY: Fail name and UUID'
+ assert:
+ that:
+ - obj is failed
+
+- name: Create two objects user with the same display_name
+ uri:
+ url: 'https://api.cloudscale.ch/v1/objects-users'
+ method: POST
+ headers:
+ Authorization: 'Bearer {{ cloudscale_api_token }}'
+ body:
+ display_name: '{{ cloudscale_resource_prefix }}-duplicate'
+ body_format: json
+ status_code: 201
+ register: duplicate
+ with_sequence: count=2
+
+- name: Try access to duplicate display_name
+ cloudscale_ch.cloud.objects_user:
+ display_name: '{{ cloudscale_resource_prefix }}-duplicate'
+ register: obj
+ ignore_errors: True
+- name: 'VERIFY: Try access to duplicate name'
+ assert:
+ that:
+ - obj is failed
+ - obj.msg.startswith("More than one objects-users resource with 'display_name' exists")
+
+- name: Fail creation with ID
+ cloudscale_ch.cloud.objects_user:
+ id: ea3b39a3-77a8-4d0b-881d-0bb00a1e7f48
+ register: obj
+ ignore_errors: True
+- name: 'VERIFY: Fail server group creation with ID'
+ assert:
+ that:
+ - obj is failed
+ - obj.msg.startswith("state is present but all of the following are missing")
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/objects_user/tasks/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/objects_user/tasks/main.yml
new file mode 100644
index 00000000..69171378
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/objects_user/tasks/main.yml
@@ -0,0 +1,8 @@
+---
+- block:
+ - import_tasks: failures.yml
+ - import_tasks: tests.yml
+ always:
+ - import_role:
+ name: common
+ tasks_from: cleanup_objects_users
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/objects_user/tasks/tests.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/objects_user/tasks/tests.yml
new file mode 100644
index 00000000..b77921aa
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/objects_user/tasks/tests.yml
@@ -0,0 +1,151 @@
+---
+- name: Create objects user in check mode
+ cloudscale_ch.cloud.objects_user:
+ display_name: '{{ cloudscale_resource_prefix }}-obj'
+ tags:
+ project: ansible-test
+ stage: production
+ sla: 24-7
+ register: obj
+ check_mode: yes
+- name: 'VERIFY: Create objects user in check mode'
+ assert:
+ that:
+ - obj is changed
+ - obj.display_name == '{{ cloudscale_resource_prefix }}-obj'
+ - not obj.id
+
+- name: Create objects user
+ cloudscale_ch.cloud.objects_user:
+ display_name: '{{ cloudscale_resource_prefix }}-obj'
+ tags:
+ project: ansible-test
+ stage: production
+ sla: 24-7
+ register: obj
+- name: 'VERIFY: Create objects user'
+ assert:
+ that:
+ - obj is changed
+ - obj.display_name == '{{ cloudscale_resource_prefix }}-obj'
+ - obj.id
+ - obj.tags.project == 'ansible-test'
+ - obj.tags.stage == 'production'
+ - obj.tags.sla == '24-7'
+
+- name: Remember uuid
+ set_fact:
+ objects_user_id: '{{ obj.id }}'
+
+- name: Create objects user idempotence
+ cloudscale_ch.cloud.objects_user:
+ display_name: '{{ cloudscale_resource_prefix }}-obj'
+ tags:
+ project: ansible-test
+ stage: production
+ sla: 24-7
+ register: obj
+- name: 'VERIFY: Create objects user idempotence'
+ assert:
+ that:
+ - obj is not changed
+ - obj.display_name == '{{ cloudscale_resource_prefix }}-obj'
+ - obj.id == objects_user_id
+ - obj.tags.project == 'ansible-test'
+ - obj.tags.stage == 'production'
+ - obj.tags.sla == '24-7'
+
+- name: Update objects user in check mode
+ cloudscale_ch.cloud.objects_user:
+ id: '{{ objects_user_id }}'
+ display_name: '{{ cloudscale_resource_prefix }}-obj2'
+ tags:
+ project: ansible-test
+ stage: staging
+ sla: 8-5
+ register: obj
+ check_mode: yes
+- name: 'VERIFY: Update objects user in check mode'
+ assert:
+ that:
+ - obj is changed
+ - obj.display_name == '{{ cloudscale_resource_prefix }}-obj'
+ - obj.id == objects_user_id
+ - obj.tags.project == 'ansible-test'
+ - obj.tags.stage == 'production'
+ - obj.tags.sla == '24-7'
+
+- name: Update objects user
+ cloudscale_ch.cloud.objects_user:
+ id: '{{ objects_user_id }}'
+ display_name: '{{ cloudscale_resource_prefix }}-obj2'
+ tags:
+ project: ansible-test
+ stage: staging
+ sla: 8-5
+ register: obj
+- name: 'VERIFY: Update objects user'
+ assert:
+ that:
+ - obj is changed
+ - obj.display_name == '{{ cloudscale_resource_prefix }}-obj2'
+ - obj.id == objects_user_id
+ - obj.tags.project == 'ansible-test'
+ - obj.tags.stage == 'staging'
+ - obj.tags.sla == '8-5'
+
+- name: Update objects user idempotence
+ cloudscale_ch.cloud.objects_user:
+ id: '{{ objects_user_id }}'
+ display_name: '{{ cloudscale_resource_prefix }}-obj2'
+ tags:
+ project: ansible-test
+ stage: staging
+ sla: 8-5
+ register: obj
+- name: 'VERIFY: Update objects user idempotence'
+ assert:
+ that:
+ - obj is not changed
+ - obj.display_name == '{{ cloudscale_resource_prefix }}-obj2'
+ - obj.id == objects_user_id
+ - obj.tags.project == 'ansible-test'
+ - obj.tags.stage == 'staging'
+ - obj.tags.sla == '8-5'
+
+- name: Delete objects user in check mode
+ cloudscale_ch.cloud.objects_user:
+ display_name: '{{ cloudscale_resource_prefix }}-obj2'
+ state: absent
+ register: obj
+ check_mode: yes
+- name: 'VERIFY: Delete objects user in check mode'
+ assert:
+ that:
+ - obj is changed
+ - obj.display_name == '{{ cloudscale_resource_prefix }}-obj2'
+ - obj.id == objects_user_id
+
+- name: Delete objects user
+ cloudscale_ch.cloud.objects_user:
+ display_name: '{{ cloudscale_resource_prefix }}-obj2'
+ state: absent
+ register: obj
+- name: 'VERIFY: Delete objects user'
+ assert:
+ that:
+ - obj is changed
+ - obj.display_name == '{{ cloudscale_resource_prefix }}-obj2'
+ - obj.id == objects_user_id
+
+- name: Delete objects user idempotence
+ cloudscale_ch.cloud.objects_user:
+ display_name: '{{ cloudscale_resource_prefix }}-obj2'
+ state: absent
+ register: obj
+- name: 'VERIFY: Delete objects user idempotence'
+ assert:
+ that:
+ - obj is not changed
+ - obj.display_name == '{{ cloudscale_resource_prefix }}-obj2'
+ - not obj.id
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/aliases b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/aliases
new file mode 100644
index 00000000..c200a3d2
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/aliases
@@ -0,0 +1,2 @@
+cloud/cloudscale
+unsupported
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/defaults/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/defaults/main.yml
new file mode 100644
index 00000000..6d8a0ff8
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/defaults/main.yml
@@ -0,0 +1,2 @@
+---
+cloudscale_test_flavor_2: flex-4
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/meta/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/meta/main.yml
new file mode 100644
index 00000000..2083f0e1
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - common
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/tasks/failures.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/tasks/failures.yml
new file mode 100644
index 00000000..8d9ebee0
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/tasks/failures.yml
@@ -0,0 +1,53 @@
+---
+- name: Fail missing params
+ cloudscale_ch.cloud.server:
+ register: srv
+ ignore_errors: True
+- name: 'VERIFY: Fail name and UUID'
+ assert:
+ that:
+ - srv is failed
+
+- name: Fail unexisting server group
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test-group'
+ flavor: '{{ cloudscale_test_flavor }}'
+ image: '{{ cloudscale_test_image }}'
+ password: '{{ cloudscale_test_password }}'
+ server_groups: '{{ cloudscale_resource_prefix }}-unexist-group'
+ ignore_errors: True
+ register: srv
+- name: 'VERIFY: Fail unexisting server group'
+ assert:
+ that:
+ - srv is failed
+ - srv.msg.startswith('Server group name or UUID not found')
+
+- name: Create two server groups with the same name
+ uri:
+ url: https://api.cloudscale.ch/v1/server-groups
+ method: POST
+ headers:
+ Authorization: 'Bearer {{ cloudscale_api_token }}'
+ body:
+ name: '{{ cloudscale_resource_prefix }}-duplicate'
+ type: anti-affinity
+ body_format: json
+ status_code: 201
+ register: duplicate
+ with_sequence: count=2
+
+- name: Try to use server groups with identical name
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test-group'
+ flavor: '{{ cloudscale_test_flavor }}'
+ image: '{{ cloudscale_test_image }}'
+ password: '{{ cloudscale_test_password }}'
+ server_groups: '{{ cloudscale_resource_prefix }}-duplicate'
+ ignore_errors: True
+ register: srv
+- name: 'VERIFY: Fail unexisting server group'
+ assert:
+ that:
+ - srv is failed
+ - srv.msg.startswith('More than one server group with name exists')
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/tasks/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/tasks/main.yml
new file mode 100644
index 00000000..90e35985
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/tasks/main.yml
@@ -0,0 +1,11 @@
+---
+- block:
+ - import_tasks: failures.yml
+ - import_tasks: tests.yml
+ always:
+ - import_role:
+ name: common
+ tasks_from: cleanup_servers
+ - import_role:
+ name: common
+ tasks_from: cleanup_server_groups
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/tasks/tests.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/tasks/tests.yml
new file mode 100644
index 00000000..5113ba53
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server/tasks/tests.yml
@@ -0,0 +1,676 @@
+---
+- name: Setup server groups
+ cloudscale_ch.cloud.server_group:
+ name: '{{ cloudscale_resource_prefix }}-group-{{ item }}'
+ type: anti-affinity
+ zone: '{{ cloudscale_test_zone }}'
+ with_sequence: count=2
+
+- name: Test create a running server in check mode
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test'
+ flavor: '{{ cloudscale_test_flavor }}'
+ image: '{{ cloudscale_test_image }}'
+ ssh_keys: '{{ cloudscale_test_ssh_key }}'
+ server_groups: '{{ cloudscale_resource_prefix }}-group-1'
+ zone: '{{ cloudscale_test_zone }}'
+ tags:
+ project: ansible-test
+ stage: production
+ sla: 24-7
+ register: server
+ check_mode: yes
+- name: Verify create a running server in check mode
+ assert:
+ that:
+ - server is changed
+ - server.state == 'absent'
+
+- name: Test create a running server
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test'
+ flavor: '{{ cloudscale_test_flavor }}'
+ image: '{{ cloudscale_test_image }}'
+ ssh_keys: '{{ cloudscale_test_ssh_key }}'
+ server_groups: '{{ cloudscale_resource_prefix }}-group-1'
+ zone: '{{ cloudscale_test_zone }}'
+ tags:
+ project: ansible-test
+ stage: production
+ sla: 24-7
+ register: server
+- name: Verify create a running server
+ assert:
+ that:
+ - server is changed
+ - server.state == 'running'
+ - server.server_groups.0.name == '{{ cloudscale_resource_prefix }}-group-1'
+ - server.zone.slug == '{{ cloudscale_test_zone }}'
+ - server.tags.project == 'ansible-test'
+ - server.tags.stage == 'production'
+ - server.tags.sla == '24-7'
+
+- name: Test create a running server idempotence
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test'
+ flavor: '{{ cloudscale_test_flavor }}'
+ image: '{{ cloudscale_test_image }}'
+ ssh_keys: '{{ cloudscale_test_ssh_key }}'
+ server_groups: '{{ cloudscale_resource_prefix }}-group-1'
+ zone: '{{ cloudscale_test_zone }}'
+ tags:
+ project: ansible-test
+ stage: production
+ sla: 24-7
+ register: server
+- name: Verify create a running server idempotence
+ assert:
+ that:
+ - server is not changed
+ - server.state == 'running'
+ - server.server_groups.0.name == '{{ cloudscale_resource_prefix }}-group-1'
+ - server.zone.slug == '{{ cloudscale_test_zone }}'
+ - server.tags.project == 'ansible-test'
+ - server.tags.stage == 'production'
+ - server.tags.sla == '24-7'
+
+- name: Test update tags in check mode
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test'
+ flavor: '{{ cloudscale_test_flavor }}'
+ image: '{{ cloudscale_test_image }}'
+ ssh_keys: '{{ cloudscale_test_ssh_key }}'
+ server_groups: '{{ cloudscale_resource_prefix }}-group-1'
+ tags:
+ project: ansible-test
+ stage: staging
+ sla: 8-5
+ register: server
+ check_mode: yes
+- name: Verify update tags in check mode
+ assert:
+ that:
+ - server is changed
+ - server.state == 'running'
+ - server.server_groups.0.name == '{{ cloudscale_resource_prefix }}-group-1'
+ - server.tags.project == 'ansible-test'
+ - server.tags.stage == 'production'
+ - server.tags.sla == '24-7'
+
+- name: Test update tags
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test'
+ flavor: '{{ cloudscale_test_flavor }}'
+ image: '{{ cloudscale_test_image }}'
+ ssh_keys: '{{ cloudscale_test_ssh_key }}'
+ server_groups: '{{ cloudscale_resource_prefix }}-group-1'
+ tags:
+ project: ansible-test
+ stage: staging
+ sla: 8-5
+ register: server
+- name: Verify update tags
+ assert:
+ that:
+ - server is changed
+ - server.state == 'running'
+ - server.server_groups.0.name == '{{ cloudscale_resource_prefix }}-group-1'
+ - server.tags.project == 'ansible-test'
+ - server.tags.stage == 'staging'
+ - server.tags.sla == '8-5'
+
+- name: Test update tags idempotence
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test'
+ flavor: '{{ cloudscale_test_flavor }}'
+ image: '{{ cloudscale_test_image }}'
+ ssh_keys: '{{ cloudscale_test_ssh_key }}'
+ server_groups: '{{ cloudscale_resource_prefix }}-group-1'
+ tags:
+ project: ansible-test
+ stage: staging
+ sla: 8-5
+ register: server
+- name: Verify update tags idempotence
+ assert:
+ that:
+ - server is not changed
+ - server.state == 'running'
+ - server.server_groups.0.name == '{{ cloudscale_resource_prefix }}-group-1'
+ - server.tags.project == 'ansible-test'
+ - server.tags.stage == 'staging'
+ - server.tags.sla == '8-5'
+
+- name: Test omit tags idempotence
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test'
+ flavor: '{{ cloudscale_test_flavor }}'
+ image: '{{ cloudscale_test_image }}'
+ ssh_keys: '{{ cloudscale_test_ssh_key }}'
+ server_groups: '{{ cloudscale_resource_prefix }}-group-1'
+ register: server
+- name: Verify update tags idempotence
+ assert:
+ that:
+ - server is not changed
+ - server.state == 'running'
+ - server.server_groups.0.name == '{{ cloudscale_resource_prefix }}-group-1'
+ - server.tags.project == 'ansible-test'
+ - server.tags.stage == 'staging'
+ - server.tags.sla == '8-5'
+
+- name: Test delete tags
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test'
+ flavor: '{{ cloudscale_test_flavor }}'
+ image: '{{ cloudscale_test_image }}'
+ ssh_keys: '{{ cloudscale_test_ssh_key }}'
+ server_groups: '{{ cloudscale_resource_prefix }}-group-1'
+ tags: {}
+ register: server
+- name: Verify delete tags
+ assert:
+ that:
+ - server is changed
+ - server.state == 'running'
+ - server.server_groups.0.name == '{{ cloudscale_resource_prefix }}-group-1'
+ - not server.tags
+
+- name: Test delete tags idempotence
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test'
+ flavor: '{{ cloudscale_test_flavor }}'
+ image: '{{ cloudscale_test_image }}'
+ ssh_keys: '{{ cloudscale_test_ssh_key }}'
+ server_groups: '{{ cloudscale_resource_prefix }}-group-1'
+ tags: {}
+ register: server
+- name: Verify delete tags idempotence
+ assert:
+ that:
+ - server is not changed
+ - server.state == 'running'
+ - server.server_groups.0.name == '{{ cloudscale_resource_prefix }}-group-1'
+ - not server.tags
+
+- name: Test update flavor of a running server without force in check mode
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test'
+ flavor: '{{ cloudscale_test_flavor_2 }}'
+ image: '{{ cloudscale_test_image }}'
+ ssh_keys: '{{ cloudscale_test_ssh_key }}'
+ force: no
+ register: server
+ check_mode: yes
+- name: Verify update flavor of a running server without force in check mode
+ assert:
+ that:
+ - server is not changed
+ - server.state == 'running'
+ - server.flavor.slug == '{{ cloudscale_test_flavor }}'
+ - server.server_groups.0.name == '{{ cloudscale_resource_prefix }}-group-1'
+
+- name: Test update flavor of a running server without force
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test'
+ flavor: '{{ cloudscale_test_flavor_2 }}'
+ image: '{{ cloudscale_test_image }}'
+ ssh_keys: '{{ cloudscale_test_ssh_key }}'
+ force: no
+ register: server
+- name: Verify update flavor of a running server without force
+ assert:
+ that:
+ - server is not changed
+ - server.state == 'running'
+ - server.flavor.slug == '{{ cloudscale_test_flavor }}'
+ - server.server_groups.0.name == '{{ cloudscale_resource_prefix }}-group-1'
+
+- name: Test update flavor of a running server without force idempotence
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test'
+ flavor: '{{ cloudscale_test_flavor_2 }}'
+ image: '{{ cloudscale_test_image }}'
+ ssh_keys: '{{ cloudscale_test_ssh_key }}'
+ force: no
+ register: server
+- name: Verify update flavor of a running server without force idempotence
+ assert:
+ that:
+ - server is not changed
+ - server.state == 'running'
+ - server.flavor.slug == '{{ cloudscale_test_flavor }}'
+ - server.server_groups.0.name == '{{ cloudscale_resource_prefix }}-group-1'
+
+- name: Test update flavor and name of a running server without force in check mode
+ cloudscale_ch.cloud.server:
+ uuid: '{{ server.uuid }}'
+ name: '{{ cloudscale_resource_prefix }}-test-renamed'
+ flavor: '{{ cloudscale_test_flavor_2 }}'
+ image: '{{ cloudscale_test_image }}'
+ ssh_keys: '{{ cloudscale_test_ssh_key }}'
+ force: no
+ register: server
+ check_mode: yes
+- name: Verify update flavor and name of a running server without force in check mode
+ assert:
+ that:
+ - server is changed
+ - server.state == 'running'
+ - server.flavor.slug == '{{ cloudscale_test_flavor }}'
+ - server.name == '{{ cloudscale_resource_prefix }}-test'
+
+- name: Test update flavor and name of a running server without force
+ cloudscale_ch.cloud.server:
+ uuid: '{{ server.uuid }}'
+ name: '{{ cloudscale_resource_prefix }}-test-renamed'
+ flavor: '{{ cloudscale_test_flavor_2 }}'
+ image: '{{ cloudscale_test_image }}'
+ ssh_keys: '{{ cloudscale_test_ssh_key }}'
+ force: no
+ register: server
+- name: Verify update flavor and name of a running server without force
+ assert:
+ that:
+ - server is changed
+ - server.state == 'running'
+ - server.flavor.slug == '{{ cloudscale_test_flavor }}'
+ - server.name == '{{ cloudscale_resource_prefix }}-test-renamed'
+
+- name: Test update flavor and name of a running server without force idempotence
+ cloudscale_ch.cloud.server:
+ uuid: '{{ server.uuid }}'
+ name: '{{ cloudscale_resource_prefix }}-test-renamed'
+ flavor: '{{ cloudscale_test_flavor_2 }}'
+ image: '{{ cloudscale_test_image }}'
+ ssh_keys: '{{ cloudscale_test_ssh_key }}'
+ force: no
+ register: server
+- name: Verify update flavor and name of a running server without force idempotence
+ assert:
+ that:
+ - server is not changed
+ - server.state == 'running'
+ - server.flavor.slug == '{{ cloudscale_test_flavor }}'
+ - server.name == '{{ cloudscale_resource_prefix }}-test-renamed'
+
+- name: Test update flavor of a running server with force in check mode
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test-renamed'
+ flavor: '{{ cloudscale_test_flavor_2 }}'
+ image: '{{ cloudscale_test_image }}'
+ ssh_keys: '{{ cloudscale_test_ssh_key }}'
+ force: yes
+ register: server
+ check_mode: yes
+- name: Verify update flavor of a running server with force in check mode
+ assert:
+ that:
+ - server is changed
+ - server.state == 'running'
+ - server.flavor.slug == '{{ cloudscale_test_flavor }}'
+ - server.name == '{{ cloudscale_resource_prefix }}-test-renamed'
+
+- name: Test update flavor of a running server with force
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test-renamed'
+ flavor: '{{ cloudscale_test_flavor_2 }}'
+ image: '{{ cloudscale_test_image }}'
+ ssh_keys: '{{ cloudscale_test_ssh_key }}'
+ force: yes
+ register: server
+- name: Verify update flavor of a running server with force
+ assert:
+ that:
+ - server is changed
+ - server.state == 'running'
+ - server.flavor.slug == '{{ cloudscale_test_flavor_2 }}'
+ - server.name == '{{ cloudscale_resource_prefix }}-test-renamed'
+
+- name: Test update a running server with force idempotence
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test-renamed'
+ flavor: '{{ cloudscale_test_flavor_2 }}'
+ image: '{{ cloudscale_test_image }}'
+ ssh_keys: '{{ cloudscale_test_ssh_key }}'
+ force: yes
+ register: server
+- name: Verify update flavor of a running server with force idempotence
+ assert:
+ that:
+ - server is not changed
+ - server.state == 'running'
+ - server.flavor.slug == '{{ cloudscale_test_flavor_2 }}'
+ - server.name == '{{ cloudscale_resource_prefix }}-test-renamed'
+
+- name: Remember uuid of running server for anti affinity
+ set_fact:
+ running_server_uuid: '{{ server.uuid }}'
+
+- name: Test create server stopped in anti affinity and private network only in check mode
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test-stopped'
+ flavor: '{{ cloudscale_test_flavor }}'
+ image: '{{ cloudscale_test_image }}'
+ ssh_keys: '{{ cloudscale_test_ssh_key }}'
+ server_groups: '{{ cloudscale_resource_prefix }}-group-1'
+ zone: '{{ cloudscale_test_zone }}'
+ use_public_network: no
+ use_private_network: yes
+ state: stopped
+ check_mode: yes
+ register: server_stopped
+- name: Verify create server stopped in anti affinity and private network only in check mode
+ assert:
+ that:
+ - server_stopped is changed
+ - server_stopped.state == 'absent'
+
+- name: Test create server stopped in anti affinity and private network only
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test-stopped'
+ flavor: '{{ cloudscale_test_flavor }}'
+ image: '{{ cloudscale_test_image }}'
+ ssh_keys: '{{ cloudscale_test_ssh_key }}'
+ server_groups: '{{ cloudscale_resource_prefix }}-group-1'
+ zone: '{{ cloudscale_test_zone }}'
+ use_public_network: no
+ use_private_network: yes
+ state: stopped
+ register: server_stopped
+- name: Verify create server stopped in anti affinity and private network only
+ assert:
+ that:
+ - server_stopped is changed
+ - server_stopped.state == 'stopped'
+ - server_stopped.zone.slug == '{{ cloudscale_test_zone }}'
+ - server_stopped.anti_affinity_with.0.uuid == running_server_uuid
+ - server_stopped.interfaces.0.type == 'private'
+ - server_stopped.server_groups.0.name == '{{ cloudscale_resource_prefix }}-group-1'
+
+- name: Test create server stopped in anti affinity and private network only idempotence
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test-stopped'
+ flavor: '{{ cloudscale_test_flavor }}'
+ image: '{{ cloudscale_test_image }}'
+ ssh_keys: '{{ cloudscale_test_ssh_key }}'
+ server_groups: '{{ cloudscale_resource_prefix }}-group-1'
+ zone: '{{ cloudscale_test_zone }}'
+ use_public_network: no
+ use_private_network: yes
+ state: stopped
+ register: server_stopped
+- name: Verify create server stopped in anti affinity and private network only idempotence
+ assert:
+ that:
+ - server_stopped is not changed
+ - server_stopped.state == 'stopped'
+ - server_stopped.zone.slug == '{{ cloudscale_test_zone }}'
+ - server_stopped.anti_affinity_with.0.uuid == running_server_uuid
+ - server_stopped.interfaces.0.type == 'private'
+ - server_stopped.server_groups.0.name == '{{ cloudscale_resource_prefix }}-group-1'
+
+- name: Test change server group not changed
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test-stopped'
+ flavor: '{{ cloudscale_test_flavor }}'
+ image: '{{ cloudscale_test_image }}'
+ ssh_keys: '{{ cloudscale_test_ssh_key }}'
+ server_groups: '{{ cloudscale_resource_prefix }}-group-2'
+ use_public_network: no
+ use_private_network: yes
+ state: stopped
+ register: server_stopped
+- name: Verify Test update server group not changed
+ assert:
+ that:
+ - server_stopped is not changed
+ - server_stopped.state == 'stopped'
+ - server_stopped.zone.slug == '{{ cloudscale_test_zone }}'
+ - server_stopped.anti_affinity_with.0.uuid == running_server_uuid
+ - server_stopped.interfaces.0.type == 'private'
+ - server_stopped.server_groups.0.name == '{{ cloudscale_resource_prefix }}-group-1'
+
+- name: Test create server with password in check mode
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test-password'
+ flavor: '{{ cloudscale_test_flavor }}'
+ image: '{{ cloudscale_test_image }}'
+ password: '{{ cloudscale_test_password }}'
+ check_mode: yes
+ register: server_password
+- name: Verify create server with password in check mode
+ assert:
+ that:
+ - server_password is changed
+ - server_password.state == 'absent'
+ # Verify password is not logged
+ - server_password.diff.after.password != cloudscale_test_password
+
+- name: Test create server with password
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test-password'
+ flavor: '{{ cloudscale_test_flavor }}'
+ image: '{{ cloudscale_test_image }}'
+ password: '{{ cloudscale_test_password }}'
+ register: server_password
+- name: Verify create server with password
+ assert:
+ that:
+ - server_password is changed
+ - server_password.state == 'running'
+ # Verify password is not logged
+ - server_password.diff.after.password != cloudscale_test_password
+
+- name: Test create server with password idempotence
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test-password'
+ flavor: '{{ cloudscale_test_flavor }}'
+ image: '{{ cloudscale_test_image }}'
+ password: '{{ cloudscale_test_password }}'
+ register: server_password
+- name: Verify create server with password idempotence
+ assert:
+ that:
+ - server_password is not changed
+ - server_password.state == 'running'
+
+- name: Test create server failure without required parameters
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test-failed'
+ register: server_failed
+ ignore_errors: yes
+- name: Verify create server failure without required parameters
+ assert:
+ that:
+ - server_failed is failed
+ - "'Failure while calling the cloudscale.ch API with POST' in server_failed.msg"
+ - "'This field is required.' in server_failed.fetch_url_info.body"
+
+- name: Test stop running server in check mode
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test-renamed'
+ state: stopped
+ check_mode: yes
+ register: server
+- name: Verify stop running server in check mode
+ assert:
+ that:
+ - server is changed
+ - server.state == 'running'
+
+- name: Test stop running server
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test-renamed'
+ state: stopped
+ register: server
+- name: Verify stop running server
+ assert:
+ that:
+ - server is changed
+ - server.state == 'stopped'
+
+- name: Test stop running server idempotence
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test-renamed'
+ state: 'stopped'
+ register: server
+- name: Verify stop running server idempotence
+ assert:
+ that:
+ - server is not changed
+ - server.state == 'stopped'
+
+- name: Test update a stopped server in check mode
+ cloudscale_ch.cloud.server:
+ uuid: '{{ server.uuid }}'
+ name: '{{ cloudscale_resource_prefix }}-test'
+ flavor: '{{ cloudscale_test_flavor }}'
+ image: '{{ cloudscale_test_image }}'
+ ssh_keys: '{{ cloudscale_test_ssh_key }}'
+ state: stopped
+ register: server
+ check_mode: yes
+- name: Verify update a stopped server in check mode
+ assert:
+ that:
+ - server is changed
+ - server.state == 'stopped'
+ - server.flavor.slug == '{{ cloudscale_test_flavor_2 }}'
+ - server.name == '{{ cloudscale_resource_prefix }}-test-renamed'
+
+- name: Test update a stopped server without force
+ cloudscale_ch.cloud.server:
+ uuid: '{{ server.uuid }}'
+ name: '{{ cloudscale_resource_prefix }}-test'
+ flavor: '{{ cloudscale_test_flavor }}'
+ image: '{{ cloudscale_test_image }}'
+ ssh_keys: '{{ cloudscale_test_ssh_key }}'
+ state: stopped
+ register: server
+- name: Verify update a stopped server without force
+ assert:
+ that:
+ - server is changed
+ - server.state == 'stopped'
+ - server.flavor.slug == '{{ cloudscale_test_flavor }}'
+ - server.name == '{{ cloudscale_resource_prefix }}-test'
+
+- name: Test update a stopped server idempotence
+ cloudscale_ch.cloud.server:
+ uuid: '{{ server.uuid }}'
+ name: '{{ cloudscale_resource_prefix }}-test'
+ flavor: '{{ cloudscale_test_flavor }}'
+ image: '{{ cloudscale_test_image }}'
+ ssh_keys: '{{ cloudscale_test_ssh_key }}'
+ state: stopped
+ register: server
+- name: Verify update a stopped server idempotence
+ assert:
+ that:
+ - server is not changed
+ - server.state == 'stopped'
+ - server.flavor.slug == '{{ cloudscale_test_flavor }}'
+ - server.name == '{{ cloudscale_resource_prefix }}-test'
+
+- name: Test server running in check mode
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test'
+ state: running
+ register: server
+ check_mode: yes
+- name: Verify server running in check mode
+ assert:
+ that:
+ - server is changed
+ - server.state == 'stopped'
+
+- name: Test server running
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test'
+ state: running
+ register: server
+- name: Verify server running
+ assert:
+ that:
+ - server is changed
+ - server.state == 'running'
+
+- name: Test server running idempotence
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test'
+ state: running
+ register: server
+- name: Verify server running idempotence
+ assert:
+ that:
+ - server is not changed
+ - server.state == 'running'
+
+- name: Test running server deletion by name in check mode
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test'
+ state: absent
+ register: server
+ check_mode: yes
+- name: Verify running server deletion by name in check mode
+ assert:
+ that:
+ - server is changed
+ - server.state == 'running'
+
+- name: Test running server deletion by name
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test'
+ state: absent
+ register: server
+- name: Verify running server deletion by name
+ assert:
+ that:
+ - server is changed
+ - server.state == 'absent'
+
+- name: Test running server deletion by name idempotence
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-test'
+ state: absent
+ register: server
+- name: Verify running server deletion by name idempotence
+ assert:
+ that:
+ - server is not changed
+ - server.state == 'absent'
+
+- name: Test stopped server deletion by uuid in check mode
+ cloudscale_ch.cloud.server:
+ uuid: '{{ server_stopped.uuid }}'
+ state: absent
+ register: server_stopped
+ check_mode: yes
+- name: Verify stopped server deletion by uuid in check mode
+ assert:
+ that:
+ - server_stopped is changed
+ - server_stopped.state == 'stopped'
+
+- name: Test stopped server deletion by uuid
+ cloudscale_ch.cloud.server:
+ uuid: '{{ server_stopped.uuid }}'
+ state: absent
+ register: server_stopped
+- name: Verify stopped server deletion by uuid
+ assert:
+ that:
+ - server_stopped is changed
+ - server_stopped.state == 'absent'
+
+- name: Test stopped server deletion by uuid idempotence
+ cloudscale_ch.cloud.server:
+ uuid: '{{ server_stopped.uuid }}'
+ state: absent
+ register: server_stopped
+- name: Verify stopped server deletion by uuid idempotence
+ assert:
+ that:
+ - server_stopped is not changed
+ - server_stopped.state == 'absent'
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server_group/aliases b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server_group/aliases
new file mode 100644
index 00000000..c200a3d2
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server_group/aliases
@@ -0,0 +1,2 @@
+cloud/cloudscale
+unsupported
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server_group/meta/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server_group/meta/main.yml
new file mode 100644
index 00000000..2083f0e1
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server_group/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - common
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server_group/tasks/failures.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server_group/tasks/failures.yml
new file mode 100644
index 00000000..b02ee031
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server_group/tasks/failures.yml
@@ -0,0 +1,45 @@
+---
+- name: Fail missing params
+ cloudscale_ch.cloud.server_group:
+ register: grp
+ ignore_errors: True
+- name: 'VERIFY: Fail name and UUID'
+ assert:
+ that:
+ - grp is failed
+
+- name: Create two server groups with the same name
+ uri:
+ url: 'https://api.cloudscale.ch/v1/server-groups'
+ method: POST
+ headers:
+ Authorization: 'Bearer {{ cloudscale_api_token }}'
+ body:
+ name: '{{ cloudscale_resource_prefix }}-duplicate'
+ type: 'anti-affinity'
+ body_format: json
+ status_code: 201
+ register: duplicate
+ with_sequence: count=2
+
+- name: Try access to duplicate name
+ cloudscale_ch.cloud.server_group:
+ name: '{{ cloudscale_resource_prefix }}-duplicate'
+ register: grp
+ ignore_errors: True
+- name: 'VERIFY: Try access to duplicate name'
+ assert:
+ that:
+ - grp is failed
+ - grp.msg.startswith("More than one server-groups resource with 'name' exists")
+
+- name: Fail server group creation with UUID
+ cloudscale_ch.cloud.server_group:
+ uuid: ea3b39a3-77a8-4d0b-881d-0bb00a1e7f48
+ register: grp
+ ignore_errors: True
+- name: 'VERIFY: Fail server group creation with UUID'
+ assert:
+ that:
+ - grp is failed
+ - grp.msg.startswith("state is present but all of the following are missing")
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server_group/tasks/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server_group/tasks/main.yml
new file mode 100644
index 00000000..44fe7303
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server_group/tasks/main.yml
@@ -0,0 +1,8 @@
+---
+- block:
+ - import_tasks: failures.yml
+ - import_tasks: tests.yml
+ always:
+ - import_role:
+ name: common
+ tasks_from: cleanup_server_groups
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server_group/tasks/tests.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server_group/tasks/tests.yml
new file mode 100644
index 00000000..018b85a5
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/server_group/tasks/tests.yml
@@ -0,0 +1,180 @@
+---
+- name: Create server group in check mode
+ cloudscale_ch.cloud.server_group:
+ name: '{{ cloudscale_resource_prefix }}-grp'
+ zone: '{{ cloudscale_test_zone }}'
+ tags:
+ project: ansible-test
+ stage: production
+ sla: 24-7
+ register: grp
+ check_mode: yes
+- name: 'VERIFY: Create server group in check mode'
+ assert:
+ that:
+ - grp is changed
+ - grp.name == '{{ cloudscale_resource_prefix }}-grp'
+ - not grp.uuid
+
+- name: Create server group
+ cloudscale_ch.cloud.server_group:
+ name: '{{ cloudscale_resource_prefix }}-grp'
+ zone: '{{ cloudscale_test_zone }}'
+ tags:
+ project: ansible-test
+ stage: production
+ sla: 24-7
+ register: grp
+- name: 'VERIFY: Create server group'
+ assert:
+ that:
+ - grp is changed
+ - grp.type == 'anti-affinity'
+ - grp.name == '{{ cloudscale_resource_prefix }}-grp'
+ - grp.zone.slug == '{{ cloudscale_test_zone }}'
+ - grp.uuid
+ - grp.tags.project == 'ansible-test'
+ - grp.tags.stage == 'production'
+ - grp.tags.sla == '24-7'
+
+- name: Remember uuid
+ set_fact:
+ server_group_uuid: '{{ grp.uuid }}'
+
+- name: Create server group idempotence
+ cloudscale_ch.cloud.server_group:
+ name: '{{ cloudscale_resource_prefix }}-grp'
+ zone: '{{ cloudscale_test_zone }}'
+ tags:
+ project: ansible-test
+ stage: production
+ sla: 24-7
+ register: grp
+- name: 'VERIFY: Create server group idempotence'
+ assert:
+ that:
+ - grp is not changed
+ - grp.name == '{{ cloudscale_resource_prefix }}-grp'
+ - grp.zone.slug == '{{ cloudscale_test_zone }}'
+ - grp.uuid == server_group_uuid
+ - grp.tags.project == 'ansible-test'
+ - grp.tags.stage == 'production'
+ - grp.tags.sla == '24-7'
+
+- name: Create server group with same name in alt zone
+ cloudscale_ch.cloud.server_group:
+ name: '{{ cloudscale_resource_prefix }}-grp'
+ zone: '{{ cloudscale_test_alt_zone }}'
+ tags:
+ project: ansible-test
+ stage: production
+ sla: 24-7
+ register: grp
+- name: 'VERIFY:Create server group with same name in alt zone'
+ assert:
+ that:
+ - grp is changed
+ - grp.name == '{{ cloudscale_resource_prefix }}-grp'
+ - grp.zone.slug == '{{ cloudscale_test_alt_zone }}'
+ - grp.uuid != server_group_uuid
+ - grp.tags.project == 'ansible-test'
+ - grp.tags.stage == 'production'
+ - grp.tags.sla == '24-7'
+
+- name: Update server group in check mode
+ cloudscale_ch.cloud.server_group:
+ uuid: '{{ server_group_uuid }}'
+ name: '{{ cloudscale_resource_prefix }}-grp2'
+ tags:
+ project: ansible-test
+ stage: staging
+ sla: 8-5
+ register: grp
+ check_mode: yes
+- name: 'VERIFY: Update server group in check mode'
+ assert:
+ that:
+ - grp is changed
+ - grp.name == '{{ cloudscale_resource_prefix }}-grp'
+ - grp.uuid == server_group_uuid
+ - grp.zone.slug == '{{ cloudscale_test_zone }}'
+ - grp.tags.project == 'ansible-test'
+ - grp.tags.stage == 'production'
+ - grp.tags.sla == '24-7'
+
+- name: Update server group
+ cloudscale_ch.cloud.server_group:
+ uuid: '{{ server_group_uuid }}'
+ name: '{{ cloudscale_resource_prefix }}-grp2'
+ tags:
+ project: ansible-test
+ stage: staging
+ sla: 8-5
+ register: grp
+- name: 'VERIFY: Update server group'
+ assert:
+ that:
+ - grp is changed
+ - grp.name == '{{ cloudscale_resource_prefix }}-grp2'
+ - grp.uuid == server_group_uuid
+ - grp.zone.slug == '{{ cloudscale_test_zone }}'
+ - grp.tags.project == 'ansible-test'
+ - grp.tags.stage == 'staging'
+ - grp.tags.sla == '8-5'
+
+- name: Update server group idempotence
+ cloudscale_ch.cloud.server_group:
+ uuid: '{{ server_group_uuid }}'
+ name: '{{ cloudscale_resource_prefix }}-grp2'
+ tags:
+ project: ansible-test
+ stage: staging
+ sla: 8-5
+ register: grp
+- name: 'VERIFY: Update server group idempotence'
+ assert:
+ that:
+ - grp is not changed
+ - grp.name == '{{ cloudscale_resource_prefix }}-grp2'
+ - grp.uuid == server_group_uuid
+ - grp.zone.slug == '{{ cloudscale_test_zone }}'
+ - grp.tags.project == 'ansible-test'
+ - grp.tags.stage == 'staging'
+ - grp.tags.sla == '8-5'
+
+- name: Delete server group in check mode
+ cloudscale_ch.cloud.server_group:
+ name: '{{ cloudscale_resource_prefix }}-grp2'
+ state: absent
+ register: grp
+ check_mode: yes
+- name: 'VERIFY: Delete server group in check mode'
+ assert:
+ that:
+ - grp is changed
+ - grp.name == '{{ cloudscale_resource_prefix }}-grp2'
+ - grp.uuid == server_group_uuid
+
+- name: Delete server group
+ cloudscale_ch.cloud.server_group:
+ name: '{{ cloudscale_resource_prefix }}-grp2'
+ state: absent
+ register: grp
+- name: 'VERIFY: Delete server group'
+ assert:
+ that:
+ - grp is changed
+ - grp.name == '{{ cloudscale_resource_prefix }}-grp2'
+ - grp.uuid == server_group_uuid
+
+- name: Delete server group idempotence
+ cloudscale_ch.cloud.server_group:
+ name: '{{ cloudscale_resource_prefix }}-grp2'
+ state: absent
+ register: grp
+- name: 'VERIFY: Delete server group idempotence'
+ assert:
+ that:
+ - grp is not changed
+ - grp.name == '{{ cloudscale_resource_prefix }}-grp2'
+ - not grp.uuid
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/aliases b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/aliases
new file mode 100644
index 00000000..c200a3d2
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/aliases
@@ -0,0 +1,2 @@
+cloud/cloudscale
+unsupported
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/defaults/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/defaults/main.yml
new file mode 100644
index 00000000..67d807cd
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/defaults/main.yml
@@ -0,0 +1,2 @@
+---
+cloudscale_subnet_cidr: 192.168.23.0/24
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/meta/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/meta/main.yml
new file mode 100644
index 00000000..2083f0e1
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - common
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/tasks/failures.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/tasks/failures.yml
new file mode 100644
index 00000000..c28f5ab0
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/tasks/failures.yml
@@ -0,0 +1,82 @@
+---
+- name: Fail missing params
+ cloudscale_ch.cloud.subnet:
+ register: snet
+ ignore_errors: True
+- name: 'VERIFY: Fail missing params'
+ assert:
+ that:
+ - snet is failed
+ - snet.msg.startswith("one of the following is required")
+
+- name: Fail creation with UUID
+ cloudscale_ch.cloud.subnet:
+ uuid: ea3b39a3-77a8-4d0b-881d-0bb00a1e7f48
+ register: snet
+ ignore_errors: True
+- name: 'VERIFY: Fail creation with UUID'
+ assert:
+ that:
+ - snet is failed
+ - snet.msg.startswith("state is present but all of the following are missing")
+
+- name: Fail creation unknown network name
+ cloudscale_ch.cloud.subnet:
+ cidr: '{{ cloudscale_subnet_cidr }}'
+ network:
+ name: '{{ cloudscale_resource_prefix }}-does-not-exist'
+ tags:
+ project: ansible-test
+ stage: production
+ sla: 24-7
+ register: snet
+ ignore_errors: True
+- name: 'VERIFY: Fail creation unknown network name'
+ assert:
+ that:
+ - snet is failed
+ - snet.msg.startswith("Network with 'name' not found")
+
+- name: Fail creation unknown network uuid
+ cloudscale_ch.cloud.subnet:
+ cidr: '{{ cloudscale_subnet_cidr }}'
+ network:
+ uuid: 'f0bb5270-f66c-41d6-ac3b-a223cd280ced'
+ tags:
+ project: ansible-test
+ stage: production
+ sla: 24-7
+ register: snet
+ ignore_errors: True
+- name: 'VERIFY: Fail creation unknown network uuid'
+ assert:
+ that:
+ - snet is failed
+ - snet.msg.startswith("Network with 'uuid' not found")
+
+- name: Create two networks with the same name
+ uri:
+ url: 'https://api.cloudscale.ch/v1/networks'
+ method: POST
+ headers:
+ Authorization: 'Bearer {{ cloudscale_api_token }}'
+ body:
+ name: '{{ cloudscale_resource_prefix }}-duplicate'
+ auto_create_ipv4_subnet: False
+ body_format: json
+ status_code: 201
+ register: duplicate
+ with_sequence: count=2
+
+- name: Try access to duplicate network name
+ cloudscale_ch.cloud.subnet:
+ cidr: '{{ cloudscale_subnet_cidr }}'
+ network:
+ name: '{{ cloudscale_resource_prefix }}-duplicate'
+ register: snet
+ ignore_errors: True
+- name: 'VERIFY: Try access to duplicate network name'
+ assert:
+ that:
+ - snet is failed
+ - snet.msg.startswith("Multiple networks with 'name' not found")
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/tasks/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/tasks/main.yml
new file mode 100644
index 00000000..54078ffa
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/tasks/main.yml
@@ -0,0 +1,10 @@
+---
+- name: Subnet test run
+ block:
+ - import_tasks: failures.yml
+ - import_tasks: setup.yml
+ - import_tasks: tests.yml
+ always:
+ - import_role:
+ name: common
+ tasks_from: cleanup_networks
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/tasks/setup.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/tasks/setup.yml
new file mode 100644
index 00000000..4662f9e7
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/tasks/setup.yml
@@ -0,0 +1,13 @@
+---
+- name: Setup network in alt zone
+ cloudscale_ch.cloud.network:
+ name: '{{ cloudscale_resource_prefix }}-net'
+ auto_create_ipv4_subnet: false
+ zone: '{{ cloudscale_test_alt_zone }}'
+
+- name: Setup network in test zone
+ cloudscale_ch.cloud.network:
+ name: '{{ cloudscale_resource_prefix }}-net'
+ auto_create_ipv4_subnet: false
+ zone: '{{ cloudscale_test_zone }}'
+ register: net
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/tasks/tests.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/tasks/tests.yml
new file mode 100644
index 00000000..5e0ff6b1
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/subnet/tasks/tests.yml
@@ -0,0 +1,243 @@
+---
+- name: Create subnet in check mode
+ cloudscale_ch.cloud.subnet:
+ cidr: '{{ cloudscale_subnet_cidr }}'
+ network:
+ name: '{{ cloudscale_resource_prefix }}-net'
+ zone: '{{ cloudscale_test_zone }}'
+ tags:
+ project: ansible-test
+ stage: production
+ sla: 24-7
+ register: snet
+ check_mode: yes
+- name: 'VERIFY: Create subnet in check mode'
+ assert:
+ that:
+ - snet is changed
+ - snet.cidr == cloudscale_subnet_cidr
+ - not snet.uuid
+
+- name: Create subnet
+ cloudscale_ch.cloud.subnet:
+ cidr: '{{ cloudscale_subnet_cidr }}'
+ network:
+ name: '{{ cloudscale_resource_prefix }}-net'
+ zone: '{{ cloudscale_test_zone }}'
+ tags:
+ project: ansible-test
+ stage: production
+ sla: 24-7
+ register: snet
+- name: 'VERIFY: Create subnet'
+ assert:
+ that:
+ - snet is changed
+ - snet.cidr == cloudscale_subnet_cidr
+ - snet.uuid
+ - snet.tags.project == 'ansible-test'
+ - snet.tags.stage == 'production'
+ - snet.tags.sla == '24-7'
+ - snet.network.zone.slug == cloudscale_test_zone
+
+- name: Remember subnet uuid
+ set_fact:
+ subnet_uuid: '{{ snet.uuid }}'
+
+- name: Create subnet idempotence
+ cloudscale_ch.cloud.subnet:
+ cidr: '{{ cloudscale_subnet_cidr }}'
+ network:
+ name: '{{ cloudscale_resource_prefix }}-net'
+ zone: '{{ cloudscale_test_zone }}'
+ tags:
+ project: ansible-test
+ stage: production
+ sla: 24-7
+ register: snet
+- name: 'VERIFY: Create subnet idempotence'
+ assert:
+ that:
+ - snet is not changed
+ - snet.cidr == cloudscale_subnet_cidr
+ - snet.uuid == subnet_uuid
+ - snet.tags.project == 'ansible-test'
+ - snet.tags.stage == 'production'
+ - snet.tags.sla == '24-7'
+ - snet.network.zone.slug == cloudscale_test_zone
+
+- name: Update subnet in check mode
+ cloudscale_ch.cloud.subnet:
+ cidr: '{{ cloudscale_subnet_cidr }}'
+ network:
+ name: '{{ cloudscale_resource_prefix }}-net'
+ zone: '{{ cloudscale_test_zone }}'
+ tags:
+ project: ansible-test
+ stage: staging
+ sla: 8-5
+ register: snet
+ check_mode: yes
+- name: 'VERIFY: Update subnet in check mode'
+ assert:
+ that:
+ - snet is changed
+ - snet.cidr == cloudscale_subnet_cidr
+ - snet.uuid == subnet_uuid
+ - snet.tags.project == 'ansible-test'
+ - snet.tags.stage == 'production'
+ - snet.tags.sla == '24-7'
+ - snet.network.zone.slug == cloudscale_test_zone
+
+- name: Update subnet
+ cloudscale_ch.cloud.subnet:
+ cidr: '{{ cloudscale_subnet_cidr }}'
+ network:
+ name: '{{ cloudscale_resource_prefix }}-net'
+ zone: '{{ cloudscale_test_zone }}'
+ tags:
+ project: ansible-test
+ stage: staging
+ sla: 8-5
+ register: snet
+- name: 'VERIFY: Update subnet'
+ assert:
+ that:
+ - snet is changed
+ - snet.cidr == cloudscale_subnet_cidr
+ - snet.uuid == subnet_uuid
+ - snet.tags.project == 'ansible-test'
+ - snet.tags.stage == 'staging'
+ - snet.tags.sla == '8-5'
+ - snet.network.zone.slug == cloudscale_test_zone
+
+- name: Update subnet idempotence
+ cloudscale_ch.cloud.subnet:
+ uuid: '{{ subnet_uuid }}'
+ cidr: '{{ cloudscale_subnet_cidr }}'
+ network:
+ name: '{{ cloudscale_resource_prefix }}-net'
+ zone: '{{ cloudscale_test_zone }}'
+ tags:
+ project: ansible-test
+ stage: staging
+ sla: 8-5
+ register: snet
+- name: 'VERIFY: Update subnet idempotence'
+ assert:
+ that:
+ - snet is not changed
+ - snet.cidr == cloudscale_subnet_cidr
+ - snet.uuid == subnet_uuid
+ - snet.tags.project == 'ansible-test'
+ - snet.tags.stage == 'staging'
+ - snet.tags.sla == '8-5'
+ - snet.network.zone.slug == cloudscale_test_zone
+
+- name: Update subnet by Network UUID
+ cloudscale_ch.cloud.subnet:
+ cidr: '{{ cloudscale_subnet_cidr }}'
+ network:
+ uuid: '{{ net.uuid }}'
+ dns_servers:
+ - 9.9.9.9
+ - 8.8.8.8
+ gateway_address: 192.168.23.1
+ register: snet
+- name: 'VERIFY: Update subnet'
+ assert:
+ that:
+ - snet is changed
+ - snet.cidr == cloudscale_subnet_cidr
+ - snet.uuid == subnet_uuid
+ - snet.dns_servers == ['9.9.9.9', '8.8.8.8']
+ - snet.gateway_address == '192.168.23.1'
+ - snet.tags.project == 'ansible-test'
+ - snet.tags.stage == 'staging'
+ - snet.tags.sla == '8-5'
+ - snet.network.zone.slug == cloudscale_test_zone
+
+- name: Update subnet by Network UUID idempotence
+ cloudscale_ch.cloud.subnet:
+ cidr: '{{ cloudscale_subnet_cidr }}'
+ network:
+ uuid: '{{ net.uuid }}'
+ dns_servers:
+ - 9.9.9.9
+ - 8.8.8.8
+ gateway_address: 192.168.23.1
+ register: snet
+- name: 'VERIFY: Update subnet'
+ assert:
+ that:
+ - snet is not changed
+ - snet.cidr == cloudscale_subnet_cidr
+ - snet.uuid == subnet_uuid
+ - snet.dns_servers == ['9.9.9.9', '8.8.8.8']
+ - snet.gateway_address == '192.168.23.1'
+ - snet.tags.project == 'ansible-test'
+ - snet.tags.stage == 'staging'
+ - snet.tags.sla == '8-5'
+ - snet.network.zone.slug == cloudscale_test_zone
+
+- name: Reset DNS servers in subnet
+ cloudscale_ch.cloud.subnet:
+ cidr: '{{ cloudscale_subnet_cidr }}'
+ network:
+ uuid: '{{ net.uuid }}'
+ gateway_address: 192.168.23.1
+ reset: true
+ register: snet
+- name: 'VERIFY: Update subnet'
+ assert:
+ that:
+ - snet is changed
+ - snet.cidr == cloudscale_subnet_cidr
+ - snet.uuid == subnet_uuid
+ - snet.dns_servers != ['9.9.9.9', '8.8.8.8']
+ - snet.gateway_address == '192.168.23.1'
+ - snet.tags.project == 'ansible-test'
+ - snet.tags.stage == 'staging'
+ - snet.tags.sla == '8-5'
+ - snet.network.zone.slug == cloudscale_test_zone
+
+- name: Delete subnet in check mode
+ cloudscale_ch.cloud.subnet:
+ uuid: "{{ snet.uuid }}"
+ state: absent
+ register: snet
+ check_mode: yes
+- name: 'VERIFY: Delete subnet in check mode'
+ assert:
+ that:
+ - snet is changed
+ - snet.cidr == cloudscale_subnet_cidr
+ - snet.uuid == subnet_uuid
+ - snet.state == "present"
+ - snet.network.zone.slug == cloudscale_test_zone
+
+- name: Delete subnet
+ cloudscale_ch.cloud.subnet:
+ uuid: "{{ snet.uuid }}"
+ state: absent
+ register: snet
+- name: 'VERIFY: Delete subnet'
+ assert:
+ that:
+ - snet is changed
+ - snet.cidr == cloudscale_subnet_cidr
+ - snet.uuid == subnet_uuid
+ - snet.state == "absent"
+ - snet.network.zone.slug == cloudscale_test_zone
+
+- name: Delete subnet idempotence
+ cloudscale_ch.cloud.subnet:
+ uuid: "{{ snet.uuid }}"
+ state: absent
+ register: snet
+- name: 'VERIFY: Delete subnet idempotence'
+ assert:
+ that:
+ - snet is not changed
+ - snet.uuid == subnet_uuid
+ - snet.state == "absent"
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/aliases b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/aliases
new file mode 100644
index 00000000..c200a3d2
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/aliases
@@ -0,0 +1,2 @@
+cloud/cloudscale
+unsupported
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/meta/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/meta/main.yml
new file mode 100644
index 00000000..2083f0e1
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - common
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/cleanup.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/cleanup.yml
new file mode 100644
index 00000000..e7abce57
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/cleanup.yml
@@ -0,0 +1,5 @@
+---
+- name: Remove test server
+ cloudscale_ch.cloud.server:
+ uuid: '{{ server.uuid }}'
+ state: 'absent'
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/failures.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/failures.yml
new file mode 100644
index 00000000..4962a7a7
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/failures.yml
@@ -0,0 +1,38 @@
+---
+- name: Create two volumes with the same name
+ uri:
+ url: 'https://api.cloudscale.ch/v1/volumes'
+ method: POST
+ headers:
+ Authorization: 'Bearer {{ cloudscale_api_token }}'
+ body:
+ name: '{{ cloudscale_resource_prefix }}-duplicate'
+ size_gb: 50
+ body_format: json
+ status_code: 201
+ register: duplicate
+ with_sequence: count=2
+
+- name: Try access to duplicate name
+ cloudscale_ch.cloud.volume:
+ name: '{{ cloudscale_resource_prefix }}-duplicate'
+ size_gb: 10
+ register: vol
+ ignore_errors: True
+- name: 'VERIFY: Try access to duplicate name'
+ assert:
+ that:
+ - vol is failed
+
+- name: Fail volume creation with UUID
+ cloudscale_ch.cloud.volume:
+ uuid: ea3b39a3-77a8-4d0b-881d-0bb00a1e7f48
+ name: '{{ cloudscale_resource_prefix }}-inexistent'
+ size_gb: 10
+ register: vol
+ ignore_errors: True
+- name: 'VERIFY: Fail volume creation with UUID'
+ assert:
+ that:
+ - vol is failed
+ - vol.msg.startswith("The resource with UUID 'ea3b39a3-77a8-4d0b-881d-0bb00a1e7f48' was not found")
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/main.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/main.yml
new file mode 100644
index 00000000..653f5446
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/main.yml
@@ -0,0 +1,12 @@
+---
+- block:
+ - import_tasks: setup.yml
+ - import_tasks: failures.yml
+ - import_tasks: tests.yml
+ always:
+ - import_role:
+ name: common
+ tasks_from: cleanup_servers
+ - import_role:
+ name: common
+ tasks_from: cleanup_volumes
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/setup.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/setup.yml
new file mode 100644
index 00000000..c256766d
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/setup.yml
@@ -0,0 +1,9 @@
+---
+- name: Create test instance
+ cloudscale_ch.cloud.server:
+ name: '{{ cloudscale_resource_prefix }}-server'
+ flavor: '{{ cloudscale_test_flavor }}'
+ zone: '{{ cloudscale_test_zone }}'
+ image: '{{ cloudscale_test_image }}'
+ ssh_keys: '{{ cloudscale_test_ssh_key }}'
+ register: server
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/tests.yml b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/tests.yml
new file mode 100644
index 00000000..9aa9d04e
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/tests.yml
@@ -0,0 +1,260 @@
+---
+- name: Create volume in check mode
+ cloudscale_ch.cloud.volume:
+ name: '{{ cloudscale_resource_prefix }}-vol'
+ zone: '{{ cloudscale_test_zone }}'
+ size_gb: 50
+ tags:
+ project: ansible-test
+ stage: production
+ sla: 24-7
+ check_mode: yes
+ register: vol
+- name: 'VERIFY: Create volume in check mode'
+ assert:
+ that:
+ - vol is successful
+ - vol is changed
+ - vol.state == 'absent'
+
+- name: Create volume
+ cloudscale_ch.cloud.volume:
+ name: '{{ cloudscale_resource_prefix }}-vol'
+ zone: '{{ cloudscale_test_zone }}'
+ size_gb: 50
+ tags:
+ project: ansible-test
+ stage: production
+ sla: 24-7
+ register: vol
+- name: 'VERIFY: Create volume'
+ assert:
+ that:
+ - vol is successful
+ - vol is changed
+ - vol.size_gb == 50
+ - vol.name == '{{ cloudscale_resource_prefix }}-vol'
+ - vol.zone.slug == '{{ cloudscale_test_zone }}'
+ - vol.tags.project == 'ansible-test'
+ - vol.tags.stage == 'production'
+ - vol.tags.sla == '24-7'
+
+- name: Create volume idempotence
+ cloudscale_ch.cloud.volume:
+ name: '{{ cloudscale_resource_prefix }}-vol'
+ zone: '{{ cloudscale_test_zone }}'
+ size_gb: 50
+ tags:
+ project: ansible-test
+ stage: production
+ sla: 24-7
+ register: vol
+- name: 'VERIFY: Create volume idempotence'
+ assert:
+ that:
+ - vol is successful
+ - vol is not changed
+ - vol.size_gb == 50
+ - vol.name == '{{ cloudscale_resource_prefix }}-vol'
+ - vol.zone.slug == '{{ cloudscale_test_zone }}'
+ - vol.tags.project == 'ansible-test'
+ - vol.tags.stage == 'production'
+ - vol.tags.sla == '24-7'
+
+- name: Attach existing volume by name to server in check mode
+ cloudscale_ch.cloud.volume:
+ name: '{{ cloudscale_resource_prefix }}-vol'
+ server_uuids:
+ - '{{ server.uuid }}'
+ check_mode: yes
+ register: vol
+- name: 'VERIFY: Attach existing volume by name to server in check mode'
+ assert:
+ that:
+ - vol is successful
+ - vol is changed
+ - server.uuid not in vol.server_uuids
+
+- name: Attach existing volume by name to server
+ cloudscale_ch.cloud.volume:
+ name: '{{ cloudscale_resource_prefix }}-vol'
+ server_uuids:
+ - '{{ server.uuid }}'
+ register: vol
+- name: 'VERIFY: Attach existing volume by name to server'
+ assert:
+ that:
+ - vol is successful
+ - vol is changed
+ - server.uuid in vol.server_uuids
+
+- name: Attach existing volume by name to server idempotence
+ cloudscale_ch.cloud.volume:
+ name: '{{ cloudscale_resource_prefix }}-vol'
+ server_uuids:
+ - '{{ server.uuid }}'
+ register: vol
+- name: 'VERIFY: Attach existing volume by name to server idempotence'
+ assert:
+ that:
+ - vol is successful
+ - vol is not changed
+ - server.uuid in vol.server_uuids
+
+- name: Resize attached volume by UUID in check mode
+ cloudscale_ch.cloud.volume:
+ uuid: '{{ vol.uuid }}'
+ size_gb: 100
+ check_mode: yes
+ register: vol
+- name: 'VERIFY: Resize attached volume by UUID in check mode'
+ assert:
+ that:
+ - vol is successful
+ - vol is changed
+ - vol.size_gb == 50
+
+- name: Resize attached volume by UUID
+ cloudscale_ch.cloud.volume:
+ uuid: '{{ vol.uuid }}'
+ size_gb: 100
+ register: vol
+- name: 'VERIFY: Resize attached volume by UUID'
+ assert:
+ that:
+ - vol is successful
+ - vol is changed
+ - vol.size_gb == 100
+
+- name: Resize attached volume by UUID idempotence
+ cloudscale_ch.cloud.volume:
+ uuid: '{{ vol.uuid }}'
+ size_gb: 100
+ register: vol
+- name: 'VERIFY: Resize attached volume by UUID idempotence'
+ assert:
+ that:
+ - vol is successful
+ - vol is not changed
+ - vol.size_gb == 100
+
+- name: Delete attached volume by UUID in check mode
+ cloudscale_ch.cloud.volume:
+ uuid: '{{ vol.uuid }}'
+ state: 'absent'
+ check_mode: yes
+ register: deleted
+- name: 'VERIFY: Delete attached volume by UUID in check mode'
+ assert:
+ that:
+ - deleted is successful
+ - deleted is changed
+ - deleted.state == 'present'
+ - deleted.uuid == vol.uuid
+ - deleted.name == '{{ cloudscale_resource_prefix }}-vol'
+
+- name: Delete attached volume by UUID
+ cloudscale_ch.cloud.volume:
+ uuid: '{{ vol.uuid }}'
+ state: 'absent'
+ register: deleted
+- name: 'VERIFY: Delete attached volume by UUID'
+ assert:
+ that:
+ - deleted is successful
+ - deleted is changed
+ - deleted.state == 'absent'
+ - deleted.uuid == vol.uuid
+ - deleted.name == '{{ cloudscale_resource_prefix }}-vol'
+
+- name: Delete attached volume by UUID idempotence
+ cloudscale_ch.cloud.volume:
+ uuid: '{{ vol.uuid }}'
+ state: 'absent'
+ register: deleted
+- name: 'VERIFY: Delete attached volume by UUID idempotence'
+ assert:
+ that:
+ - deleted is successful
+ - deleted is not changed
+ - deleted.state == 'absent'
+ - deleted.uuid == vol.uuid
+ - not deleted.name
+
+- name: Create bulk volume and attach
+ cloudscale_ch.cloud.volume:
+ name: '{{ cloudscale_resource_prefix }}-bulk'
+ type: bulk
+ zone: '{{ cloudscale_test_zone }}'
+ size_gb: 100
+ server_uuids:
+ - '{{ server.uuid }}'
+ register: bulk
+- name: 'VERIFY: Create bulk volume and attach'
+ assert:
+ that:
+ - bulk is successful
+ - bulk is changed
+ - bulk.size_gb == 100
+ - server.uuid in bulk.server_uuids
+
+- name: Detach volume by UUID
+ cloudscale_ch.cloud.volume:
+ uuid: '{{ bulk.uuid }}'
+ server_uuids: []
+ register: bulk
+- name: 'VERIFY: Detach volume by UUID'
+ assert:
+ that:
+ - bulk is successful
+ - bulk is changed
+ - bulk.server_uuids == []
+
+- name: Resize detached volume by name
+ cloudscale_ch.cloud.volume:
+ name: '{{ bulk.name }}'
+ size_gb: 200
+ register: bulk
+- name: 'VERIFY: Resize detached volume by name'
+ assert:
+ that:
+ - bulk is successful
+ - bulk is changed
+ - bulk.size_gb == 200
+
+- name: Delete volume by name in check mode
+ cloudscale_ch.cloud.volume:
+ name: '{{ bulk.name }}'
+ state: 'absent'
+ check_mode: yes
+ register: bulk
+- name: 'VERIFY: Delete volume by name'
+ assert:
+ that:
+ - bulk is successful
+ - bulk is changed
+ - bulk.state == 'present'
+
+- name: Delete volume by name
+ cloudscale_ch.cloud.volume:
+ name: '{{ bulk.name }}'
+ state: 'absent'
+ register: bulk
+- name: 'VERIFY: Delete volume by name'
+ assert:
+ that:
+ - bulk is successful
+ - bulk is changed
+ - bulk.state == 'absent'
+
+- name: Delete volume by name idempotence
+ cloudscale_ch.cloud.volume:
+ name: '{{ bulk.name }}'
+ state: 'absent'
+ register: bulk
+- name: 'VERIFY: Delete volume by name idempotence'
+ assert:
+ that:
+ - bulk is successful
+ - bulk is not changed
+ - bulk.state == 'absent'
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/requirements.txt b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/requirements.txt
new file mode 100644
index 00000000..4f6a277e
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/requirements.txt
@@ -0,0 +1 @@
+netaddr
diff --git a/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/sanity/ignore-2.10.txt b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/sanity/ignore-2.10.txt
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/cloudscale_ch/cloud/tests/sanity/ignore-2.10.txt