cloudscale_ch.cloud.server module – Manages servers on the cloudscale.ch IaaS service
Note
This module is part of the cloudscale_ch.cloud collection (version 2.2.3).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install cloudscale_ch.cloud
.
To use it in a playbook, specify: cloudscale_ch.cloud.server
.
New in cloudscale_ch.cloud 1.0.0
Synopsis
Create, update, start, stop and delete servers on the cloudscale.ch IaaS service.
Parameters
Parameter |
Comments |
---|---|
Timeout in seconds for calls to the cloudscale.ch API. This can also be passed in the Default: |
|
cloudscale.ch API token. This can also be passed in the |
|
cloudscale.ch API URL. This can also be passed in the Default: |
|
Size of the bulk storage volume in GB. No bulk storage volume if not set. |
|
Flavor of the server. |
|
Allow to stop the running server for updating if necessary. Choices:
|
|
Image used to create the server. |
|
List of network interface objects specifying the interfaces to be attached to the server. See https://www.cloudscale.ch/en/api/v1/#interfaces-attribute-specification for more details. |
|
Attach a private network interface and configure a subnet and/or an IP address. |
|
The static IP address of the interface. Use ‘[]’ to avoid assigning an IP address via DHCP. |
|
UUID of the subnet from which an address will be assigned. |
|
Create a network interface on the network identified by UUID. Use ‘public’ instead of an UUID to attach a public network interface. Can be omitted if a subnet is provided under addresses. |
|
Name of the Server. Either name or uuid are required. |
|
Password for the server. |
|
List of UUID or names of server groups. |
|
List of SSH public keys. Use the full content of your .pub file here. |
|
State of the server. Choices:
|
|
Tags assosiated with the servers. Set this to |
|
Enable IPv6 on the public network interface. Choices:
|
|
Attach a private network interface to the server. Choices:
|
|
Attach a public network interface to the server. Choices:
|
|
Cloud-init configuration (cloud-config) data to use for the server. |
|
UUID of the server. Either name or uuid are required. |
|
Size of the root volume in GB. Default: |
|
Zone in which the server resides (e.g. |
Notes
Note
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.
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_ch.cloud.server:
name: my-shiny-cloudscale-server
image: debian-10
flavor: flex-4-4
ssh_keys:
- ssh-rsa XXXXXXXXXX...XXXX ansible@cloudscale
server_groups: shiny-group
zone: lpg1
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_ch.cloud.server:
name: my-other-shiny-server
image: ubuntu-16.04
flavor: flex-8-2
ssh_keys:
- ssh-rsa XXXXXXXXXX...XXXX ansible@cloudscale
server_groups: shiny-group
zone: lpg1
api_token: xxxxxx
# Force to update the flavor of a running server
- name: Start cloudscale.ch server
cloudscale_ch.cloud.server:
name: my-shiny-cloudscale-server
image: debian-10
flavor: flex-8-2
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_ch.cloud.server:
uuid: '{{ server1.uuid }}'
state: stopped
api_token: xxxxxx
# Delete my second server
- name: Delete my second server
cloudscale_ch.cloud.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_ch.cloud.server:
name: my-cloudscale-server-with-ssh-key
image: debian-10
flavor: flex-4-2
ssh_keys:
- ssh-rsa XXXXXXXXXX...XXXX ansible@cloudscale
api_token: xxxxxx
register: server
until: server is not failed
retries: 5
delay: 2
# Start a server with two network interfaces:
#
# A public interface with IPv4/IPv6
# A private interface on a specific private network with an IPv4 address
- name: Start a server with a public and private network interface
cloudscale_ch.cloud.server:
name: my-cloudscale-server-with-two-network-interfaces
image: debian-10
flavor: flex-4-2
ssh_keys:
- ssh-rsa XXXXXXXXXX...XXXX ansible@cloudscale
api_token: xxxxxx
interfaces:
- network: 'public'
- addresses:
- subnet: UUID_of_private_subnet
# Start a server with a specific IPv4 address from subnet range
- name: Start a server with a specific IPv4 address from subnet range
cloudscale_ch.cloud.server:
name: my-cloudscale-server-with-specific-address
image: debian-10
flavor: flex-4-2
ssh_keys:
- ssh-rsa XXXXXXXXXX...XXXX ansible@cloudscale
api_token: xxxxxx
interfaces:
- addresses:
- subnet: UUID_of_private_subnet
address: 'A.B.C.D'
# Start a server with two network interfaces:
#
# A public interface with IPv4/IPv6
# A private interface on a specific private network with no IPv4 address
- name: Start a server with a private network interface and no IP address
cloudscale_ch.cloud.server:
name: my-cloudscale-server-with-specific-address
image: debian-10
flavor: flex-4-2
ssh_keys:
- ssh-rsa XXXXXXXXXX...XXXX ansible@cloudscale
api_token: xxxxxx
interfaces:
- network: 'public'
- network: UUID_of_private_network
addresses: []
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
The flavor that has been used for this server Returned: success when not state == absent Sample: |
|
API URL to get details about this server Returned: success when not state == absent Sample: |
|
The image used for booting this server Returned: success when not state == absent Sample: |
|
List of network ports attached to the server Returned: success when not state == absent Sample: |
|
The display name of the server Returned: success Sample: |
|
List of server groups Returned: success when not state == absent Sample: |
|
A list of SSH host key fingerprints. Will be null until the host keys could be retrieved from the server. Returned: success when not state == absent Sample: |
|
A list of SSH host keys. Will be null until the host keys could be retrieved from the server. Returned: success when not state == absent Sample: |
|
The current status of the server Returned: success Sample: |
|
Tags assosiated with the server. Returned: success Sample: |
|
The unique identifier for this server Returned: success Sample: |
|
List of volumes attached to the server Returned: success when not state == absent Sample: |
|
The zone used for booting this server Returned: success when not state == absent Sample: |