feat: runner terraform

This commit is contained in:
2025-10-01 23:06:29 -04:00
parent 909fd105e7
commit 5f2b51ef09
3 changed files with 122 additions and 72 deletions

View File

@@ -1,3 +1,10 @@
resource "hcloud_network" "network" {
name = "network"
ip_range = "10.0.0.0/16"
}
/* -------------------------------------------------------------------------- */
resource "hcloud_primary_ip" "public_ip" {
name = "repository-public-ip"
datacenter = local.datacenter
@@ -6,23 +13,28 @@ resource "hcloud_primary_ip" "public_ip" {
auto_delete = false
}
resource "hcloud_ssh_key" "ssh_key" {
resource "hcloud_ssh_key" "gitea_ssh_key" {
name = "repository-ssh-key"
public_key = file(var.public_ssh_key_path)
public_key = file(var.public_gitea_ssh_key_path)
}
resource "hcloud_server" "server_instance" {
name = "repository-server"
resource "hcloud_server" "gitea_server_instance" {
name = "repository-gitea_server"
image = local.server_image
server_type = local.server_type
datacenter = local.datacenter
ssh_keys = [hcloud_ssh_key.ssh_key.id]
ssh_keys = [hcloud_ssh_key.gitea_ssh_key.id]
public_net {
ipv4_enabled = true
ipv4 = hcloud_primary_ip.public_ip.id
ipv6_enabled = false
}
network {
network_id = hcloud_network.network.id
ip = local.gitea_ip
}
}
resource "hcloud_firewall" "server_firewall" {
@@ -60,3 +72,28 @@ resource "hcloud_firewall_attachment" "server_fw_attachment" {
firewall_id = hcloud_firewall.server_firewall.id
server_ids = [hcloud_server.server_instance.id]
}
/* -------------------------------------------------------------------------- */
resource "hcloud_ssh_key" "runner_ssh_key" {
name = "repository-runner-ssh-key"
public_key = file(var.public_runner_ssh_key_path)
}
resource "hcloud_server" "runner_instance" {
name = "repository-runner-server"
image = local.server_image
server_type = local.server_type
datacenter = local.datacenter
ssh_keys = [hcloud_ssh_key.runner_ssh_key.id]
public_net {
ipv4_enabled = false
ipv6_enabled = false
}
network {
network_id = hcloud_network.network.id
ip = local.runner_ip
}
}

View File

@@ -5,6 +5,10 @@ locals {
domain = "maximhutz.com"
subdomain = "git"
network_cidr = "10.0.0.0/16"
gitea_ip = "10.0.0.16"
runner_ip = "10.0.0.17"
}
# ---------------------------------------------------------------------------- #
@@ -15,8 +19,13 @@ variable "hcloud_token" {
type = string
}
variable "public_ssh_key_path" {
description = "The location of the public key used to access the repository server."
variable "public_gitea_ssh_key_path" {
description = "The location of the public key used to access the repository Gitea server."
type = string
}
variable "public_runner_ssh_key_path" {
description = "The location of the public key used to access the repository Gitea Action runner."
type = string
}