diff --git a/id.tjo.space/README.md b/README.md similarity index 100% rename from id.tjo.space/README.md rename to README.md diff --git a/id.tjo.space/install.sh b/id.tjo.space/install.sh index e9b6ea0..1fcdfb3 100755 --- a/id.tjo.space/install.sh +++ b/id.tjo.space/install.sh @@ -15,7 +15,7 @@ if [ ! -d .git ]; then --depth 1 \ --no-checkout \ --filter=tree:0 \ - https://github.com/tjo-space/tjo-cloud-infrastructure.git . + https://github.com/tjo-space/tjo-space-infrastructure.git . git sparse-checkout set --no-cone /id.tjo.space git checkout else @@ -37,10 +37,6 @@ function provision() { ufw allow 443/tcp # HTTPS ufw allow 636/tcp # LDAPS ufw enable - - ## - echo "=== Setting up the user" - loginctl enable-linger "ubuntu" } echo "=== Provision the System (as root)" diff --git a/id.tjo.space/justfile b/id.tjo.space/justfile index 2ab7ef2..5116ae1 100644 --- a/id.tjo.space/justfile +++ b/id.tjo.space/justfile @@ -1,8 +1,3 @@ -# Always use devbox environment to run commands. -set shell := ["devbox", "run"] -# Load dotenv -set dotenv-load - default: @just --list diff --git a/id.tjo.space/terraform/main.tf b/id.tjo.space/terraform/main.tf index 0b2766d..89843aa 100644 --- a/id.tjo.space/terraform/main.tf +++ b/id.tjo.space/terraform/main.tf @@ -1,11 +1,15 @@ resource "hcloud_ssh_key" "main" { for_each = var.ssh_keys + name = each.key - public_key = eeach.value + public_key = each.value } resource "hcloud_server" "main" { - name = "id.tjo.space" + for_each = toset(var.nodes) + + name = "${each.key}.id.tjo.space" + image = "ubuntu-24.04" server_type = "cax11" @@ -18,11 +22,11 @@ resource "hcloud_server" "main" { backups = true - ssh_keys = [for key in var.ssh_keys : hcloud_ssh_key.main[key].id] + ssh_keys = [for key, value in var.ssh_keys : hcloud_ssh_key.main[key].id] user_data = <<-EOF #cloud-config - hostname: id + hostname: ${each.key} fqdn: id.tjo.space prefer_fqdn_over_hostname: true packages: @@ -41,17 +45,21 @@ resource "hcloud_server" "main" { } resource "dnsimple_zone_record" "a" { + for_each = toset(var.nodes) + zone_name = "tjo.space" name = "id.tjo.space" - value = hcloud_server.main.ipv4_address + value = hcloud_server.main[each.key].ipv4_address type = "A" ttl = 300 } resource "dnsimple_zone_record" "aaaa" { + for_each = toset(var.nodes) + zone_name = "tjo.space" name = "id.tjo.space" - value = hcloud_server.main.ipv6_address + value = hcloud_server.main[each.key].ipv6_address type = "AAAA" ttl = 300 } diff --git a/id.tjo.space/terraform/terraform.tf b/id.tjo.space/terraform/terraform.tf index 74a0a04..c3957ec 100644 --- a/id.tjo.space/terraform/terraform.tf +++ b/id.tjo.space/terraform/terraform.tf @@ -19,5 +19,5 @@ provider "hcloud" { provider "dnsimple" { token = var.dnsimple_token - account = var.dnsimple_aaccount_id + account = var.dnsimple_account_id } diff --git a/id.tjo.space/terraform/terraform.tfvars b/id.tjo.space/terraform/terraform.tfvars index dc6deb5..d22fcaa 100644 --- a/id.tjo.space/terraform/terraform.tfvars +++ b/id.tjo.space/terraform/terraform.tfvars @@ -1,3 +1,7 @@ +nodes = [ + "01", +] + ssh_keys = { "tine+pc" = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICXAlzwziqfUUb2qmFwNF/nrBYc5MNT1MMOx81ohBmB+ tine+pc@tjo.space" "tine+mobile" = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAdPg/nG/Qzk110SBukHHEDqH6/3IJHsIKKHWTrqjaOh tine+mobile@tjo.space" diff --git a/id.tjo.space/terraform/variables.tf b/id.tjo.space/terraform/variables.tf index ea232c4..ce8d7d7 100644 --- a/id.tjo.space/terraform/variables.tf +++ b/id.tjo.space/terraform/variables.tf @@ -1,17 +1,21 @@ variable "hcloud_token" { sensitive = true - type = string + type = string } variable "dnsimple_token" { sensitive = true - type = string + type = string } -variable "dnsimple_aaccount_id" { +variable "dnsimple_account_id" { type = string } variable "ssh_keys" { type = map(string) } + +variable "nodes" { + type = list(string) +} diff --git a/justfile b/justfile new file mode 100644 index 0000000..155f4d0 --- /dev/null +++ b/justfile @@ -0,0 +1,9 @@ +# Always use devbox environment to run commands. +set shell := ["devbox", "run"] +# Load dotenv +set dotenv-load + +mod id 'id.tjo.space' + +default: + @just --list