linuxfabrik.lfops.exoscale_instance¶
Manage an Exoscale compute instance
Synopsis¶
- Creates, changes or deletes an Exoscale compute instance, identified by name, using the Exoscale v2 API.
- On an existing instance, the module scales it to instance_type, grows its disk to disk_size, attaches the security_groups and attaches, detaches or re-addresses the private_networks. Scaling and growing the disk need a stopped instance, see force.
- template, ssh_keys and public_ip_assignment only take effect when the instance is created.
- Supports
--checkand--diff.
Available since LFOps 10.0.0.
Mandatory Parameters¶
api_key
- Exoscale API key.
- Type: String.
api_secret
- Exoscale API secret matching api_key.
- Type: String.
name
- Name of the instance. Must be unique in the zone.
- Type: String.
zone
- Exoscale zone, for example
ch-gva-2. - Type: String.
Optional Parameters¶
disk_size
- Size of the root disk in GiB, between 10 and 51200. Required to create the instance. On an existing instance, a larger value grows the disk. The disk cannot shrink, so a smaller value fails.
- Type: Number.
force
- Allows the module to stop a running instance to scale it or to grow its disk, and to start it again afterwards. Without it, the module fails instead of stopping the instance.
- Type: Bool.
- Default:
false
instance_type
- Instance type as
<family>.<size>, for examplestandard.medium. Required to create the instance. On an existing instance, a different type scales it. Exoscale only scales within the same family. - Type: String.
operation_timeout
- Seconds to wait for an asynchronous Exoscale operation to finish.
- Type: Number.
- Default:
600
private_networks
- Private networks to attach to or detach from the instance. Attached networks that are not listed here are left alone.
- Type: List.
- Default:
[] -
Subkeys:
-
fixed_ip:- IPv4 address the instance gets on a managed private network. If the instance currently has another one, it is changed.
- Type: String.
-
name:- Name of the private network. It has to exist, see
linuxfabrik.lfops.exoscale_private_network. - Type: String.
- Name of the private network. It has to exist, see
-
state:- Whether the instance should be attached to the network.
- Type: String. One of
absent,present. - Default:
present
-
public_ip_assignment
inet4gives the instance a public IPv4 address,duala public IPv4 and IPv6 address,nonenone at all. Only used when the instance is created.- Type: String. One of
dual,inet4,none. - Default:
inet4
security_groups
- Names of the security groups the instance is attached to. They have to exist. Security groups attached to the instance that are not listed here are left alone.
- Type: List.
- Default:
[]
ssh_keys
- Names of the SSH keys registered at Exoscale to deploy to the instance. Only used when the instance is created.
- Type: List.
- Default:
[]
state
presentcreates the instance if it is missing and leaves the power state of an existing instance alone.startedandstoppedalso start or stop the instance. An instance created withstoppednever boots.restartedreboots a running instance on every run and starts a stopped one.absentdeletes the instance.- Type: String. One of
absent,present,restarted,started,stopped. - Default:
present
template
- Name or ID of the template to create the instance from. Required to create the instance. A name is looked up among the templates with template_visibility. Use the ID for a private template whose name is not unique.
- Type: String.
template_visibility
- Visibility of the templates that template is looked up in.
privateare the templates registered in the own organization. - Type: String. One of
private,public. - Default:
public
Examples¶
- name: 'Create a private instance with a fixed address in a private network'
linuxfabrik.lfops.exoscale_instance:
api_key: '{{ exoscale_api_key }}'
api_secret: '{{ exoscale_api_secret }}'
zone: 'ch-gva-2'
name: 'web01'
instance_type: 'standard.small'
template: 'Rocky Linux 9 (Blue Onyx) 64-bit'
disk_size: 50
ssh_keys:
- 'linuxfabrik'
public_ip_assignment: 'none'
security_groups:
- 'default'
- 'web01'
private_networks:
- name: 'net-prod01'
fixed_ip: '192.0.2.10'
state: 'started'
delegate_to: 'localhost'
- name: 'Grow the disk, stopping the instance for it'
linuxfabrik.lfops.exoscale_instance:
api_key: '{{ exoscale_api_key }}'
api_secret: '{{ exoscale_api_secret }}'
zone: 'ch-gva-2'
name: 'web01'
disk_size: 100
force: true
state: 'started'
delegate_to: 'localhost'
Return Values¶
instance
- The instance as returned by the Exoscale API after all changes. Empty when
state=absent, or when it would be created in check mode. - Type: Dictionary.
- Returned: always.
Authors¶
- Linuxfabrik GmbH, Zurich, Switzerland (info (at) linuxfabrik (dot) ch)