server
Manages servers on the cloudscale.ch IaaS service
Collection: cloudscale_ch.cloud
Full Name: cloudscale_ch.cloud.server
Synopsis
Manages servers on the cloudscale.ch IaaS service
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| api_url | str | Cloudscale API URL; defaults from CLOUDSCALE_API_URL or https://api.cloudscale.ch/v1. | ||
| api_token | str | API bearer token; defaults from CLOUDSCALE_API_TOKEN. | ||
| api_timeout | int | Request timeout seconds; defaults from CLOUDSCALE_API_TIMEOUT or 45. | ||
| bulk_volume_size_gb | int | Size of the bulk storage volume in GB. No bulk storage volume if not set. | ||
| flavor | str | Flavor of the server. | ||
| force | bool | false | Allow to stop the running server for updating if necessary. | |
| image | str | Image used to create the server. | ||
| interfaces | list | List of network interface objects specifying the interfaces to be attached to the server. See U(https://www.cloudscale.ch/en/api/v1/#interfaces-attribute-specification) for more details. | ||
| name | str | Name of the Server. Either I(name) or I(uuid) are required. | ||
| password | str | Password for the server. | ||
| server_groups | list | List of UUID or names of server groups. | ||
| ssh_keys | list | List of SSH public keys. Use the full content of your .pub file here. | ||
| state | str | running | State of the server. | |
| tags | dict | Tags assosiated with the servers. Set this to C({}) to clear any tags. | ||
| use_ipv6 | bool | true | Enable IPv6 on the public network interface. | |
| use_private_network | bool | Attach a private network interface to the server. | ||
| use_public_network | bool | Attach a public network interface to the server. | ||
| user_data | str | Cloud-init configuration (cloud-config) data to use for the server. | ||
| uuid | str | UUID of the server. Either I(name) or I(uuid) are required. | ||
| volume_size_gb | int | 10 | Initial size of the root volume in GB. This parameter has no effect on existing servers. Use the volume module to change the size of the root volume. | |
| zone | str | Zone in which the server resides (e.g. C(lpg1) or C(rma1)). |
Example
yaml
# 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: true
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: []