Ansible Role infomaniak_vm
This role creates and manages instances (virtual machines) on Infomaniak. It also allows creating other compontents for the instance, such as networks and firewall rules.
Mandatory Requirements
Install the openstack command line tool.
Import your public SSH-key into Infomaniak (here). Ideally, set the key name to your local username (replace
.
withinfomaniak_vm__key_name
.
Mandatory Role Variables
Variable |
Description |
---|---|
|
The flavor for the instance. This defines the amount of CPU cores, RAM and disk space. The possible options can be obtained using |
|
The image to use for this instance. The possible options can be obtained using |
|
The password for the OpenStack API. Normally this is the same as your admin user login. |
|
The project ID for the OpenStack API. Can be obtained by running |
|
The username for the OpenStack API. Normally this is the same as your admin user login. |
Example:
# mandatory
infomaniak_vm__flavor: 'a1-ram2-disk50-perf1'
infomaniak_vm__image: 'Rocky 8 Generic Cloud'
infomaniak_vm__api_password: 'linuxfabrik'
infomaniak_vm__api_project_id: 'oitexaeTeivaoRo7einuighRiegh4iexah'
infomaniak_vm__api_username: 'PCU-123456'
Optional Role Variables
Variable |
Description |
Default Value |
---|---|---|
|
The name of the deposited SSH-key. Defaults to using the local username of the Ansible control node, but replaces all |
|
|
The name of the instance. By default, it uses the Ansible inventory name. |
|
|
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. Subkeys: |
unset |
|
A list of dictionaries containing rules for the security group (basically OpenStack firewall rules). Subkeys:
|
unset |
|
The size of the bootable root-volume in GB. This should only be used if the |
unset |
|
The type of the bootable root-volume. This only has an effect if |
|
|
The state of the instance. Note that setting this to absent also removes all other created compontents, except the networks, which are never deleted since other VMs could still be using them. Possible options: |
|
Example:
# optional
infomaniak_vm__key_name: '{{ lookup("env", "USER") | regex_replace(".", " ") }}'
infomaniak_vm__name: '{{ inventory_hostname }}'
infomaniak_vm__networks:
- name: 'ext-net1'
- name: 'test-network'
cidr: '10.1.3.0/24'
fixed_ip: '10.1.3.1'
infomaniak_vm__security_group_rules:
- direction: 'ingress'
protocol: 'tcp'
port_range_min: 22
port_range_max: 22
infomaniak_vm__separate_boot_volume_size: 20
infomaniak_vm__separate_boot_volume_type: 'perf2'
infomaniak_vm__state: 'present'
Troubleshooting
BadRequestException: 400: Client Error for url: https://api....infomaniak.cloud/compute/v2.1/..., Invalid key_name provided.
: Provide the correct „Key Pair Name“ of your SSH Key. It should match your local Linux username.