diff --git a/packer/build.pkr.hcl b/packer/build.pkr.hcl index e5fc4f0..2077c66 100644 --- a/packer/build.pkr.hcl +++ b/packer/build.pkr.hcl @@ -6,8 +6,8 @@ build { ] provisioner "file" { - direction = "upload" - source = "./rootfs" + direction = "upload" + source = "./rootfs" destination = "/tmp" } diff --git a/packer/sources.pkr.hcl b/packer/sources.pkr.hcl index 53041d6..5d9a282 100644 --- a/packer/sources.pkr.hcl +++ b/packer/sources.pkr.hcl @@ -1,10 +1,10 @@ source "hcloud" "main" { token = var.hcloud_api_token - image = "ubuntu-20.04" + image = "ubuntu-20.04" server_name = "wireguard-{{timestamp}}" server_type = "cx11" - location = "fsn1" + location = "fsn1" snapshot_name = "wireguard-{{timestamp}}" snapshot_labels = { @@ -13,19 +13,19 @@ source "hcloud" "main" { user_data_file = "./hetzner/seed/user-data" - ssh_port = "22" - ssh_username = "root" - ssh_timeout = "10m" + ssh_port = "22" + ssh_username = "root" + ssh_timeout = "10m" ssh_clear_authorized_keys = true } source "digitalocean" "main" { api_token = var.digitalocean_api_token - image = "ubuntu-20-04-x64" + image = "ubuntu-20-04-x64" droplet_name = "wireguard-{{timestamp}}" - size = "s-1vcpu-1gb" - region = "fra1" + size = "s-1vcpu-1gb" + region = "fra1" snapshot_name = "wireguard-{{timestamp}}" tags = [ @@ -34,40 +34,40 @@ source "digitalocean" "main" { user_data_file = "./digitalocean/seed/user-data" - ssh_port = "22" - ssh_username = "root" - ssh_timeout = "10m" + ssh_port = "22" + ssh_username = "root" + ssh_timeout = "10m" ssh_clear_authorized_keys = true } source "qemu" "main" { - iso_url = "https://cloud-images.ubuntu.com/daily/server/focal/current/focal-server-cloudimg-amd64.img" + iso_url = "https://cloud-images.ubuntu.com/daily/server/focal/current/focal-server-cloudimg-amd64.img" iso_checksum = "file:https://cloud-images.ubuntu.com/daily/server/focal/current/SHA256SUMS" - disk_image = true + disk_image = true - vm_name = "wireguard.qcow2" - http_directory = "./qemu/http/" + vm_name = "wireguard.qcow2" + http_directory = "./qemu/http/" output_directory = "./dist/qemu/" accelerator = "kvm" - cpus = 1 - memory = 512 - headless = true + cpus = 1 + memory = 512 + headless = true qemuargs = [ ["-smbios", "type=1,serial=ds=nocloud-net;s=http://{{.HTTPIP}}:{{.HTTPPort}}/seed/"] ] net_device = "virtio-net" - format = "qcow2" - disk_size = "4G" - disk_interface = "virtio" + format = "qcow2" + disk_size = "4G" + disk_interface = "virtio" disk_compression = false - ssh_port = "22" - ssh_username = "root" - ssh_password = "toor" - ssh_timeout = "10m" + ssh_port = "22" + ssh_username = "root" + ssh_password = "toor" + ssh_timeout = "10m" ssh_clear_authorized_keys = true shutdown_command = "shutdown -P now" diff --git a/packer/variables.pkr.hcl b/packer/variables.pkr.hcl index f9c69e3..1a5594f 100644 --- a/packer/variables.pkr.hcl +++ b/packer/variables.pkr.hcl @@ -1,11 +1,11 @@ variable "hcloud_api_token" { - type = string + type = string description = "Hetzner Cloud API token" - default = "" + default = "" } variable "digitalocean_api_token" { - type = string + type = string description = "DigitalOcean API token" - default = "" + default = "" } diff --git a/terraform/main.tf b/terraform/main.tf index 4570f9c..e5e8e76 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -4,19 +4,19 @@ provider "hcloud" { data "hcloud_image" "wg_image" { with_selector = "service=wireguard" - most_recent = true + most_recent = true } resource "hcloud_ssh_key" "wg_server_ssh_key" { public_key = var.wg_server_ssh_publickey - name = var.wg_server_ssh_publickey_name + name = var.wg_server_ssh_publickey_name } resource "hcloud_server" "wg_server" { - image = data.hcloud_image.wg_image.id - name = var.wg_server_name + image = data.hcloud_image.wg_image.id + name = var.wg_server_name server_type = var.wg_server_type - location = var.wg_server_location + location = var.wg_server_location labels = { service = "wireguard" } @@ -24,7 +24,7 @@ resource "hcloud_server" "wg_server" { hcloud_ssh_key.wg_server_ssh_key.id ] user_data = templatefile("${path.module}/templates/user-data.tpl", { - wg_server_own_privatekey = var.wg_server_own_privatekey + wg_server_own_privatekey = var.wg_server_own_privatekey wg_server_peer_publickeys = var.wg_server_peer_publickeys }) } diff --git a/terraform/outputs.tf b/terraform/outputs.tf index 7a9da79..6b187cb 100644 --- a/terraform/outputs.tf +++ b/terraform/outputs.tf @@ -1,9 +1,9 @@ output "wg_server_ipv4_address" { - value = hcloud_server.wg_server.ipv4_address + value = hcloud_server.wg_server.ipv4_address description = "IPv4 address" } output "wg_server_ipv6_address" { - value = hcloud_server.wg_server.ipv6_address + value = hcloud_server.wg_server.ipv6_address description = "IPv6 address" } diff --git a/terraform/terraform.tfvars.sample b/terraform/terraform.tfvars.sample index 6eb23fc..b07ae3e 100644 --- a/terraform/terraform.tfvars.sample +++ b/terraform/terraform.tfvars.sample @@ -1,11 +1,11 @@ hcloud_api_token = "" -wg_server_name = "" -wg_server_type = "" +wg_server_name = "" +wg_server_type = "" wg_server_location = "" -wg_server_ssh_publickey = "" +wg_server_ssh_publickey = "" wg_server_ssh_publickey_name = "" -wg_server_own_privatekey = "" +wg_server_own_privatekey = "" wg_server_peer_publickeys = [] diff --git a/terraform/variables.tf b/terraform/variables.tf index aa185e5..cd66332 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -1,43 +1,43 @@ variable "hcloud_api_token" { - type = string + type = string description = "Hetzner Cloud API token" - default = "" + default = "" } variable "wg_server_name" { - type = string + type = string description = "Server name" - default = "wireguard" + default = "wireguard" } variable "wg_server_type" { - type = string + type = string description = "Server type" - default = "cx11" + default = "cx11" } variable "wg_server_location" { - type = string + type = string description = "Server location" - default = "fsn1" + default = "fsn1" } variable "wg_server_ssh_publickey" { - type = string + type = string description = "SSH public key" } variable "wg_server_ssh_publickey_name" { - type = string + type = string description = "SSH public key name" } variable "wg_server_own_privatekey" { - type = string + type = string description = "WireGuard private key" } variable "wg_server_peer_publickeys" { - type = list(string) + type = list(string) description = "WireGuard peer public keys" }