This commit is contained in:
Héctor Molinero Fernández 2021-06-14 22:49:37 +02:00
parent 2b83b7b75c
commit e9d9202616
7 changed files with 55 additions and 55 deletions

View File

@ -6,8 +6,8 @@ build {
]
provisioner "file" {
direction = "upload"
source = "./rootfs"
direction = "upload"
source = "./rootfs"
destination = "/tmp"
}

View File

@ -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"

View File

@ -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 = ""
}

View File

@ -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
})
}

View File

@ -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"
}

View File

@ -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 = []

View File

@ -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"
}