mirror of
https://github.com/optim-enterprises-bv/terraform-talos.git
synced 2025-10-30 01:52:18 +00:00
Use packer.io to upload base os-image
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -9,6 +9,9 @@
|
||||
*.tfstate
|
||||
*.tfstate.*
|
||||
|
||||
# packer files
|
||||
.auto.pkrvars.hcl
|
||||
|
||||
# Crash log files
|
||||
crash.log
|
||||
|
||||
|
||||
@@ -3,8 +3,10 @@ data "hcloud_image" "talos" {
|
||||
with_selector = "type=infra"
|
||||
}
|
||||
|
||||
data "hcloud_ssh_key" "infra" {
|
||||
with_selector = "type=infra"
|
||||
resource "hcloud_ssh_key" "infra" {
|
||||
name = "infra"
|
||||
public_key = file("~/.ssh/terraform.pub")
|
||||
labels = merge(var.tags, { type = "infra" })
|
||||
}
|
||||
|
||||
# resource "talos_cluster_config" "talos_config" {
|
||||
|
||||
@@ -5,7 +5,7 @@ resource "hcloud_server" "controlplane" {
|
||||
name = "master-${count.index + 1}"
|
||||
image = data.hcloud_image.talos.id
|
||||
server_type = lookup(var.controlplane, "type", "cpx11")
|
||||
ssh_keys = [data.hcloud_ssh_key.infra.id]
|
||||
ssh_keys = [hcloud_ssh_key.infra.id]
|
||||
keep_disk = true
|
||||
labels = merge(var.tags, { type = "infra", label = "master" })
|
||||
|
||||
|
||||
47
system_os/hetzner/hetzner.pkr.hcl
Normal file
47
system_os/hetzner/hetzner.pkr.hcl
Normal file
@@ -0,0 +1,47 @@
|
||||
|
||||
packer {
|
||||
required_plugins {
|
||||
docker = {
|
||||
version = ">= 1.0.0"
|
||||
source = "github.com/hashicorp/hcloud"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
variable "hcloud_token" {
|
||||
type = string
|
||||
default = "${env("HCLOUD_TOKEN")}"
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
variable "talos_version" {
|
||||
type = string
|
||||
default = "v0.11.0"
|
||||
}
|
||||
|
||||
source "hcloud" "talos" {
|
||||
token = var.hcloud_token
|
||||
rescue = "linux64"
|
||||
image = "debian-10"
|
||||
location = "hel1"
|
||||
server_type = "cx11"
|
||||
ssh_username = "root"
|
||||
|
||||
snapshot_name = "talos system disk"
|
||||
snapshot_labels = {
|
||||
type = "infra",
|
||||
os = "talos",
|
||||
version = "${var.talos_version}",
|
||||
}
|
||||
}
|
||||
|
||||
build {
|
||||
sources = ["source.hcloud.talos"]
|
||||
provisioner "shell" {
|
||||
inline = [
|
||||
"apt-get install -y wget",
|
||||
"wget -O /tmp/openstack.tar.gz https://github.com/talos-systems/talos/releases/download/${var.talos_version}/openstack-amd64.tar.gz",
|
||||
"cd /tmp && tar xzf /tmp/openstack.tar.gz && dd if=/tmp/disk.raw of=/dev/sda && sync",
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user