Format
This commit is contained in:
parent
2b83b7b75c
commit
e9d9202616
@ -6,8 +6,8 @@ build {
|
|||||||
]
|
]
|
||||||
|
|
||||||
provisioner "file" {
|
provisioner "file" {
|
||||||
direction = "upload"
|
direction = "upload"
|
||||||
source = "./rootfs"
|
source = "./rootfs"
|
||||||
destination = "/tmp"
|
destination = "/tmp"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
source "hcloud" "main" {
|
source "hcloud" "main" {
|
||||||
token = var.hcloud_api_token
|
token = var.hcloud_api_token
|
||||||
|
|
||||||
image = "ubuntu-20.04"
|
image = "ubuntu-20.04"
|
||||||
server_name = "wireguard-{{timestamp}}"
|
server_name = "wireguard-{{timestamp}}"
|
||||||
server_type = "cx11"
|
server_type = "cx11"
|
||||||
location = "fsn1"
|
location = "fsn1"
|
||||||
|
|
||||||
snapshot_name = "wireguard-{{timestamp}}"
|
snapshot_name = "wireguard-{{timestamp}}"
|
||||||
snapshot_labels = {
|
snapshot_labels = {
|
||||||
@ -13,19 +13,19 @@ source "hcloud" "main" {
|
|||||||
|
|
||||||
user_data_file = "./hetzner/seed/user-data"
|
user_data_file = "./hetzner/seed/user-data"
|
||||||
|
|
||||||
ssh_port = "22"
|
ssh_port = "22"
|
||||||
ssh_username = "root"
|
ssh_username = "root"
|
||||||
ssh_timeout = "10m"
|
ssh_timeout = "10m"
|
||||||
ssh_clear_authorized_keys = true
|
ssh_clear_authorized_keys = true
|
||||||
}
|
}
|
||||||
|
|
||||||
source "digitalocean" "main" {
|
source "digitalocean" "main" {
|
||||||
api_token = var.digitalocean_api_token
|
api_token = var.digitalocean_api_token
|
||||||
|
|
||||||
image = "ubuntu-20-04-x64"
|
image = "ubuntu-20-04-x64"
|
||||||
droplet_name = "wireguard-{{timestamp}}"
|
droplet_name = "wireguard-{{timestamp}}"
|
||||||
size = "s-1vcpu-1gb"
|
size = "s-1vcpu-1gb"
|
||||||
region = "fra1"
|
region = "fra1"
|
||||||
|
|
||||||
snapshot_name = "wireguard-{{timestamp}}"
|
snapshot_name = "wireguard-{{timestamp}}"
|
||||||
tags = [
|
tags = [
|
||||||
@ -34,40 +34,40 @@ source "digitalocean" "main" {
|
|||||||
|
|
||||||
user_data_file = "./digitalocean/seed/user-data"
|
user_data_file = "./digitalocean/seed/user-data"
|
||||||
|
|
||||||
ssh_port = "22"
|
ssh_port = "22"
|
||||||
ssh_username = "root"
|
ssh_username = "root"
|
||||||
ssh_timeout = "10m"
|
ssh_timeout = "10m"
|
||||||
ssh_clear_authorized_keys = true
|
ssh_clear_authorized_keys = true
|
||||||
}
|
}
|
||||||
|
|
||||||
source "qemu" "main" {
|
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"
|
iso_checksum = "file:https://cloud-images.ubuntu.com/daily/server/focal/current/SHA256SUMS"
|
||||||
disk_image = true
|
disk_image = true
|
||||||
|
|
||||||
vm_name = "wireguard.qcow2"
|
vm_name = "wireguard.qcow2"
|
||||||
http_directory = "./qemu/http/"
|
http_directory = "./qemu/http/"
|
||||||
output_directory = "./dist/qemu/"
|
output_directory = "./dist/qemu/"
|
||||||
|
|
||||||
accelerator = "kvm"
|
accelerator = "kvm"
|
||||||
cpus = 1
|
cpus = 1
|
||||||
memory = 512
|
memory = 512
|
||||||
headless = true
|
headless = true
|
||||||
qemuargs = [
|
qemuargs = [
|
||||||
["-smbios", "type=1,serial=ds=nocloud-net;s=http://{{.HTTPIP}}:{{.HTTPPort}}/seed/"]
|
["-smbios", "type=1,serial=ds=nocloud-net;s=http://{{.HTTPIP}}:{{.HTTPPort}}/seed/"]
|
||||||
]
|
]
|
||||||
|
|
||||||
net_device = "virtio-net"
|
net_device = "virtio-net"
|
||||||
|
|
||||||
format = "qcow2"
|
format = "qcow2"
|
||||||
disk_size = "4G"
|
disk_size = "4G"
|
||||||
disk_interface = "virtio"
|
disk_interface = "virtio"
|
||||||
disk_compression = false
|
disk_compression = false
|
||||||
|
|
||||||
ssh_port = "22"
|
ssh_port = "22"
|
||||||
ssh_username = "root"
|
ssh_username = "root"
|
||||||
ssh_password = "toor"
|
ssh_password = "toor"
|
||||||
ssh_timeout = "10m"
|
ssh_timeout = "10m"
|
||||||
ssh_clear_authorized_keys = true
|
ssh_clear_authorized_keys = true
|
||||||
|
|
||||||
shutdown_command = "shutdown -P now"
|
shutdown_command = "shutdown -P now"
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
variable "hcloud_api_token" {
|
variable "hcloud_api_token" {
|
||||||
type = string
|
type = string
|
||||||
description = "Hetzner Cloud API token"
|
description = "Hetzner Cloud API token"
|
||||||
default = ""
|
default = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "digitalocean_api_token" {
|
variable "digitalocean_api_token" {
|
||||||
type = string
|
type = string
|
||||||
description = "DigitalOcean API token"
|
description = "DigitalOcean API token"
|
||||||
default = ""
|
default = ""
|
||||||
}
|
}
|
||||||
|
@ -4,19 +4,19 @@ provider "hcloud" {
|
|||||||
|
|
||||||
data "hcloud_image" "wg_image" {
|
data "hcloud_image" "wg_image" {
|
||||||
with_selector = "service=wireguard"
|
with_selector = "service=wireguard"
|
||||||
most_recent = true
|
most_recent = true
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "hcloud_ssh_key" "wg_server_ssh_key" {
|
resource "hcloud_ssh_key" "wg_server_ssh_key" {
|
||||||
public_key = var.wg_server_ssh_publickey
|
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" {
|
resource "hcloud_server" "wg_server" {
|
||||||
image = data.hcloud_image.wg_image.id
|
image = data.hcloud_image.wg_image.id
|
||||||
name = var.wg_server_name
|
name = var.wg_server_name
|
||||||
server_type = var.wg_server_type
|
server_type = var.wg_server_type
|
||||||
location = var.wg_server_location
|
location = var.wg_server_location
|
||||||
labels = {
|
labels = {
|
||||||
service = "wireguard"
|
service = "wireguard"
|
||||||
}
|
}
|
||||||
@ -24,7 +24,7 @@ resource "hcloud_server" "wg_server" {
|
|||||||
hcloud_ssh_key.wg_server_ssh_key.id
|
hcloud_ssh_key.wg_server_ssh_key.id
|
||||||
]
|
]
|
||||||
user_data = templatefile("${path.module}/templates/user-data.tpl", {
|
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
|
wg_server_peer_publickeys = var.wg_server_peer_publickeys
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
output "wg_server_ipv4_address" {
|
output "wg_server_ipv4_address" {
|
||||||
value = hcloud_server.wg_server.ipv4_address
|
value = hcloud_server.wg_server.ipv4_address
|
||||||
description = "IPv4 address"
|
description = "IPv4 address"
|
||||||
}
|
}
|
||||||
|
|
||||||
output "wg_server_ipv6_address" {
|
output "wg_server_ipv6_address" {
|
||||||
value = hcloud_server.wg_server.ipv6_address
|
value = hcloud_server.wg_server.ipv6_address
|
||||||
description = "IPv6 address"
|
description = "IPv6 address"
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
hcloud_api_token = ""
|
hcloud_api_token = ""
|
||||||
|
|
||||||
wg_server_name = ""
|
wg_server_name = ""
|
||||||
wg_server_type = ""
|
wg_server_type = ""
|
||||||
wg_server_location = ""
|
wg_server_location = ""
|
||||||
|
|
||||||
wg_server_ssh_publickey = ""
|
wg_server_ssh_publickey = ""
|
||||||
wg_server_ssh_publickey_name = ""
|
wg_server_ssh_publickey_name = ""
|
||||||
|
|
||||||
wg_server_own_privatekey = ""
|
wg_server_own_privatekey = ""
|
||||||
wg_server_peer_publickeys = []
|
wg_server_peer_publickeys = []
|
||||||
|
@ -1,43 +1,43 @@
|
|||||||
variable "hcloud_api_token" {
|
variable "hcloud_api_token" {
|
||||||
type = string
|
type = string
|
||||||
description = "Hetzner Cloud API token"
|
description = "Hetzner Cloud API token"
|
||||||
default = ""
|
default = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "wg_server_name" {
|
variable "wg_server_name" {
|
||||||
type = string
|
type = string
|
||||||
description = "Server name"
|
description = "Server name"
|
||||||
default = "wireguard"
|
default = "wireguard"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "wg_server_type" {
|
variable "wg_server_type" {
|
||||||
type = string
|
type = string
|
||||||
description = "Server type"
|
description = "Server type"
|
||||||
default = "cx11"
|
default = "cx11"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "wg_server_location" {
|
variable "wg_server_location" {
|
||||||
type = string
|
type = string
|
||||||
description = "Server location"
|
description = "Server location"
|
||||||
default = "fsn1"
|
default = "fsn1"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "wg_server_ssh_publickey" {
|
variable "wg_server_ssh_publickey" {
|
||||||
type = string
|
type = string
|
||||||
description = "SSH public key"
|
description = "SSH public key"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "wg_server_ssh_publickey_name" {
|
variable "wg_server_ssh_publickey_name" {
|
||||||
type = string
|
type = string
|
||||||
description = "SSH public key name"
|
description = "SSH public key name"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "wg_server_own_privatekey" {
|
variable "wg_server_own_privatekey" {
|
||||||
type = string
|
type = string
|
||||||
description = "WireGuard private key"
|
description = "WireGuard private key"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "wg_server_peer_publickeys" {
|
variable "wg_server_peer_publickeys" {
|
||||||
type = list(string)
|
type = list(string)
|
||||||
description = "WireGuard peer public keys"
|
description = "WireGuard peer public keys"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user