diff --git a/system_os/vultr/Makefile b/system_os/vultr/Makefile new file mode 100644 index 0000000..920d11f --- /dev/null +++ b/system_os/vultr/Makefile @@ -0,0 +1,9 @@ + +init: + packer init -upgrade . + +release: + packer build -only=release.vultr.talos . + +develop: + packer build -only=develop.vultr.talos . diff --git a/system_os/vultr/variables.pkr.hcl b/system_os/vultr/variables.pkr.hcl new file mode 100644 index 0000000..8eac3cd --- /dev/null +++ b/system_os/vultr/variables.pkr.hcl @@ -0,0 +1,19 @@ + +variable "vultr_api_key" { + type = string + default = "" +} + +variable "vultr_region" { + type = string + default = "" +} + +variable "talos_version" { + type = string + default = "v0.13.0" +} + +locals { + image = "https://github.com/talos-systems/talos/releases/download/${var.talos_version}/vultr-amd64.raw.xz" +} diff --git a/system_os/vultr/vultr.pkr.hcl b/system_os/vultr/vultr.pkr.hcl new file mode 100644 index 0000000..5c504b0 --- /dev/null +++ b/system_os/vultr/vultr.pkr.hcl @@ -0,0 +1,53 @@ + +packer { + required_plugins { + vultr = { + version = ">= 2.4.0" + source = "github.com/vultr/vultr" + } + } +} + +source "vultr" "talos" { + api_key = var.vultr_api_key + region_id = var.vultr_region + plan_id = "vc2-1c-1gb" + + # Arch Linux + iso_id = "20eceb4f-7b28-466e-aaf4-cff60385c30d" + state_timeout = "10m" + ssh_username = "root" + ssh_password = "packer" + + instance_label = "talos" + snapshot_description = "talos system disk" +} + +# FIXME +build { + name = "release" + sources = ["source.vultr.talos"] + + provisioner "shell" { + inline = [ + "apt-get install -y wget", + "wget -O /tmp/talos.raw.xz ${local.image}", + "xz -d -c /tmp/talos.raw.xz | dd of=/dev/vda", + ] + } +} + +build { + name = "develop" + sources = ["source.vultr.talos"] + + provisioner "file" { + source = "../../../talos-pr/_out/vultr-amd64.raw.xz" + destination = "/tmp/talos.raw.xz" + } + provisioner "shell" { + inline = [ + "xz -d -c /tmp/talos.raw.xz | dd of=/dev/vda", + ] + } +} diff --git a/vultr/auth.tf b/vultr/auth.tf new file mode 100644 index 0000000..99c96b8 --- /dev/null +++ b/vultr/auth.tf @@ -0,0 +1,6 @@ + +provider "vultr" { + api_key = var.vultr_api_key + rate_limit = 700 + retry_limit = 3 +} diff --git a/vultr/main.tf b/vultr/main.tf new file mode 100644 index 0000000..f70135d --- /dev/null +++ b/vultr/main.tf @@ -0,0 +1,17 @@ + +resource "vultr_instance" "controlplane" { + plan = "vc2-1c-1gb" + region = "ams" + snapshot_id = "0d6f3e7b-62e6-429b-ac53-53108843ee21" + label = "talos" + tag = "controlplane" + hostname = "master-1" + + enable_ipv6 = true + private_network_ids = ["329f9a26-d475-41f0-8e1f-b8cf11814848"] + user_data = file("talos.yaml") + + backups = "disabled" + ddos_protection = false + activation_email = false +} diff --git a/vultr/variables.tf b/vultr/variables.tf new file mode 100644 index 0000000..91d51ac --- /dev/null +++ b/vultr/variables.tf @@ -0,0 +1,5 @@ + +variable "vultr_api_key" { + type = string + sensitive = true +} diff --git a/vultr/versions.tf b/vultr/versions.tf new file mode 100644 index 0000000..dde4cac --- /dev/null +++ b/vultr/versions.tf @@ -0,0 +1,8 @@ +terraform { + required_providers { + vultr = { + source = "vultr/vultr" + version = "2.4.1" + } + } +}