cloudscale_server – Manages servers on the cloudscale.ch IaaS service

Synopsis

  • Create, update, start, stop and delete servers on the cloudscale.ch IaaS service.

Parameters

Parameter Choices/Defaults Comments
anti_affinity_with
string
UUID of another server to create an anti-affinity group with.
Mutually exclusive with server_groups.
Deprecated, removed in version 2.11.
api_timeout
-
added in 2.5
Default:
30
Timeout in seconds for calls to the cloudscale.ch API.
api_token
-
cloudscale.ch API token.
This can also be passed in the CLOUDSCALE_API_TOKEN environment variable.
bulk_volume_size_gb
integer
Size of the bulk storage volume in GB.
No bulk storage volume if not set.
flavor
string
Flavor of the server.
force
boolean
added in 2.8
    Choices:
  • no ←
  • yes
Allow to stop the running server for updating if necessary.
image
-
Image used to create the server.
name
string
Name of the Server.
Either name or uuid are required.
password
string
added in 2.8
Password for the server.
server_groups
list
added in 2.8
List of UUID or names of server groups.
Mutually exclusive with anti_affinity_with.
ssh_keys
list
List of SSH public keys.
Use the full content of your .pub file here.
state
string
    Choices:
  • running ←
  • stopped
  • absent
State of the server.
tags
dictionary
added in 2.9
Tags assosiated with the servers. Set this to {} to clear any tags.
use_ipv6
boolean
    Choices:
  • no
  • yes ←
Enable IPv6 on the public network interface.
use_private_network
boolean
    Choices:
  • no ←
  • yes
Attach a private network interface to the server.
use_public_network
boolean
    Choices:
  • no
  • yes ←
Attach a public network interface to the server.
user_data
string
Cloud-init configuration (cloud-config) data to use for the server.
uuid
string
UUID of the server.
Either name or uuid are required.
volume_size_gb
integer
Default:
10
Size of the root volume in GB.

Notes

Note

  • Since version 2.8, uuid and name or not mutually exclusive anymore.
  • If uuid option is provided, it takes precedence over name for server selection. This allows to update the server’s name.
  • If no uuid option is provided, name is used for server selection. If more than one server with this name exists, execution is aborted.
  • Only the name and flavor are evaluated for the update.
  • The option force=true must be given to allow the reboot of existing running servers for applying the changes.
  • Instead of the api_token parameter the CLOUDSCALE_API_TOKEN environment variable can be used.
  • All operations are performed using the cloudscale.ch public API v1.
  • For details consult the full API documentation: https://www.cloudscale.ch/en/api/v1.
  • A valid API token is required for all operations. You can create as many tokens as you like using the cloudscale.ch control panel at https://control.cloudscale.ch.

Examples

# Create and start a server with an existing server group (shiny-group)
- name: Start cloudscale.ch server
  cloudscale_server:
    name: my-shiny-cloudscale-server
    image: debian-8
    flavor: flex-4
    ssh_keys: ssh-rsa XXXXXXXXXX...XXXX ansible@cloudscale
    server_groups: shiny-group
    use_private_network: True
    bulk_volume_size_gb: 100
    api_token: xxxxxx

# Start another server in anti-affinity (server group shiny-group)
- name: Start second cloudscale.ch server
  cloudscale_server:
    name: my-other-shiny-server
    image: ubuntu-16.04
    flavor: flex-8
    ssh_keys: ssh-rsa XXXXXXXXXXX ansible@cloudscale
    server_groups: shiny-group
    api_token: xxxxxx


# Force to update the flavor of a running server
- name: Start cloudscale.ch server
  cloudscale_server:
    name: my-shiny-cloudscale-server
    image: debian-8
    flavor: flex-8
    force: yes
    ssh_keys: ssh-rsa XXXXXXXXXX...XXXX ansible@cloudscale
    use_private_network: True
    bulk_volume_size_gb: 100
    api_token: xxxxxx
  register: server1

# Stop the first server
- name: Stop my first server
  cloudscale_server:
    uuid: '{{ server1.uuid }}'
    state: stopped
    api_token: xxxxxx

# Delete my second server
- name: Delete my second server
  cloudscale_server:
    name: my-other-shiny-server
    state: absent
    api_token: xxxxxx

# Start a server and wait for the SSH host keys to be generated
- name: Start server and wait for SSH host keys
  cloudscale_server:
    name: my-cloudscale-server-with-ssh-key
    image: debian-8
    flavor: flex-4
    ssh_keys: ssh-rsa XXXXXXXXXXX ansible@cloudscale
    api_token: xxxxxx
  register: server
  until: server.ssh_fingerprints is defined and server.ssh_fingerprints
  retries: 60
  delay: 2

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
anti_affinity_with
list
success when not state == absent
List of servers in the same anti-affinity group
Deprecated, removed in version 2.11.

flavor
string
success when not state == absent
The flavor that has been used for this server

Sample:
flex-8
href
string
success when not state == absent
API URL to get details about this server

Sample:
https://api.cloudscale.ch/v1/servers/cfde831a-4e87-4a75-960f-89b0148aa2cc
image
string
success when not state == absent
The image used for booting this server

Sample:
debian-8
interfaces
list
success when not state == absent
List of network ports attached to the server

Sample:
[{'type': 'public', 'addresses': ['...']}]
name
string
success
The display name of the server

Sample:
its-a-me-mario.cloudscale.ch
server_groups
list
added in 2.8
success when not state == absent
List of server groups

Sample:
[{'href': 'https://api.cloudscale.ch/v1/server-groups/...', 'uuid': '...', 'name': 'db-group'}]
ssh_fingerprints
list
success when not state == absent
A list of SSH host key fingerprints. Will be null until the host keys could be retrieved from the server.

Sample:
['ecdsa-sha2-nistp256 SHA256:XXXX', '...']
ssh_host_keys
list
success when not state == absent
A list of SSH host keys. Will be null until the host keys could be retrieved from the server.

Sample:
['ecdsa-sha2-nistp256 XXXXX', '...']
state
string
success
The current status of the server

Sample:
running
tags
dictionary
added in 2.9
success
Tags assosiated with the volume.

Sample:
{'project': 'my project'}
uuid
string
success
The unique identifier for this server

Sample:
cfde831a-4e87-4a75-960f-89b0148aa2cc
volumes
list
success when not state == absent
List of volumes attached to the server

Sample:
[{'type': 'ssd', 'device': '/dev/vda', 'size_gb': '50'}]


Status

Authors

  • Gaudenz Steinlin (@gaudenz)
  • René Moser (@resmo)

Hint

If you notice any issues in this documentation, you can edit this document to improve it.