Initial commit

This commit is contained in:
Ansible Core Team
2020-03-09 09:11:07 +00:00
commit aebc1b03fd
4861 changed files with 812621 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
---
- name: Remove test server
cloudscale_server:
uuid: '{{ server.uuid }}'
state: 'absent'

View File

@@ -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_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_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 volume with UUID \'ea3b39a3-77a8-4d0b-881d-0bb00a1e7f48\' was not found')

View File

@@ -0,0 +1,11 @@
---
- block:
- import_tasks: setup.yml
- import_tasks: tests.yml
always:
- import_role:
name: cloudscale_common
tasks_from: cleanup_servers
- import_role:
name: cloudscale_common
tasks_from: cleanup_volumes

View File

@@ -0,0 +1,9 @@
---
- name: Create test instance
cloudscale_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

View File

@@ -0,0 +1,262 @@
---
- name: Create volume in check mode
cloudscale_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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'
- import_tasks: failures.yml