1---
2- name: Create two volumes with the same name
3  uri:
4    url: 'https://api.cloudscale.ch/v1/volumes'
5    method: POST
6    headers:
7      Authorization: 'Bearer {{ cloudscale_api_token }}'
8    body:
9      name: '{{ cloudscale_resource_prefix }}-duplicate'
10      size_gb: 50
11    body_format: json
12    status_code: 201
13  register: duplicate
14  with_sequence: count=2
15
16- name: Try access to duplicate name
17  cloudscale_volume:
18    name: '{{ cloudscale_resource_prefix }}-duplicate'
19    size_gb: 10
20  register: vol
21  ignore_errors: True
22- name: 'VERIFY: Try access to duplicate name'
23  assert:
24    that:
25      - vol is failed
26
27- name: Fail volume creation with UUID
28  cloudscale_volume:
29    uuid: ea3b39a3-77a8-4d0b-881d-0bb00a1e7f48
30    name: '{{ cloudscale_resource_prefix }}-inexistent'
31    size_gb: 10
32  register: vol
33  ignore_errors: True
34- name: 'VERIFY: Fail volume creation with UUID'
35  assert:
36    that:
37      - vol is failed
38      - vol.msg.startswith('The volume with UUID \'ea3b39a3-77a8-4d0b-881d-0bb00a1e7f48\' was not found')
39