Ansible Role linuxfabrik.lfops.exoscale_vm¶
This role creates and manages instances (virtual machines) on Exoscale. It also allows creating other compontents for the instance, such as networks and firewall rules.
Available since LFOps 2.0.0.
Known Limitations¶
- Resizing / scaling of instances is currently not supported
Requirements¶
Manual steps:
- Install the exo command line tool and configure your Exoscale account using
exo configon the Ansible control node. - Install the
python3-cslibrary on the Ansible control node. - Import your public SSH-key into Exoscale (here). Ideally, set the key name to your local username, then you can use the default value for
exoscale_vm__ssh_key.
Tags¶
exoscale_vm
- Creates and manages the instance.
- Triggers: none.
exoscale_vm:firewalls
- Manage the provider firewalls of the host.
- Triggers: none.
exoscale_vm:networks
- Manage the provider private networks.
- Triggers: none.
Mandatory Role Variables¶
exoscale_vm__account
- The name of the Exoscale account name as configured during
exo config. Can be found in~/.config/exoscale/exoscale.tomlafterwards. - Type: String.
exoscale_vm__api_key
- Set the Exoscale API key. API keys can be managed here. We recommend creating a unrestricted key, because else some operations fail.
- Type: String.
exoscale_vm__api_secret
- Set the Exoscale secret corresponding to the API key.
- Type: String.
exoscale_vm__service_offering
- The Exoscale service offering. This defines the amount of CPU cores, RAM and disk space. The possible options can be obtained using
exo compute instance-type list --verbose. Note that these changes will only be applied to stopped instances. - Type: String.
exoscale_vm__template
- The Exoscale template for the instance. The possible options can be obtained using
exo compute instance-template list. Note that you have to use the ID instead of the name when referencing custom templates. - Type: String.
exoscale_vm__zone
- The Exoscale zone the instance should be in. The possible options can be obtained using
exo zone list. - Type: String.
Example:
# mandatory
exoscale_vm__account: 'example'
exoscale_vm__api_key: 'EXOtn4Rg5ooosUALc1uNTqVTyTd'
exoscale_vm__api_secret: '4Is7jmDfzCONfJtEfxqX1VePSK9p7iZLafJy9ItC'
exoscale_vm__service_offering: 'standard.tiny'
exoscale_vm__template: 'Rocky Linux 8 (Green Obsidian) 64-bit'
exoscale_vm__zone: 'ch-dk-2'
Optional Role Variables¶
exoscale_vm__disk_size
- The disk size in GBs. Must be greater than 10. Note that adjusting the disk size is not currently supported.
- Type: Number.
- Default:
10
exoscale_vm__name
- The name of the instance. By default, the Ansible inventory name prefixed with
eis used, as it has to start with a letter. - Type: String.
- Default:
'e{{ inventory_hostname }}'
exoscale_vm__private_instance
- Choose if the instance should be "private" without a public IP, or not.
- Type: Bool.
- Default:
true
exoscale_vm__private_networks
- A list of dictionaries defining which networks should be attached to this instance. It also allows the creation of new internal networks, or setting a fixed IP for the instance.
- Type: List of dictionaries.
-
Default:
[] -
Subkeys:
-
name:- Mandatory. The name of an existing network, or the network which should be created.
- Type: String.
-
cidr:- Optional. If this is given, a new network with this cidr is created.
- Type: String.
-
fixed_ip:- Optional. The fixed IP of this instance. This can be used for attach to an existing network, or when creating a new one.
- Type: String.
-
exoscale_vm__security_group_rules
- A list of dictionaries containing rules for the security group (basically Exoscale firewall rules).
- Type: List of dictionaries.
-
Default: unset
-
Subkeys:
-
cidr:- Optional. CIDR to be used for security group rule.
- Type: String.
-
protocol:- Mandatory. To which IP protocol the rule is applied. Possible options:
tcp,udp,icmp. - Type: String.
- Mandatory. To which IP protocol the rule is applied. Possible options:
-
start_port:- Mandatory. The starting port.
- Type: Number.
-
end_port:- Mandatory. The ending port.
- Type: Number.
-
state:- Optional. State of the rule. Either
absentorpresent. - Type: String.
- Default:
'present'
- Optional. State of the rule. Either
-
type:- Mandatory. For which direction the rule should apply. Possible options:
ingress,egress. - Type: String.
- Mandatory. For which direction the rule should apply. Possible options:
-
exoscale_vm__ssh_key
- The name of the SSH-key deposited in Exoscale here. Defaults to using the local username of the Ansible control node.
- Type: String.
- Default:
'{{ lookup("env", "USER") }}'
exoscale_vm__state
- The state of the instance. Possible options:
deployed,started,stopped,restarted,restored,destroyed,expunged,present,absent. - Type: String.
- Default:
'started'
exoscale_vm__template_visibility
- Visibility of the Exoscale template for the instance. Usually
'private'for custom templates. - Type: String.
- Default:
'public'
Example:
# optional
exoscale_vm__disk_size: 10
exoscale_vm__name: '{{ inventory_hostname }}'
exoscale_vm__private_instance: false
exoscale_vm__private_networks:
- name: 'net-prod01'
cidr: '192.0.2.0/24'
fixed_ip: '192.0.2.1'
exoscale_vm__security_group_rules:
- type: 'ingress'
protocol: 'tcp'
start_port: 22
end_port: 22
exoscale_vm__ssh_key: '{{ lookup("env", "USER") }}'
exoscale_vm__state: 'started'
exoscale_vm__template_visibility: 'private'