mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
scaleway: Refactor modules
This commit is contained in:
parent
29cfebe332
commit
8f9d55529d
13 changed files with 544 additions and 652 deletions
|
@ -117,60 +117,6 @@ class Scaleway(object):
|
|||
return self.send("UPDATE", path, data, headers)
|
||||
|
||||
|
||||
class ScalewayAPI(object):
|
||||
|
||||
def __init__(self, module, base_url, headers=None):
|
||||
self.module = module
|
||||
self.headers = {'User-Agent': self.get_user_agent_string(module),
|
||||
'Content-type': 'application/json'}
|
||||
if headers is not None:
|
||||
self.headers.update(headers)
|
||||
self.base_url = base_url
|
||||
|
||||
def _url_builder(self, path):
|
||||
if path[0] == '/':
|
||||
path = path[1:]
|
||||
return '%s/%s' % (self.base_url, path)
|
||||
|
||||
def send(self, method, path, data=None, headers=None):
|
||||
url = self._url_builder(path)
|
||||
data = self.module.jsonify(data)
|
||||
timeout = self.module.params['timeout']
|
||||
|
||||
if headers is not None:
|
||||
self.headers.update(headers)
|
||||
|
||||
resp, info = fetch_url(self.module, url, data=data, headers=self.headers, method=method, timeout=timeout)
|
||||
|
||||
# Exceptions in fetch_url may result in a status -1, the ensures a proper error to the user in all cases
|
||||
if info['status'] == -1:
|
||||
self.module.fail_json(msg=info['msg'])
|
||||
|
||||
return Response(resp, info)
|
||||
|
||||
@staticmethod
|
||||
def get_user_agent_string(module):
|
||||
return "ansible %s Python %s" % (module.ansible_version, sys.version.split(' ')[0])
|
||||
|
||||
def get(self, path, data=None, headers=None):
|
||||
return self.send('GET', path, data, headers)
|
||||
|
||||
def put(self, path, data=None, headers=None):
|
||||
return self.send('PUT', path, data, headers)
|
||||
|
||||
def post(self, path, data=None, headers=None):
|
||||
return self.send('POST', path, data, headers)
|
||||
|
||||
def delete(self, path, data=None, headers=None):
|
||||
return self.send('DELETE', path, data, headers)
|
||||
|
||||
def patch(self, path, data=None, headers=None):
|
||||
return self.send("PATCH", path, data, headers)
|
||||
|
||||
def update(self, path, data=None, headers=None):
|
||||
return self.send("UPDATE", path, data, headers)
|
||||
|
||||
|
||||
SCALEWAY_LOCATION = {
|
||||
'par1': {'name': 'Paris 1', 'country': 'FR', "api_endpoint": 'https://cp-par1.scaleway.com'},
|
||||
'EMEA-FR-PAR1': {'name': 'Paris 1', 'country': 'FR', "api_endpoint": 'https://cp-par1.scaleway.com'},
|
||||
|
|
|
@ -25,6 +25,8 @@ version_added: "2.6"
|
|||
author: Remy Leone (@sieben)
|
||||
description:
|
||||
- "This module manages compute instances on Scaleway."
|
||||
extends_documentation_fragment: scaleway
|
||||
|
||||
options:
|
||||
|
||||
enable_ipv6:
|
||||
|
@ -64,11 +66,6 @@ options:
|
|||
required: false
|
||||
default: []
|
||||
|
||||
oauth_token:
|
||||
description:
|
||||
- Scaleway OAuth token.
|
||||
required: true
|
||||
|
||||
region:
|
||||
description:
|
||||
- Scaleway compute zone
|
||||
|
@ -104,12 +101,6 @@ options:
|
|||
- X64-60GB
|
||||
- X64-120GB
|
||||
|
||||
timeout:
|
||||
description:
|
||||
- Timeout for API calls
|
||||
required: false
|
||||
default: 30
|
||||
|
||||
wait:
|
||||
description:
|
||||
- Wait for the instance to reach its desired state before returning.
|
||||
|
@ -159,9 +150,8 @@ import datetime
|
|||
import time
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.basic import env_fallback
|
||||
from ansible.module_utils.six.moves.urllib.parse import quote as urlquote
|
||||
from ansible.module_utils.scaleway import ScalewayAPI, SCALEWAY_LOCATION
|
||||
from ansible.module_utils.scaleway import SCALEWAY_LOCATION, scaleway_argument_spec, Scaleway
|
||||
|
||||
SCALEWAY_COMMERCIAL_TYPES = [
|
||||
|
||||
|
@ -573,7 +563,6 @@ def server_change_attributes(compute_api, target_server, wished_server):
|
|||
|
||||
|
||||
def core(module):
|
||||
api_token = module.params['oauth_token']
|
||||
region = module.params["region"]
|
||||
wished_server = {
|
||||
"state": module.params["state"],
|
||||
|
@ -584,37 +573,31 @@ def core(module):
|
|||
"tags": module.params["tags"],
|
||||
"organization": module.params["organization"]
|
||||
}
|
||||
module.params['api_url'] = SCALEWAY_LOCATION[region]["api_endpoint"]
|
||||
|
||||
compute_api = ScalewayAPI(module=module,
|
||||
headers={'X-Auth-Token': api_token},
|
||||
base_url=SCALEWAY_LOCATION[region]["api_endpoint"])
|
||||
compute_api = Scaleway(module=module)
|
||||
|
||||
changed, summary = state_strategy[wished_server["state"]](compute_api=compute_api, wished_server=wished_server)
|
||||
module.exit_json(changed=changed, msg=summary)
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = scaleway_argument_spec()
|
||||
argument_spec.update(dict(
|
||||
image=dict(required=True),
|
||||
name=dict(),
|
||||
region=dict(required=True, choices=SCALEWAY_LOCATION.keys()),
|
||||
commercial_type=dict(required=True, choices=SCALEWAY_COMMERCIAL_TYPES),
|
||||
enable_ipv6=dict(default=False, type="bool"),
|
||||
state=dict(choices=state_strategy.keys(), default='present'),
|
||||
tags=dict(type="list", default=[]),
|
||||
organization=dict(required=True),
|
||||
wait=dict(type="bool", default=False),
|
||||
wait_timeout=dict(type="int", default=300),
|
||||
wait_sleep_time=dict(type="int", default=3),
|
||||
))
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
oauth_token=dict(
|
||||
no_log=True,
|
||||
# Support environment variable for Scaleway OAuth Token
|
||||
fallback=(env_fallback, ['SCW_TOKEN', 'SCW_API_KEY', 'SCW_OAUTH_TOKEN']),
|
||||
required=True,
|
||||
),
|
||||
image=dict(required=True),
|
||||
name=dict(),
|
||||
region=dict(required=True, choices=SCALEWAY_LOCATION.keys()),
|
||||
commercial_type=dict(required=True, choices=SCALEWAY_COMMERCIAL_TYPES),
|
||||
enable_ipv6=dict(default=False, type="bool"),
|
||||
state=dict(choices=state_strategy.keys(), default='present'),
|
||||
tags=dict(type="list", default=[]),
|
||||
organization=dict(required=True),
|
||||
timeout=dict(type="int", default=30),
|
||||
wait=dict(type="bool", default=False),
|
||||
wait_timeout=dict(type="int", default=300),
|
||||
wait_sleep_time=dict(type="int", default=3),
|
||||
),
|
||||
argument_spec=argument_spec,
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
|
|
|
@ -26,12 +26,13 @@ author: Remy Leone (@sieben)
|
|||
description:
|
||||
- This module manages SSH keys on Scaleway account
|
||||
U(https://developer.scaleway.com)
|
||||
extends_documentation_fragment: scaleway
|
||||
|
||||
options:
|
||||
state:
|
||||
description:
|
||||
- Indicate desired state of the SSH key.
|
||||
required: true
|
||||
default: present
|
||||
choices:
|
||||
- present
|
||||
- absent
|
||||
|
@ -39,18 +40,11 @@ options:
|
|||
description:
|
||||
- The public SSH key as a string to add.
|
||||
required: true
|
||||
oauth_token:
|
||||
api_url:
|
||||
description:
|
||||
- Scaleway OAuth token.
|
||||
required: true
|
||||
timeout:
|
||||
description:
|
||||
- Timeout for API calls
|
||||
default: 30
|
||||
base_url:
|
||||
description:
|
||||
- Base URL for account API
|
||||
default: "https://account.scaleway.com"
|
||||
- Scaleway API URL
|
||||
default: 'https://account.scaleway.com'
|
||||
aliases: ['base_url']
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
|
@ -83,9 +77,8 @@ data:
|
|||
}
|
||||
'''
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.basic import env_fallback
|
||||
from ansible.module_utils.scaleway import ScalewayAPI
|
||||
from ansible.module_utils.basic import AnsibleModule, env_fallback
|
||||
from ansible.module_utils.scaleway import scaleway_argument_spec, Scaleway
|
||||
|
||||
|
||||
def extract_present_sshkeys(raw_organization_dict):
|
||||
|
@ -105,12 +98,9 @@ def sshkey_user_patch(ssh_lookup):
|
|||
|
||||
|
||||
def core(module):
|
||||
api_token = module.params['oauth_token']
|
||||
ssh_pub_key = module.params['ssh_pub_key']
|
||||
state = module.params["state"]
|
||||
account_api = ScalewayAPI(module,
|
||||
headers={'X-Auth-Token': api_token},
|
||||
base_url=module.params["base_url"])
|
||||
account_api = Scaleway(module)
|
||||
response = account_api.get('organizations')
|
||||
|
||||
status_code = response.status_code
|
||||
|
@ -166,19 +156,14 @@ def core(module):
|
|||
|
||||
|
||||
def main():
|
||||
argument_spec = scaleway_argument_spec()
|
||||
argument_spec.update(dict(
|
||||
state=dict(default='present', choices=['absent', 'present']),
|
||||
ssh_pub_key=dict(required=True),
|
||||
api_url=dict(fallback=(env_fallback, ['SCW_API_URL']), default='https://account.scaleway.com', aliases=['base_url']),
|
||||
))
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
base_url=dict(default='https://account.scaleway.com'),
|
||||
oauth_token=dict(
|
||||
no_log=True,
|
||||
# Support environment variable for Scaleway OAuth Token
|
||||
fallback=(env_fallback, ['SCW_TOKEN', 'SCW_API_KEY', 'SCW_OAUTH_TOKEN']),
|
||||
required=True,
|
||||
),
|
||||
state=dict(choices=['present', 'absent'], required=True),
|
||||
ssh_pub_key=dict(required=True),
|
||||
timeout=dict(type='int', default=30),
|
||||
),
|
||||
argument_spec=argument_spec,
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
|
|
|
@ -25,19 +25,16 @@ author: Henryk Konsek (@hekonsek)
|
|||
description:
|
||||
- This module manages volumes on Scaleway account
|
||||
U(https://developer.scaleway.com)
|
||||
extends_documentation_fragment: scaleway
|
||||
|
||||
options:
|
||||
state:
|
||||
description:
|
||||
- Indicate desired state of the volume.
|
||||
required: true
|
||||
default: present
|
||||
choices:
|
||||
- present
|
||||
- absent
|
||||
oauth_token:
|
||||
description:
|
||||
- Scaleway OAuth token.
|
||||
required: true
|
||||
region:
|
||||
description:
|
||||
- Scaleway region to use (for example par1).
|
||||
|
@ -60,10 +57,6 @@ options:
|
|||
volume_type:
|
||||
description:
|
||||
- Type of the volume (for example 'l_ssd').
|
||||
timeout:
|
||||
description:
|
||||
- Timeout for API calls
|
||||
default: 30
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
|
@ -103,24 +96,18 @@ data:
|
|||
}
|
||||
'''
|
||||
|
||||
from ansible.module_utils.scaleway import ScalewayAPI, SCALEWAY_LOCATION
|
||||
from ansible.module_utils.scaleway import SCALEWAY_LOCATION, scaleway_argument_spec, Scaleway
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.basic import env_fallback
|
||||
from ansible.module_utils.scaleway import ScalewayAPI
|
||||
|
||||
|
||||
def core(module):
|
||||
api_token = module.params['oauth_token']
|
||||
region = module.params['region']
|
||||
state = module.params['state']
|
||||
name = module.params['name']
|
||||
organization = module.params['organization']
|
||||
size = module.params['size']
|
||||
volume_type = module.params['volume_type']
|
||||
|
||||
account_api = ScalewayAPI(module,
|
||||
headers={'X-Auth-Token': api_token},
|
||||
base_url=SCALEWAY_LOCATION[region]['api_endpoint'])
|
||||
account_api = Scaleway(module)
|
||||
response = account_api.get('volumes')
|
||||
status_code = response.status_code
|
||||
volumes_json = response.json
|
||||
|
@ -164,22 +151,17 @@ def core(module):
|
|||
|
||||
|
||||
def main():
|
||||
argument_spec = scaleway_argument_spec()
|
||||
argument_spec.update(dict(
|
||||
state=dict(default='present', choices=['absent', 'present']),
|
||||
name=dict(required=True),
|
||||
size=dict(type='int'),
|
||||
organization=dict(),
|
||||
volume_type=dict(),
|
||||
region=dict(required=True, choices=SCALEWAY_LOCATION.keys()),
|
||||
))
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
region=dict(required=True, choices=SCALEWAY_LOCATION.keys()),
|
||||
oauth_token=dict(
|
||||
no_log=True,
|
||||
# Support environment variable for Scaleway OAuth Token
|
||||
fallback=(env_fallback, ['SCW_TOKEN', 'SCW_API_KEY', 'SCW_OAUTH_TOKEN']),
|
||||
required=True,
|
||||
),
|
||||
state=dict(choices=['present', 'absent'], required=True),
|
||||
name=dict(required=True),
|
||||
size=dict(type='int'),
|
||||
organization=dict(),
|
||||
volume_type=dict(),
|
||||
timeout=dict(type='int', default=30),
|
||||
),
|
||||
argument_spec=argument_spec,
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
|
|
6
test/legacy/roles/scaleway_compute/defaults/main.yml
Normal file
6
test/legacy/roles/scaleway_compute/defaults/main.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
# Below information has been taken from https://developer.scaleway.com/#servers
|
||||
---
|
||||
scaleway_image_id: 89ee4018-f8c3-4dc4-a6b5-bca14f985ebe
|
||||
scaleway_organization: '{{ scw_org }}'
|
||||
scaleway_region: ams1
|
||||
scaleway_commerial_type: START1-S
|
388
test/legacy/roles/scaleway_compute/tasks/main.yml
Normal file
388
test/legacy/roles/scaleway_compute/tasks/main.yml
Normal file
|
@ -0,0 +1,388 @@
|
|||
# SCW_API_KEY='XXX' SCW_ORG='YYY' ansible-playbook ./test/legacy/scaleway.yml --tags test_scaleway_compute
|
||||
|
||||
- name: Create a server (Check)
|
||||
check_mode: yes
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: present
|
||||
image: '{{ scaleway_image_id }}'
|
||||
organization: '{{ scaleway_organization }}'
|
||||
region: '{{ scaleway_region }}'
|
||||
commercial_type: '{{ scaleway_commerial_type }}'
|
||||
|
||||
register: server_creation_check_task
|
||||
|
||||
- debug: var=server_creation_check_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_creation_check_task is success
|
||||
- server_creation_check_task is changed
|
||||
|
||||
- name: Create a server
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: present
|
||||
image: '{{ scaleway_image_id }}'
|
||||
organization: '{{ scaleway_organization }}'
|
||||
region: '{{ scaleway_region }}'
|
||||
commercial_type: '{{ scaleway_commerial_type }}'
|
||||
wait: true
|
||||
|
||||
register: server_creation_task
|
||||
|
||||
- debug: var=server_creation_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_creation_task is success
|
||||
- server_creation_task is changed
|
||||
|
||||
- name: Create a server (Confirmation)
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: present
|
||||
image: '{{ scaleway_image_id }}'
|
||||
organization: '{{ scaleway_organization }}'
|
||||
region: '{{ scaleway_region }}'
|
||||
commercial_type: '{{ scaleway_commerial_type }}'
|
||||
wait: true
|
||||
|
||||
register: server_creation_confirmation_task
|
||||
|
||||
- debug: var=server_creation_confirmation_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_creation_confirmation_task is success
|
||||
- server_creation_confirmation_task is not changed
|
||||
|
||||
- name: Patch server tags (Check)
|
||||
check_mode: yes
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: present
|
||||
image: '{{ scaleway_image_id }}'
|
||||
organization: '{{ scaleway_organization }}'
|
||||
region: '{{ scaleway_region }}'
|
||||
commercial_type: '{{ scaleway_commerial_type }}'
|
||||
tags:
|
||||
- test
|
||||
- www
|
||||
register: server_patching_check_task
|
||||
|
||||
- debug: var=server_patching_check_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_patching_check_task is success
|
||||
- server_patching_check_task is changed
|
||||
|
||||
- name: Patch server tags
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: present
|
||||
image: '{{ scaleway_image_id }}'
|
||||
organization: '{{ scaleway_organization }}'
|
||||
region: '{{ scaleway_region }}'
|
||||
commercial_type: '{{ scaleway_commerial_type }}'
|
||||
wait: true
|
||||
tags:
|
||||
- test
|
||||
- www
|
||||
register: server_patching_task
|
||||
|
||||
- debug: var=server_patching_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_patching_task is success
|
||||
- server_patching_task is changed
|
||||
|
||||
- name: Patch server tags (Confirmation)
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: present
|
||||
image: '{{ scaleway_image_id }}'
|
||||
organization: '{{ scaleway_organization }}'
|
||||
region: '{{ scaleway_region }}'
|
||||
commercial_type: '{{ scaleway_commerial_type }}'
|
||||
wait: true
|
||||
tags:
|
||||
- test
|
||||
- www
|
||||
register: server_patching_confirmation_task
|
||||
|
||||
- debug: var=server_patching_confirmation_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_patching_confirmation_task is success
|
||||
- server_patching_confirmation_task is not changed
|
||||
|
||||
- name: Run it (Check mode)
|
||||
check_mode: yes
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: running
|
||||
image: '{{ scaleway_image_id }}'
|
||||
organization: '{{ scaleway_organization }}'
|
||||
region: '{{ scaleway_region }}'
|
||||
commercial_type: '{{ scaleway_commerial_type }}'
|
||||
tags:
|
||||
- test
|
||||
- www
|
||||
register: server_run_check_task
|
||||
|
||||
- debug: var=server_run_check_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_run_check_task is success
|
||||
- server_run_check_task is changed
|
||||
|
||||
- name: Run it
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: running
|
||||
image: '{{ scaleway_image_id }}'
|
||||
organization: '{{ scaleway_organization }}'
|
||||
region: '{{ scaleway_region }}'
|
||||
commercial_type: '{{ scaleway_commerial_type }}'
|
||||
wait: true
|
||||
tags:
|
||||
- test
|
||||
- www
|
||||
register: server_run_task
|
||||
|
||||
- debug: var=server_run_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_run_task is success
|
||||
- server_run_task is changed
|
||||
|
||||
- name: Run it
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: running
|
||||
image: '{{ scaleway_image_id }}'
|
||||
organization: '{{ scaleway_organization }}'
|
||||
region: '{{ scaleway_region }}'
|
||||
commercial_type: '{{ scaleway_commerial_type }}'
|
||||
wait: true
|
||||
tags:
|
||||
- test
|
||||
- www
|
||||
register: server_run_confirmation_task
|
||||
|
||||
- debug: var=server_run_confirmation_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_run_confirmation_task is success
|
||||
- server_run_confirmation_task is not changed
|
||||
|
||||
- name: Reboot it (Check mode)
|
||||
check_mode: yes
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: restarted
|
||||
image: '{{ scaleway_image_id }}'
|
||||
organization: '{{ scaleway_organization }}'
|
||||
region: '{{ scaleway_region }}'
|
||||
commercial_type: '{{ scaleway_commerial_type }}'
|
||||
tags:
|
||||
- test
|
||||
- www
|
||||
register: server_reboot_check_task
|
||||
|
||||
- debug: var=server_reboot_check_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_reboot_check_task is success
|
||||
- server_reboot_check_task is changed
|
||||
|
||||
- name: Reboot it
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: restarted
|
||||
image: '{{ scaleway_image_id }}'
|
||||
organization: '{{ scaleway_organization }}'
|
||||
region: '{{ scaleway_region }}'
|
||||
commercial_type: '{{ scaleway_commerial_type }}'
|
||||
wait: true
|
||||
tags:
|
||||
- test
|
||||
- www
|
||||
register: server_reboot_task
|
||||
|
||||
- debug: var=server_reboot_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_reboot_task is success
|
||||
- server_reboot_task is changed
|
||||
|
||||
- name: Stop it (Check mode)
|
||||
check_mode: yes
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: stopped
|
||||
image: '{{ scaleway_image_id }}'
|
||||
organization: '{{ scaleway_organization }}'
|
||||
region: '{{ scaleway_region }}'
|
||||
commercial_type: '{{ scaleway_commerial_type }}'
|
||||
tags:
|
||||
- test
|
||||
- www
|
||||
register: server_stop_check_task
|
||||
|
||||
- debug: var=server_stop_check_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_stop_check_task is success
|
||||
- server_stop_check_task is changed
|
||||
|
||||
- name: Stop it
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: stopped
|
||||
image: '{{ scaleway_image_id }}'
|
||||
organization: '{{ scaleway_organization }}'
|
||||
region: '{{ scaleway_region }}'
|
||||
commercial_type: '{{ scaleway_commerial_type }}'
|
||||
wait: true
|
||||
tags:
|
||||
- test
|
||||
- www
|
||||
register: server_stop_task
|
||||
|
||||
- debug: var=server_stop_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_stop_task is success
|
||||
- server_stop_task is changed
|
||||
|
||||
- name: Stop it (Confirmation)
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: stopped
|
||||
image: '{{ scaleway_image_id }}'
|
||||
organization: '{{ scaleway_organization }}'
|
||||
region: '{{ scaleway_region }}'
|
||||
commercial_type: '{{ scaleway_commerial_type }}'
|
||||
wait: true
|
||||
tags:
|
||||
- test
|
||||
- www
|
||||
register: server_stop_confirmation_task
|
||||
|
||||
- debug: var=server_stop_confirmation_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_stop_confirmation_task is success
|
||||
- server_stop_confirmation_task is not changed
|
||||
|
||||
- name: Destroy it (Check mode)
|
||||
check_mode: yes
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: absent
|
||||
image: '{{ scaleway_image_id }}'
|
||||
organization: '{{ scaleway_organization }}'
|
||||
region: '{{ scaleway_region }}'
|
||||
commercial_type: '{{ scaleway_commerial_type }}'
|
||||
tags:
|
||||
- test
|
||||
- www
|
||||
register: server_destroy_check_task
|
||||
|
||||
- debug: var=server_destroy_check_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_destroy_check_task is success
|
||||
- server_destroy_check_task is changed
|
||||
|
||||
- name: Destroy it
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: absent
|
||||
image: '{{ scaleway_image_id }}'
|
||||
organization: '{{ scaleway_organization }}'
|
||||
region: '{{ scaleway_region }}'
|
||||
commercial_type: '{{ scaleway_commerial_type }}'
|
||||
wait: true
|
||||
tags:
|
||||
- test
|
||||
- www
|
||||
register: server_destroy_task
|
||||
|
||||
- debug: var=server_destroy_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_destroy_task is success
|
||||
- server_destroy_task is changed
|
||||
|
||||
- name: Destroy it (Confirmation)
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: absent
|
||||
image: '{{ scaleway_image_id }}'
|
||||
organization: '{{ scaleway_organization }}'
|
||||
region: '{{ scaleway_region }}'
|
||||
commercial_type: '{{ scaleway_commerial_type }}'
|
||||
wait: true
|
||||
tags:
|
||||
- test
|
||||
- www
|
||||
register: server_destroy_confirmation_task
|
||||
|
||||
- debug: var=server_destroy_confirmation_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_destroy_confirmation_task is success
|
||||
- server_destroy_confirmation_task is not changed
|
||||
|
||||
- name: Testing for unauthorized organization
|
||||
ignore_errors: yes
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: present
|
||||
image: '{{ scaleway_image_id }}'
|
||||
organization: this-organization-does-not-exists
|
||||
region: '{{ scaleway_region }}'
|
||||
commercial_type: '{{ scaleway_commerial_type }}'
|
||||
register: unauthorized_organization_task
|
||||
|
||||
- debug: var=unauthorized_organization_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- unauthorized_organization_task is not success
|
||||
- unauthorized_organization_task is not changed
|
||||
|
||||
- name: Testing for unexisting image
|
||||
ignore_errors: yes
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: present
|
||||
image: this-image-does-not-exists
|
||||
organization: '{{ scaleway_organization }}'
|
||||
region: '{{ scaleway_region }}'
|
||||
commercial_type: '{{ scaleway_commerial_type }}'
|
||||
register: unexisting_image_check
|
||||
|
||||
- debug: var=unexisting_image_check
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- unexisting_image_check is not success
|
||||
- unexisting_image_check is not changed
|
41
test/legacy/roles/scaleway_ssh/tasks/main.yml
Normal file
41
test/legacy/roles/scaleway_ssh/tasks/main.yml
Normal file
|
@ -0,0 +1,41 @@
|
|||
# SCW_API_KEY='XXX' ansible-playbook ./test/legacy/scaleway.yml --tags test_scaleway_ssh
|
||||
|
||||
- scaleway_sshkey:
|
||||
ssh_pub_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDf29yyommeGyKSIgSmX0ISVXP+3x6RUY4JDGLoAMFh2efkfDaRVdsvkvnFuUywgP2RewrjTyLE8w0NpCBHVS5Fm1BAn3yvxOUtTMxTbsQcw6HQ8swJ02+1tewJYjHPwc4GrBqiDo3Nmlq354Us0zBOJg/bBzuEnVD5eJ3GO3gKaCSUYTVrYwO0U4eJE0D9OJeUP9J48kl4ULbCub976+mTHdBvlzRw0Tzfl2kxgdDwlks0l2NefY/uiTdz2oMt092bAY3wZHxjto/DXoChxvaf5s2k8Zb+J7CjimUYnzPlH+zA9F6ROjP5AUu6ZWPd0jOIBl1nDWWb2j/qfNLYM43l sieben@sieben-macbook.local"
|
||||
state: present
|
||||
check_mode: yes
|
||||
|
||||
- scaleway_sshkey:
|
||||
ssh_pub_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDf29yyommeGyKSIgSmX0ISVXP+3x6RUY4JDGLoAMFh2efkfDaRVdsvkvnFuUywgP2RewrjTyLE8w0NpCBHVS5Fm1BAn3yvxOUtTMxTbsQcw6HQ8swJ02+1tewJYjHPwc4GrBqiDo3Nmlq354Us0zBOJg/bBzuEnVD5eJ3GO3gKaCSUYTVrYwO0U4eJE0D9OJeUP9J48kl4ULbCub976+mTHdBvlzRw0Tzfl2kxgdDwlks0l2NefY/uiTdz2oMt092bAY3wZHxjto/DXoChxvaf5s2k8Zb+J7CjimUYnzPlH+zA9F6ROjP5AUu6ZWPd0jOIBl1nDWWb2j/qfNLYM43l sieben@sieben-macbook.local"
|
||||
state: present
|
||||
register: result1
|
||||
|
||||
- scaleway_sshkey:
|
||||
ssh_pub_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDf29yyommeGyKSIgSmX0ISVXP+3x6RUY4JDGLoAMFh2efkfDaRVdsvkvnFuUywgP2RewrjTyLE8w0NpCBHVS5Fm1BAn3yvxOUtTMxTbsQcw6HQ8swJ02+1tewJYjHPwc4GrBqiDo3Nmlq354Us0zBOJg/bBzuEnVD5eJ3GO3gKaCSUYTVrYwO0U4eJE0D9OJeUP9J48kl4ULbCub976+mTHdBvlzRw0Tzfl2kxgdDwlks0l2NefY/uiTdz2oMt092bAY3wZHxjto/DXoChxvaf5s2k8Zb+J7CjimUYnzPlH+zA9F6ROjP5AUu6ZWPd0jOIBl1nDWWb2j/qfNLYM43l sieben@sieben-macbook.local"
|
||||
state: present
|
||||
register: result2
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result1 is success and result1 is changed
|
||||
- result2 is success and result2 is not changed
|
||||
|
||||
- scaleway_sshkey:
|
||||
ssh_pub_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDf29yyommeGyKSIgSmX0ISVXP+3x6RUY4JDGLoAMFh2efkfDaRVdsvkvnFuUywgP2RewrjTyLE8w0NpCBHVS5Fm1BAn3yvxOUtTMxTbsQcw6HQ8swJ02+1tewJYjHPwc4GrBqiDo3Nmlq354Us0zBOJg/bBzuEnVD5eJ3GO3gKaCSUYTVrYwO0U4eJE0D9OJeUP9J48kl4ULbCub976+mTHdBvlzRw0Tzfl2kxgdDwlks0l2NefY/uiTdz2oMt092bAY3wZHxjto/DXoChxvaf5s2k8Zb+J7CjimUYnzPlH+zA9F6ROjP5AUu6ZWPd0jOIBl1nDWWb2j/qfNLYM43l sieben@sieben-macbook.local"
|
||||
state: absent
|
||||
check_mode: yes
|
||||
|
||||
- scaleway_sshkey:
|
||||
ssh_pub_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDf29yyommeGyKSIgSmX0ISVXP+3x6RUY4JDGLoAMFh2efkfDaRVdsvkvnFuUywgP2RewrjTyLE8w0NpCBHVS5Fm1BAn3yvxOUtTMxTbsQcw6HQ8swJ02+1tewJYjHPwc4GrBqiDo3Nmlq354Us0zBOJg/bBzuEnVD5eJ3GO3gKaCSUYTVrYwO0U4eJE0D9OJeUP9J48kl4ULbCub976+mTHdBvlzRw0Tzfl2kxgdDwlks0l2NefY/uiTdz2oMt092bAY3wZHxjto/DXoChxvaf5s2k8Zb+J7CjimUYnzPlH+zA9F6ROjP5AUu6ZWPd0jOIBl1nDWWb2j/qfNLYM43l sieben@sieben-macbook.local"
|
||||
state: absent
|
||||
register: result1
|
||||
|
||||
- scaleway_sshkey:
|
||||
ssh_pub_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDf29yyommeGyKSIgSmX0ISVXP+3x6RUY4JDGLoAMFh2efkfDaRVdsvkvnFuUywgP2RewrjTyLE8w0NpCBHVS5Fm1BAn3yvxOUtTMxTbsQcw6HQ8swJ02+1tewJYjHPwc4GrBqiDo3Nmlq354Us0zBOJg/bBzuEnVD5eJ3GO3gKaCSUYTVrYwO0U4eJE0D9OJeUP9J48kl4ULbCub976+mTHdBvlzRw0Tzfl2kxgdDwlks0l2NefY/uiTdz2oMt092bAY3wZHxjto/DXoChxvaf5s2k8Zb+J7CjimUYnzPlH+zA9F6ROjP5AUu6ZWPd0jOIBl1nDWWb2j/qfNLYM43l sieben@sieben-macbook.local"
|
||||
state: absent
|
||||
register: result2
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result1 is success and result1 is changed
|
||||
- result2 is success and result2 is not changed
|
3
test/legacy/roles/scaleway_volume/defaults/main.yml
Normal file
3
test/legacy/roles/scaleway_volume/defaults/main.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
scaleway_organization: '{{ scw_org }}'
|
||||
scaleway_region: ams1
|
43
test/legacy/roles/scaleway_volume/tasks/main.yml
Normal file
43
test/legacy/roles/scaleway_volume/tasks/main.yml
Normal file
|
@ -0,0 +1,43 @@
|
|||
# SCW_API_KEY='XXX' SCW_ORG='YYY' ansible-playbook ./test/legacy/scaleway.yml --tags test_scaleway_volume
|
||||
|
||||
- name: Make sure volume is not there before tests
|
||||
scaleway_volume:
|
||||
name: ansible-test-volume
|
||||
state: absent
|
||||
region: '{{ scaleway_region }}'
|
||||
organization: '{{ scaleway_organization }}'
|
||||
register: server_creation_check_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_creation_check_task is success
|
||||
|
||||
- name: Create volume
|
||||
scaleway_volume:
|
||||
name: ansible-test-volume
|
||||
state: present
|
||||
region: '{{ scaleway_region }}'
|
||||
organization: '{{ scaleway_organization }}'
|
||||
"size": 10000000000
|
||||
volume_type: l_ssd
|
||||
register: server_creation_check_task
|
||||
|
||||
- debug: var=server_creation_check_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_creation_check_task is success
|
||||
- server_creation_check_task is changed
|
||||
|
||||
- name: Make sure volume is deleted
|
||||
scaleway_volume:
|
||||
name: ansible-test-volume
|
||||
state: absent
|
||||
region: '{{ scaleway_region }}'
|
||||
organization: '{{ scaleway_organization }}'
|
||||
register: server_creation_check_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_creation_check_task is success
|
||||
- server_creation_check_task is changed
|
13
test/legacy/scaleway.yml
Normal file
13
test/legacy/scaleway.yml
Normal file
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
- hosts: localhost
|
||||
gather_facts: no
|
||||
connection: local
|
||||
environment:
|
||||
SCW_API_KEY: "{{ lookup('env', 'SCW_API_KEY') }}"
|
||||
vars:
|
||||
scw_org: "{{ lookup('env', 'SCW_ORG') }}"
|
||||
|
||||
roles:
|
||||
- { role: scaleway_ssh, tags: test_scaleway_ssh }
|
||||
- { role: scaleway_volume, tags: test_scaleway_volume }
|
||||
- { role: scaleway_compute, tags: test_scaleway_compute }
|
|
@ -1,396 +0,0 @@
|
|||
# SCW_API_KEY='XXX' ansible-playbook ./test/legacy/scaleway_compute.yml
|
||||
|
||||
- name: Test compute instance lifecyle on a Scaleway account
|
||||
hosts: localhost
|
||||
gather_facts: no
|
||||
environment:
|
||||
SCW_API_KEY: "{{ lookup('env', 'SCW_API_KEY') }}"
|
||||
|
||||
tasks:
|
||||
|
||||
- name: Create a server (Check)
|
||||
check_mode: yes
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: present
|
||||
image: 89ee4018-f8c3-4dc4-a6b5-bca14f985ebe
|
||||
organization: 951df375-e094-4d26-97c1-ba548eeb9c42
|
||||
region: ams1
|
||||
commercial_type: START1-S
|
||||
|
||||
register: server_creation_check_task
|
||||
|
||||
- debug: var=server_creation_check_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_creation_check_task is success
|
||||
- server_creation_check_task is changed
|
||||
|
||||
- name: Create a server
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: present
|
||||
image: 89ee4018-f8c3-4dc4-a6b5-bca14f985ebe
|
||||
organization: 951df375-e094-4d26-97c1-ba548eeb9c42
|
||||
region: ams1
|
||||
commercial_type: START1-S
|
||||
wait: true
|
||||
|
||||
register: server_creation_task
|
||||
|
||||
- debug: var=server_creation_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_creation_task is success
|
||||
- server_creation_task is changed
|
||||
|
||||
- name: Create a server (Confirmation)
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: present
|
||||
image: 89ee4018-f8c3-4dc4-a6b5-bca14f985ebe
|
||||
organization: 951df375-e094-4d26-97c1-ba548eeb9c42
|
||||
region: ams1
|
||||
commercial_type: START1-S
|
||||
wait: true
|
||||
|
||||
register: server_creation_confirmation_task
|
||||
|
||||
- debug: var=server_creation_confirmation_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_creation_confirmation_task is success
|
||||
- server_creation_confirmation_task is not changed
|
||||
|
||||
- name: Patch server tags (Check)
|
||||
check_mode: yes
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: present
|
||||
image: 89ee4018-f8c3-4dc4-a6b5-bca14f985ebe
|
||||
organization: 951df375-e094-4d26-97c1-ba548eeb9c42
|
||||
region: ams1
|
||||
commercial_type: START1-S
|
||||
tags:
|
||||
- test
|
||||
- www
|
||||
register: server_patching_check_task
|
||||
|
||||
- debug: var=server_patching_check_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_patching_check_task is success
|
||||
- server_patching_check_task is changed
|
||||
|
||||
- name: Patch server tags
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: present
|
||||
image: 89ee4018-f8c3-4dc4-a6b5-bca14f985ebe
|
||||
organization: 951df375-e094-4d26-97c1-ba548eeb9c42
|
||||
region: ams1
|
||||
commercial_type: START1-S
|
||||
wait: true
|
||||
tags:
|
||||
- test
|
||||
- www
|
||||
register: server_patching_task
|
||||
|
||||
- debug: var=server_patching_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_patching_task is success
|
||||
- server_patching_task is changed
|
||||
|
||||
- name: Patch server tags (Confirmation)
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: present
|
||||
image: 89ee4018-f8c3-4dc4-a6b5-bca14f985ebe
|
||||
organization: 951df375-e094-4d26-97c1-ba548eeb9c42
|
||||
region: ams1
|
||||
commercial_type: START1-S
|
||||
wait: true
|
||||
tags:
|
||||
- test
|
||||
- www
|
||||
register: server_patching_confirmation_task
|
||||
|
||||
- debug: var=server_patching_confirmation_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_patching_confirmation_task is success
|
||||
- server_patching_confirmation_task is not changed
|
||||
|
||||
- name: Run it (Check mode)
|
||||
check_mode: yes
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: running
|
||||
image: 89ee4018-f8c3-4dc4-a6b5-bca14f985ebe
|
||||
organization: 951df375-e094-4d26-97c1-ba548eeb9c42
|
||||
region: ams1
|
||||
commercial_type: START1-S
|
||||
tags:
|
||||
- test
|
||||
- www
|
||||
register: server_run_check_task
|
||||
|
||||
- debug: var=server_run_check_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_run_check_task is success
|
||||
- server_run_check_task is changed
|
||||
|
||||
- name: Run it
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: running
|
||||
image: 89ee4018-f8c3-4dc4-a6b5-bca14f985ebe
|
||||
organization: 951df375-e094-4d26-97c1-ba548eeb9c42
|
||||
region: ams1
|
||||
commercial_type: START1-S
|
||||
wait: true
|
||||
tags:
|
||||
- test
|
||||
- www
|
||||
register: server_run_task
|
||||
|
||||
- debug: var=server_run_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_run_task is success
|
||||
- server_run_task is changed
|
||||
|
||||
- name: Run it
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: running
|
||||
image: 89ee4018-f8c3-4dc4-a6b5-bca14f985ebe
|
||||
organization: 951df375-e094-4d26-97c1-ba548eeb9c42
|
||||
region: ams1
|
||||
commercial_type: START1-S
|
||||
wait: true
|
||||
tags:
|
||||
- test
|
||||
- www
|
||||
register: server_run_confirmation_task
|
||||
|
||||
- debug: var=server_run_confirmation_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_run_confirmation_task is success
|
||||
- server_run_confirmation_task is not changed
|
||||
|
||||
- name: Reboot it (Check mode)
|
||||
check_mode: yes
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: restarted
|
||||
image: 89ee4018-f8c3-4dc4-a6b5-bca14f985ebe
|
||||
organization: 951df375-e094-4d26-97c1-ba548eeb9c42
|
||||
region: ams1
|
||||
commercial_type: START1-S
|
||||
tags:
|
||||
- test
|
||||
- www
|
||||
register: server_reboot_check_task
|
||||
|
||||
- debug: var=server_reboot_check_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_reboot_check_task is success
|
||||
- server_reboot_check_task is changed
|
||||
|
||||
- name: Reboot it
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: restarted
|
||||
image: 89ee4018-f8c3-4dc4-a6b5-bca14f985ebe
|
||||
organization: 951df375-e094-4d26-97c1-ba548eeb9c42
|
||||
region: ams1
|
||||
commercial_type: START1-S
|
||||
wait: true
|
||||
tags:
|
||||
- test
|
||||
- www
|
||||
register: server_reboot_task
|
||||
|
||||
- debug: var=server_reboot_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_reboot_task is success
|
||||
- server_reboot_task is changed
|
||||
|
||||
- name: Stop it (Check mode)
|
||||
check_mode: yes
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: stopped
|
||||
image: 89ee4018-f8c3-4dc4-a6b5-bca14f985ebe
|
||||
organization: 951df375-e094-4d26-97c1-ba548eeb9c42
|
||||
region: ams1
|
||||
commercial_type: START1-S
|
||||
tags:
|
||||
- test
|
||||
- www
|
||||
register: server_stop_check_task
|
||||
|
||||
- debug: var=server_stop_check_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_stop_check_task is success
|
||||
- server_stop_check_task is changed
|
||||
|
||||
- name: Stop it
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: stopped
|
||||
image: 89ee4018-f8c3-4dc4-a6b5-bca14f985ebe
|
||||
organization: 951df375-e094-4d26-97c1-ba548eeb9c42
|
||||
region: ams1
|
||||
commercial_type: START1-S
|
||||
wait: true
|
||||
tags:
|
||||
- test
|
||||
- www
|
||||
register: server_stop_task
|
||||
|
||||
- debug: var=server_stop_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_stop_task is success
|
||||
- server_stop_task is changed
|
||||
|
||||
- name: Stop it (Confirmation)
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: stopped
|
||||
image: 89ee4018-f8c3-4dc4-a6b5-bca14f985ebe
|
||||
organization: 951df375-e094-4d26-97c1-ba548eeb9c42
|
||||
region: ams1
|
||||
commercial_type: START1-S
|
||||
wait: true
|
||||
tags:
|
||||
- test
|
||||
- www
|
||||
register: server_stop_confirmation_task
|
||||
|
||||
- debug: var=server_stop_confirmation_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_stop_confirmation_task is success
|
||||
- server_stop_confirmation_task is not changed
|
||||
|
||||
- name: Destroy it (Check mode)
|
||||
check_mode: yes
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: absent
|
||||
image: 89ee4018-f8c3-4dc4-a6b5-bca14f985ebe
|
||||
organization: 951df375-e094-4d26-97c1-ba548eeb9c42
|
||||
region: ams1
|
||||
commercial_type: START1-S
|
||||
tags:
|
||||
- test
|
||||
- www
|
||||
register: server_destroy_check_task
|
||||
|
||||
- debug: var=server_destroy_check_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_destroy_check_task is success
|
||||
- server_destroy_check_task is changed
|
||||
|
||||
- name: Destroy it
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: absent
|
||||
image: 89ee4018-f8c3-4dc4-a6b5-bca14f985ebe
|
||||
organization: 951df375-e094-4d26-97c1-ba548eeb9c42
|
||||
region: ams1
|
||||
commercial_type: START1-S
|
||||
wait: true
|
||||
tags:
|
||||
- test
|
||||
- www
|
||||
register: server_destroy_task
|
||||
|
||||
- debug: var=server_destroy_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_destroy_task is success
|
||||
- server_destroy_task is changed
|
||||
|
||||
- name: Destroy it (Confirmation)
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: absent
|
||||
image: 89ee4018-f8c3-4dc4-a6b5-bca14f985ebe
|
||||
organization: 951df375-e094-4d26-97c1-ba548eeb9c42
|
||||
region: ams1
|
||||
commercial_type: START1-S
|
||||
wait: true
|
||||
tags:
|
||||
- test
|
||||
- www
|
||||
register: server_destroy_confirmation_task
|
||||
|
||||
- debug: var=server_destroy_confirmation_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_destroy_confirmation_task is success
|
||||
- server_destroy_confirmation_task is not changed
|
||||
|
||||
- name: Testing for unauthorized organization
|
||||
ignore_errors: yes
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: present
|
||||
image: 89ee4018-f8c3-4dc4-a6b5-bca14f985ebe
|
||||
organization: this-organization-does-not-exists
|
||||
region: ams1
|
||||
commercial_type: START1-S
|
||||
register: unauthorized_organization_task
|
||||
|
||||
- debug: var=unauthorized_organization_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- unauthorized_organization_task is not success
|
||||
- unauthorized_organization_task is not changed
|
||||
|
||||
- name: Testing for unexisting image
|
||||
ignore_errors: yes
|
||||
scaleway_compute:
|
||||
name: foobar
|
||||
state: present
|
||||
image: this-image-does-not-exists
|
||||
organization: 951df375-e094-4d26-97c1-ba548eeb9c42
|
||||
region: ams1
|
||||
commercial_type: START1-S
|
||||
register: unexisting_image_check
|
||||
|
||||
- debug: var=unexisting_image_check
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- unexisting_image_check is not success
|
||||
- unexisting_image_check is not changed
|
|
@ -1,49 +0,0 @@
|
|||
# SCW_API_KEY='XXX' ansible-playbook ./test/legacy/scaleway_ssh_playbook.yml
|
||||
|
||||
- name: Test SSH key lifecyle on a Scaleway account
|
||||
hosts: localhost
|
||||
gather_facts: no
|
||||
environment:
|
||||
SCW_API_KEY: "{{ lookup('env', 'SCW_API_KEY') }}"
|
||||
|
||||
tasks:
|
||||
|
||||
- scaleway_sshkey:
|
||||
ssh_pub_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDf29yyommeGyKSIgSmX0ISVXP+3x6RUY4JDGLoAMFh2efkfDaRVdsvkvnFuUywgP2RewrjTyLE8w0NpCBHVS5Fm1BAn3yvxOUtTMxTbsQcw6HQ8swJ02+1tewJYjHPwc4GrBqiDo3Nmlq354Us0zBOJg/bBzuEnVD5eJ3GO3gKaCSUYTVrYwO0U4eJE0D9OJeUP9J48kl4ULbCub976+mTHdBvlzRw0Tzfl2kxgdDwlks0l2NefY/uiTdz2oMt092bAY3wZHxjto/DXoChxvaf5s2k8Zb+J7CjimUYnzPlH+zA9F6ROjP5AUu6ZWPd0jOIBl1nDWWb2j/qfNLYM43l sieben@sieben-macbook.local"
|
||||
state: present
|
||||
check_mode: yes
|
||||
|
||||
- scaleway_sshkey:
|
||||
ssh_pub_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDf29yyommeGyKSIgSmX0ISVXP+3x6RUY4JDGLoAMFh2efkfDaRVdsvkvnFuUywgP2RewrjTyLE8w0NpCBHVS5Fm1BAn3yvxOUtTMxTbsQcw6HQ8swJ02+1tewJYjHPwc4GrBqiDo3Nmlq354Us0zBOJg/bBzuEnVD5eJ3GO3gKaCSUYTVrYwO0U4eJE0D9OJeUP9J48kl4ULbCub976+mTHdBvlzRw0Tzfl2kxgdDwlks0l2NefY/uiTdz2oMt092bAY3wZHxjto/DXoChxvaf5s2k8Zb+J7CjimUYnzPlH+zA9F6ROjP5AUu6ZWPd0jOIBl1nDWWb2j/qfNLYM43l sieben@sieben-macbook.local"
|
||||
state: present
|
||||
register: result1
|
||||
|
||||
- scaleway_sshkey:
|
||||
ssh_pub_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDf29yyommeGyKSIgSmX0ISVXP+3x6RUY4JDGLoAMFh2efkfDaRVdsvkvnFuUywgP2RewrjTyLE8w0NpCBHVS5Fm1BAn3yvxOUtTMxTbsQcw6HQ8swJ02+1tewJYjHPwc4GrBqiDo3Nmlq354Us0zBOJg/bBzuEnVD5eJ3GO3gKaCSUYTVrYwO0U4eJE0D9OJeUP9J48kl4ULbCub976+mTHdBvlzRw0Tzfl2kxgdDwlks0l2NefY/uiTdz2oMt092bAY3wZHxjto/DXoChxvaf5s2k8Zb+J7CjimUYnzPlH+zA9F6ROjP5AUu6ZWPd0jOIBl1nDWWb2j/qfNLYM43l sieben@sieben-macbook.local"
|
||||
state: present
|
||||
register: result2
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result1 is success and result1 is changed
|
||||
- result2 is success and result2 is not changed
|
||||
|
||||
- scaleway_sshkey:
|
||||
ssh_pub_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDf29yyommeGyKSIgSmX0ISVXP+3x6RUY4JDGLoAMFh2efkfDaRVdsvkvnFuUywgP2RewrjTyLE8w0NpCBHVS5Fm1BAn3yvxOUtTMxTbsQcw6HQ8swJ02+1tewJYjHPwc4GrBqiDo3Nmlq354Us0zBOJg/bBzuEnVD5eJ3GO3gKaCSUYTVrYwO0U4eJE0D9OJeUP9J48kl4ULbCub976+mTHdBvlzRw0Tzfl2kxgdDwlks0l2NefY/uiTdz2oMt092bAY3wZHxjto/DXoChxvaf5s2k8Zb+J7CjimUYnzPlH+zA9F6ROjP5AUu6ZWPd0jOIBl1nDWWb2j/qfNLYM43l sieben@sieben-macbook.local"
|
||||
state: absent
|
||||
check_mode: yes
|
||||
|
||||
- scaleway_sshkey:
|
||||
ssh_pub_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDf29yyommeGyKSIgSmX0ISVXP+3x6RUY4JDGLoAMFh2efkfDaRVdsvkvnFuUywgP2RewrjTyLE8w0NpCBHVS5Fm1BAn3yvxOUtTMxTbsQcw6HQ8swJ02+1tewJYjHPwc4GrBqiDo3Nmlq354Us0zBOJg/bBzuEnVD5eJ3GO3gKaCSUYTVrYwO0U4eJE0D9OJeUP9J48kl4ULbCub976+mTHdBvlzRw0Tzfl2kxgdDwlks0l2NefY/uiTdz2oMt092bAY3wZHxjto/DXoChxvaf5s2k8Zb+J7CjimUYnzPlH+zA9F6ROjP5AUu6ZWPd0jOIBl1nDWWb2j/qfNLYM43l sieben@sieben-macbook.local"
|
||||
state: absent
|
||||
register: result1
|
||||
|
||||
- scaleway_sshkey:
|
||||
ssh_pub_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDf29yyommeGyKSIgSmX0ISVXP+3x6RUY4JDGLoAMFh2efkfDaRVdsvkvnFuUywgP2RewrjTyLE8w0NpCBHVS5Fm1BAn3yvxOUtTMxTbsQcw6HQ8swJ02+1tewJYjHPwc4GrBqiDo3Nmlq354Us0zBOJg/bBzuEnVD5eJ3GO3gKaCSUYTVrYwO0U4eJE0D9OJeUP9J48kl4ULbCub976+mTHdBvlzRw0Tzfl2kxgdDwlks0l2NefY/uiTdz2oMt092bAY3wZHxjto/DXoChxvaf5s2k8Zb+J7CjimUYnzPlH+zA9F6ROjP5AUu6ZWPd0jOIBl1nDWWb2j/qfNLYM43l sieben@sieben-macbook.local"
|
||||
state: absent
|
||||
register: result2
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result1 is success and result1 is changed
|
||||
- result2 is success and result2 is not changed
|
|
@ -1,53 +0,0 @@
|
|||
# SCW_API_KEY='XXX' SCW_ORG='YYY' ansible-playbook ./test/legacy/scaleway_volume.yml
|
||||
|
||||
- name: Test compute instance lifecyle on a Scaleway account
|
||||
hosts: localhost
|
||||
gather_facts: no
|
||||
environment:
|
||||
SCW_API_KEY: "{{ lookup('env', 'SCW_API_KEY') }}"
|
||||
vars:
|
||||
scw_org: "{{ lookup('env', 'SCW_ORG') }}"
|
||||
|
||||
tasks:
|
||||
|
||||
- name: Make sure volume is not there before tests
|
||||
scaleway_volume:
|
||||
name: ansible-test-volume
|
||||
state: absent
|
||||
region: par1
|
||||
organization: "{{ scw_org }}"
|
||||
register: server_creation_check_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_creation_check_task is success
|
||||
|
||||
- name: Create volume
|
||||
scaleway_volume:
|
||||
name: ansible-test-volume
|
||||
state: present
|
||||
region: par1
|
||||
organization: "{{ scw_org }}"
|
||||
"size": 10000000000
|
||||
volume_type: l_ssd
|
||||
register: server_creation_check_task
|
||||
|
||||
- debug: var=server_creation_check_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_creation_check_task is success
|
||||
- server_creation_check_task is changed
|
||||
|
||||
- name: Make sure volume is deleted
|
||||
scaleway_volume:
|
||||
name: ansible-test-volume
|
||||
state: absent
|
||||
region: par1
|
||||
organization: "{{ scw_org }}"
|
||||
register: server_creation_check_task
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- server_creation_check_task is success
|
||||
- server_creation_check_task is changed
|
Loading…
Reference in a new issue