Automation
Overview
Taking the basic concept of cloud-init to the next level by using methods like:
- CLI β¦ Command Line Interface
- API β¦ Application Programming Interface
- IaC β¦ Infrastructure as Code
Infrastructure as Code π
Infrastructure as Code (IaC) manages and provides computer data centers through machine-readable definition files rather than physical hardware configuration or interactive configuration tools.
- Specify your whole infrastructure as programming code
- Automated infrastructure management
- Quickly start, modify or delete your whole infrastructure
- Code is also documentation
- Terraform Plugin provided by Exoscale
The approach of immutable infrastructure is practiced in this concept by never updating and always replacing.
Example π
data "exoscale_compute_template" "ubuntu" {
zone = local.zone
name = "Linux Ubuntu 20.04 LTS 64-bit"
}
resource "exoscale_security_group" "web" {
name = "web"
}
resource "exoscale_compute_instance" βwebserver" {
zone = local.zone
name = "webserver"
type = "standard.medium"
template_id = data.exoscale_compute_template.ubuntu.id
disk_size = 10
security_group_ids = [
data.exoscale_security_group.default.id,
exoscale_security_group.web.id,
]
user_data = <<EOF
#cloud-config
package_upgrade: true
packages:
- nginx
write_files:
- owner: www-data:www-data
path: /var/www/html/index.html
content: |
Hello world!
runcmd:
- systemctl restart nginx
EOF
}
Application Programming Interface π
Exoscale Public API
https://openapi-v2.exoscale.com
- Everything on Exoscale can be controlled via the API
- Full potential for automation
- Implementable in every programming language
- Specifically limit access using IAM
Example π
import requests
from exoscale_auth import ExoscaleV2Auth
import secret
auth = ExoscaleV2Auth(secret.api, secret.key)
response = requests.get("https://api-de-fra-1.exoscale.com/v2/instance", auth=auth)
print(response.text)
Command Line Interface π
Exoscale CLI β exo
https://community.exoscale.com/documentation/tools/exoscale-command-line-interface/
exo is Exoscaleβs official command line interface to access all platform services. It allows you to manage your infrastructure from a user-friendly command line tool with the benefits of being scriptable.
> exo compute instance create my-new-vm
β Creating instance "my-new-vm"... 16s
βΌβββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββΌ
β COMPUTE INSTANCE β β
βΌβββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββΌ
β ID β xxx-xxx-xxx-xxx β
β Name β my-new-vm β
β Creation Date β 2022-11-30 14:39:19 +0000 UTC β
β Instance Type β standard.medium β
β Template β Linux Ubuntu 22.04 LTS 64-bit β
β Zone β ch-gva-2 β
β Anti-Affinity Groups β n/a β
β Security Groups β default β
β Private Networks β n/a β
β Elastic IPs β n/a β
β IP Address β 159.100.242.231 β
β IPv6 Address β - β
β SSH Key β - β
β Disk Size β 50 GiB β
β State β running β
β Labels β n/a β
βΌβββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββΌ
> exo compute instance list
βΌββββββββββββββββββΌββββββββββββΌβββββββββββΌββββββββββββββββββΌββββββββββββββββββΌββββββββββΌ
β ID β NAME β ZONE β TYPE β IP ADDRESS β STATE β
βΌββββββββββββββββββΌββββββββββββΌβββββββββββΌββββββββββββββββββΌββββββββββββββββββΌββββββββββΌ
β xxx-xxx-xxx-xxx β my-new-vm β ch-gva-2 β standard.medium β 159.100.242.231 β running β
βΌββββββββββββββββββΌββββββββββββΌβββββββββββΌββββββββββββββββββΌββββββββββββββββββΌββββββββββΌ
> exo compute instance delete my-new-vm
[+] Are you sure you want to delete instance "my-new-vm"? [yN]: y
β Deleting instance "my-new-vm"... 12s