ngine_io.exoscale_compute
Ansible Role: Exoscale Compute
:warning: DEPRECATED: Exoscale will stop supporting the Cloudstack API after May 1, 2024. See Announcement.
This role helps you manage compute resources on Exoscale Cloud.
Role Variables
# API credentials
exoscale__api_key:
exoscale__api_secret:
exoscale__api_endpoint: https://api.exoscale.ch/v1
# Zone to be used
exoscale__zone: ch-dk-2
# Security groups configuration
exoscale__security_groups:
- name: default
rules:
- protocol: tcp
type: ingress
cidr: 0.0.0.0/0
start_port: 22
end_port: 22
# Affinity groups
exoscale__affinity_groups:
- name: my cluster group
# Network configurations
exoscale__networks:
- name: private-network
start_ip: 10.23.12.100
end_ip: 10.23.12.150
netmask: 255.255.255.0
# SSH Keys configuration
exoscale__ssh_key_default_name: "{{ lookup('env', 'USER') }}@{{ lookup('pipe', 'hostname') }}"
exoscale__ssh_key_default_pubkey: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
exoscale__ssh_keys:
- name: "{{ exoscale__ssh_key_default_name }}"
pubkey: "{{ exoscale__ssh_key_default_pubkey }}"
# Server instance configuration
exoscale__server_name: "{{ inventory_hostname_short }}"
exoscale__server_template: "Rocky Linux 8 (Green Obsidian) 64-bit"
exoscale__server_service_offering: Small
exoscale__server_root_disk_size: 10
exoscale__server_networks: "{{ omit }}"
exoscale__server_ip_to_networks: "{{ omit }}"
exoscale__server_security_groups:
- default
exoscale__server_affinity_groups: []
exoscale__server_ssh_key: "{{ exoscale__ssh_key_default_name }}"
exoscale__server_user_data: |
#cloud-config
manage_etc_hosts: false
fqdn: "{{ inventory_hostname }}"
exoscale__server_state: present
exoscale__server_allow_reboot: false
Dependencies
Check requirements.txt
for required Python libraries.
Examples
Playbook
Here is an example of a typical playbook.
---
- name: Provision Cloud servers
hosts: all
serial: 5
gather_facts: false
roles:
- role: ngine_io.exoscale_compute
delegate_to: localhost
post_tasks:
- name: Wait for SSH access
delegate_to: localhost
wait_for:
host: "{{ ansible_host }}"
port: 22
timeout: 60
- name: Wait for cloud-init to finish
wait_for:
host: "{{ ansible_host }}"
path: /var/lib/cloud/instance/boot-finished
timeout: 600
Common Configurations
You can set typical configurations in a file (e.g. group_vars/all.yml
) for adding security groups and rules, affinity groups, and networks:
# file: group_vars/all.yml
# API credentials
exoscale__api_key: EXO...
exoscale__api_secret: ...$
# Zone: default ch-dk-2
exoscale__zone: ch-gva-2
# Template configuration
ansible_user: rockylinux
exoscale__server_template: "Rocky Linux 8 (Green Obsidian) 64-bit 2021-08-25-13bb54"
# Enable IPv6
exoscale__server_ipv6_enabled: true
# Security groups
exoscale__security_groups:
- name: proxy
rules:
- protocol: tcp
type: ingress
cidr: 0.0.0.0/0
port: 443
- protocol: tcp
type: ingress
cidr: 0.0.0.0/0
port: 80
- protocol: tcp
type: ingress
cidr: 1.2.3.4/32
start_port: 8000
end_port: 8999
- name: mqtt
rules:
- port: 1883
- port: 8883
# Affinity groups
exoscale__affinity_groups:
- name: cassandra
- name: proxy
# Private networks
exoscale__networks:
- name: my private net
start_ip: 10.23.12.100
end_ip: 10.23.12.150
netmask: 255.255.255.0
Instance Configurations via Group / Host Vars
If you have an inventory like this:
[proxy]
proxy1.example.com
proxy2.example.com
[cassandra]
cassandra1.example.com
cassandra2.example.com
cassandra3.example.com
Set different offerings and security groups for proxies:
#file: group_vars/proxy.yml
# Medium offering
exoscale__server_service_offering: Medium
# Assign security groups
exoscale__server_security_groups:
- default
- proxy
# Attach a private network
exoscale__server_networks:
- my private net
Set affinity groups and hardware for Cassandra instances:
#file: group_vars/cassandra.yml
# Assign affinity group
exoscale__server_affinity_groups: cassandra
# Use specific hardware
exoscale__server_service_offering: CPU-extra-large
# Attach a private network
exoscale__server_networks:
- my private net
:information_source: HINT: To see all offerings, use:
cs listServiceOfferings | jq --raw-output '.serviceoffering[].name'
. Check https://github.com/exoscale/cs/ for more information on the library used as CLI.
License
MIT
Author Information
René Moser (@resmo)