Note
This plugin is part of the cloudscale_ch.cloud collection (version 2.2.0).
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 version 1.0.0: of cloudscale_ch.cloud
Parameter | Choices/Defaults | Comments | ||
---|---|---|---|---|
api_timeout integer | Default: 45 | Timeout in seconds for calls to the cloudscale.ch API. This can also be passed in the CLOUDSCALE_API_TIMEOUT environment variable. | ||
api_token string / required | cloudscale.ch API token. This can also be passed in the CLOUDSCALE_API_TOKEN environment variable. | |||
api_url string added in 1.3.0 of cloudscale_ch.cloud | Default: "https://api.cloudscale.ch/v1" | cloudscale.ch API URL. This can also be passed in the CLOUDSCALE_API_URL 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 |
| Allow to stop the running server for updating if necessary. | ||
image string | Image used to create the server. | |||
interfaces list / elements=dictionary added in 1.4.0 of cloudscale_ch.cloud | 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. | |||
addresses list / elements=dictionary | Attach a private network interface and configure a subnet and/or an IP address. | |||
address string | The static IP address of the interface. Use '[]' to avoid assigning an IP address via DHCP. | |||
subnet string | UUID of the subnet from which an address will be assigned. | |||
network string | 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 string | Name of the Server. Either name or uuid are required. | |||
password string | Password for the server. | |||
server_groups list / elements=string | List of UUID or names of server groups. | |||
ssh_keys list / elements=string | List of SSH public keys. Use the full content of your .pub file here. | |||
state string |
| State of the server. | ||
tags dictionary | Tags assosiated with the servers. Set this to {} to clear any tags. | |||
use_ipv6 boolean |
| Enable IPv6 on the public network interface. | ||
use_private_network boolean |
| Attach a private network interface to the server. | ||
use_public_network boolean |
| 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. | ||
zone string | Zone in which the server resides (e.g. lgp1 or rma1 ). |
Note
# 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 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 ssh_keys: ssh-rsa XXXXXXXXXXX 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 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 ssh_keys: ssh-rsa XXXXXXXXXXX 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 ssh_keys: ssh-rsa XXXXXXXXXXX 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 ssh_keys: ssh-rsa XXXXXXXXXXX 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 ssh_keys: ssh-rsa XXXXXXXXXXX ansible@cloudscale api_token: xxxxxx interfaces: - network: 'public' - network: UUID_of_private_network addresses: []
Common return values are documented here, the following are the fields unique to this module:
Key | Returned | Description |
---|---|---|
flavor dictionary | success when not state == absent | The flavor that has been used for this server Sample: {'memory_gb': 4, 'name': 'Flex-4', 'slug': 'flex-4', 'vcpu_count': 2} |
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 dictionary | success when not state == absent | The image used for booting this server Sample: {'default_username': 'ubuntu', 'name': 'Ubuntu 18.04 LTS', 'operating_system': 'Ubuntu', 'slug': 'ubuntu-18.04'} |
interfaces list / elements=string | success when not state == absent | List of network ports attached to the server Sample: [{'addresses': ['...'], 'type': 'public'}] |
name string | success | The display name of the server Sample: its-a-me-mario.cloudscale.ch |
server_groups list / elements=string | success when not state == absent | List of server groups Sample: [{'href': 'https://api.cloudscale.ch/v1/server-groups/...', 'name': 'db-group', 'uuid': '...'}] |
ssh_fingerprints list / elements=string | 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 / elements=string | 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 | success | Tags assosiated with the server. Sample: {'project': 'my project'} |
uuid string | success | The unique identifier for this server Sample: cfde831a-4e87-4a75-960f-89b0148aa2cc |
volumes list / elements=string | success when not state == absent | List of volumes attached to the server Sample: [{'device': '/dev/vda', 'size_gb': '50', 'type': 'ssd'}] |
zone dictionary | success when not state == absent | The zone used for booting this server Sample: {'slug': 'lpg1'} |
© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/cloudscale_ch/cloud/server_module.html