2019-03-12 17:53:49 +01:00
|
|
|
---
|
2019-08-29 16:08:54 +02:00
|
|
|
- name: Create volume in check mode
|
|
|
|
cloudscale_volume:
|
|
|
|
name: '{{ cloudscale_resource_prefix }}-vol'
|
2020-02-12 14:06:41 +01:00
|
|
|
zone: '{{ cloudscale_test_zone }}'
|
2019-08-29 16:08:54 +02:00
|
|
|
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'
|
|
|
|
|
2019-03-12 17:53:49 +01:00
|
|
|
- name: Create volume
|
|
|
|
cloudscale_volume:
|
|
|
|
name: '{{ cloudscale_resource_prefix }}-vol'
|
2020-02-12 14:06:41 +01:00
|
|
|
zone: '{{ cloudscale_test_zone }}'
|
2019-03-12 17:53:49 +01:00
|
|
|
size_gb: 50
|
2019-08-29 16:08:54 +02:00
|
|
|
tags:
|
|
|
|
project: ansible-test
|
|
|
|
stage: production
|
|
|
|
sla: 24-7
|
2019-03-12 17:53:49 +01:00
|
|
|
register: vol
|
|
|
|
- name: 'VERIFY: Create volume'
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- vol is successful
|
|
|
|
- vol is changed
|
|
|
|
- vol.size_gb == 50
|
|
|
|
- vol.name == '{{ cloudscale_resource_prefix }}-vol'
|
2020-02-12 14:06:41 +01:00
|
|
|
- vol.zone.slug == '{{ cloudscale_test_zone }}'
|
2019-08-29 16:08:54 +02:00
|
|
|
- vol.tags.project == 'ansible-test'
|
|
|
|
- vol.tags.stage == 'production'
|
|
|
|
- vol.tags.sla == '24-7'
|
2019-03-12 17:53:49 +01:00
|
|
|
|
2020-02-12 14:06:41 +01:00
|
|
|
- name: Create volume idempotence
|
2019-03-12 17:53:49 +01:00
|
|
|
cloudscale_volume:
|
|
|
|
name: '{{ cloudscale_resource_prefix }}-vol'
|
2020-02-12 14:06:41 +01:00
|
|
|
zone: '{{ cloudscale_test_zone }}'
|
2019-03-12 17:53:49 +01:00
|
|
|
size_gb: 50
|
2019-08-29 16:08:54 +02:00
|
|
|
tags:
|
|
|
|
project: ansible-test
|
|
|
|
stage: production
|
|
|
|
sla: 24-7
|
2019-03-12 17:53:49 +01:00
|
|
|
register: vol
|
2020-02-12 14:06:41 +01:00
|
|
|
- name: 'VERIFY: Create volume idempotence'
|
2019-03-12 17:53:49 +01:00
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- vol is successful
|
|
|
|
- vol is not changed
|
2019-08-29 16:08:54 +02:00
|
|
|
- vol.size_gb == 50
|
|
|
|
- vol.name == '{{ cloudscale_resource_prefix }}-vol'
|
2020-02-12 14:06:41 +01:00
|
|
|
- vol.zone.slug == '{{ cloudscale_test_zone }}'
|
2019-08-29 16:08:54 +02:00
|
|
|
- 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
|
2019-03-12 17:53:49 +01:00
|
|
|
|
|
|
|
- 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
|
|
|
|
|
2020-02-12 14:06:41 +01:00
|
|
|
- name: Attach existing volume by name to server idempotence
|
2019-03-12 17:53:49 +01:00
|
|
|
cloudscale_volume:
|
|
|
|
name: '{{ cloudscale_resource_prefix }}-vol'
|
|
|
|
server_uuids:
|
|
|
|
- '{{ server.uuid }}'
|
|
|
|
register: vol
|
2020-02-12 14:06:41 +01:00
|
|
|
- name: 'VERIFY: Attach existing volume by name to server idempotence'
|
2019-03-12 17:53:49 +01:00
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- vol is successful
|
|
|
|
- vol is not changed
|
|
|
|
- server.uuid in vol.server_uuids
|
|
|
|
|
2019-08-29 16:08:54 +02:00
|
|
|
- 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
|
|
|
|
|
2019-03-12 17:53:49 +01:00
|
|
|
- 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
|
|
|
|
|
2020-02-12 14:06:41 +01:00
|
|
|
- name: Resize attached volume by UUID idempotence
|
2019-03-12 17:53:49 +01:00
|
|
|
cloudscale_volume:
|
|
|
|
uuid: '{{ vol.uuid }}'
|
|
|
|
size_gb: 100
|
|
|
|
register: vol
|
2020-02-12 14:06:41 +01:00
|
|
|
- name: 'VERIFY: Resize attached volume by UUID idempotence'
|
2019-03-12 17:53:49 +01:00
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- vol is successful
|
|
|
|
- vol is not changed
|
|
|
|
- vol.size_gb == 100
|
|
|
|
|
2019-08-29 16:08:54 +02:00
|
|
|
- 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'
|
|
|
|
|
2019-03-12 17:53:49 +01:00
|
|
|
- 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'
|
2019-08-29 16:08:54 +02:00
|
|
|
- deleted.uuid == vol.uuid
|
|
|
|
- deleted.name == '{{ cloudscale_resource_prefix }}-vol'
|
2019-03-12 17:53:49 +01:00
|
|
|
|
2020-02-12 14:06:41 +01:00
|
|
|
- name: Delete attached volume by UUID idempotence
|
2019-03-12 17:53:49 +01:00
|
|
|
cloudscale_volume:
|
|
|
|
uuid: '{{ vol.uuid }}'
|
|
|
|
state: 'absent'
|
|
|
|
register: deleted
|
2020-02-12 14:06:41 +01:00
|
|
|
- name: 'VERIFY: Delete attached volume by UUID idempotence'
|
2019-03-12 17:53:49 +01:00
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- deleted is successful
|
|
|
|
- deleted is not changed
|
|
|
|
- deleted.state == 'absent'
|
2019-08-29 16:08:54 +02:00
|
|
|
- deleted.uuid == vol.uuid
|
|
|
|
- not deleted.name
|
2019-03-12 17:53:49 +01:00
|
|
|
|
|
|
|
- name: Create bulk volume and attach
|
|
|
|
cloudscale_volume:
|
|
|
|
name: '{{ cloudscale_resource_prefix }}-bulk'
|
|
|
|
type: bulk
|
2020-02-12 14:06:41 +01:00
|
|
|
zone: '{{ cloudscale_test_zone }}'
|
2019-03-12 17:53:49 +01:00
|
|
|
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
|
|
|
|
|
2019-08-29 16:08:54 +02:00
|
|
|
- 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'
|
|
|
|
|
2019-03-12 17:53:49 +01:00
|
|
|
- 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'
|
|
|
|
|
2019-08-29 16:08:54 +02:00
|
|
|
- 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'
|
2019-03-12 17:53:49 +01:00
|
|
|
|
2019-08-29 16:08:54 +02:00
|
|
|
- import_tasks: failures.yml
|