cloudscale_server - Manages servers on the cloudscale.ch IaaS service

New in version 2.3.

Synopsis

  • Create, start, stop and delete servers on the cloudscale.ch IaaS service.
  • 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.
  • An 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.

Options

parameter required default choices comments
anti_affinity_with
no
UUID of another server to create an anti-affinity group with
api_token
no
cloudscale.ch API token.
This can also be passed in the CLOUDSCALE_API_TOKEN environment variable.
bulk_volume_size_gb
no null (no bulk storage volume)
Size of the bulk storage volume in GB
flavor
no
Flavor of the server
image
no
Image used to create the server
name
no
Name of the Server
Either name or uuid are required. These options are mutually exclusive.
ssh_keys
no
List of SSH public keys
Use the full content of your .pub file here.
state
no running
  • running
  • stopped
  • absent
State of the server
use_ipv6
no True
Enable IPv6 on the public network interface
use_private_network
no
Attach a private network interface to the server
use_public_network
no True
Attach a public network interface to the server
user_data
no
Cloud-init configuration (cloud-config) data to use for the server.
uuid
no
UUID of the server
Either name or uuid are required. These options are mutually exclusive.
volume_size_gb
no 10
Size of the root volume in GB

Examples

# Start a server (if it does not exist) and register the server details
- 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
    use_private_network: True
    bulk_volume_size_gb: 100
    api_token: xxxxxx
  register: server1

# Start another server in anti-affinity to the first one
- 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
    anti_affinity_with: '{{ server1.uuid }}'
    api_token: xxxxxx

# 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
  retries: 60
  delay: 2

Return Values

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

name description returned type sample
anti_affinity_with
List of servers in the same anti-affinity group
success when not state == absent string []
flavor
The flavor that has been used for this server
success when not state == absent string flex-8
href
API URL to get details about this server
success when not state == absent string https://api.cloudscale.ch/v1/servers/cfde831a-4e87-4a75-960f-89b0148aa2cc
image
The image used for booting this server
success when not state == absent string debian-8
interfaces
List of network ports attached to the server
success when not state == absent list [{'type': 'public', 'addresses': ['...']}]
name
The display name of the server
success string its-a-me-mario.cloudscale.ch
ssh_fingerprints
A list of SSH host key fingerprints. Will be null until the host keys could be retrieved from the server.
success when not state == absent list ['ecdsa-sha2-nistp256 SHA256:XXXX', '...']
ssh_host_keys
A list of SSH host keys. Will be null until the host keys could be retrieved from the server.
success when not state == absent list ['ecdsa-sha2-nistp256 XXXXX', '...']
state
The current status of the server
success string running
uuid
The unique identifier for this server
success string cfde831a-4e87-4a75-960f-89b0148aa2cc
volumes
List of volumes attached to the server
success when not state == absent list [{'device': '/dev/vda', 'size_gb': '50', 'type': 'ssd'}]

Notes

Note

  • Instead of the api_token parameter the CLOUDSCALE_API_TOKEN environment variable can be used.
  • To create a new server at least the name, ssh_key, image and flavor options are required.
  • If more than one server with the name given by the name option exists, execution is aborted.
  • Once a server is created all parameters except state are read-only. You can’t change the name, flavor or any other property. This is a limitation of the cloudscale.ch API. The module will silently ignore differences between the configured parameters and the running server if a server with the correct name or UUID exists. Only state changes will be applied.

Status

This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.

For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Testing Ansible and Developing Modules.

© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.4/cloudscale_server_module.html