more fixes

This commit is contained in:
Jörg Thalheim 2023-05-11 00:29:15 +02:00
parent 92fb8a9476
commit d1e5c253f0
5 changed files with 29 additions and 9 deletions

View File

@ -4,14 +4,14 @@ resource "netlify_dns_zone" "nixos" {
}
resource "netlify_dns_record" "nixos_wiki_a" {
zone_id = var.zone_id
zone_id = netlify_dns_zone.nixos.id
hostname = var.domain
type = "A"
value = hcloud_server.nixos_wiki.ipv4_address
}
resource "netlify_dns_record" "nixos_wiki_aaaa" {
zone_id = var.zone_id
zone_id = netlify_dns_zone.nixos.id
hostname = var.domain
type = "AAAA"
value = hcloud_server.nixos_wiki.ipv6_address

View File

@ -1,7 +1,7 @@
# Record the SSH public key into Hetzner Cloud
resource "hcloud_ssh_key" "hcloud" {
for_each = var.admin_ssh_keys
name = each.key
name = "${var.domain}-${each.key}"
public_key = each.value
}
@ -10,11 +10,11 @@ resource "hcloud_server" "nixos_wiki" {
keep_disk = true
name = "nixos-wiki"
server_type = var.server_type
ssh_keys = data.hcloud_ssh_key.hcloud[*].id
ssh_keys = [for k in hcloud_ssh_key.hcloud : k.id]
backups = false
labels = var.tags
location = var.server_location
location = var.server_location
lifecycle {
# Don't destroy server instance if ssh keys changes.
@ -24,12 +24,12 @@ resource "hcloud_server" "nixos_wiki" {
}
module "deploy" {
depends_on = [ local_file.nixos_vars ]
depends_on = [local_file.nixos_vars]
source = "github.com/numtide/nixos-anywhere//terraform/all-in-one"
nixos_system_attr = ".#nixosConfigurations.${var.nixos_flake_attr}.config.system.build.toplevel"
nixos_partitioner_attr = ".#nixosConfigurations.${var.nixos_flake_attr}.config.system.build.diskoNoDeps"
target_host = hcloud_server.nixos-wiki.ipv4_address
instance_id = hcloud_server.nixos-wiki.id
target_host = hcloud_server.nixos_wiki.ipv4_address
instance_id = hcloud_server.nixos_wiki.id
debug_logging = true
}

View File

@ -29,3 +29,14 @@ variable "nixos_flake_attr" {
type = string
description = "NixOS configuration flake attribute"
}
variable "domain" {
type = string
description = "Domain name"
}
variable "tags" {
type = map(string)
default = {}
description = "Tags to add to the server"
}

View File

@ -15,6 +15,11 @@ module "wiki" {
mic92 = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKbBp2dH2X3dcU1zh+xW3ZsdYROKpJd3n13ssOP092qE joerg@turingmachine"
}
netlify_dns_zone = "wiki.thalheim.io"
domain = "wiki.thalheim.io"
nixos_flake_attr = "nixos-wiki-production"
nixos_vars_file = "${path.module}/nixos-vars.json"
nixos_vars_file = "${path.module}/nixos-vars.json"
tags = {
Terraform = "true"
Target = "nixos-wiki.thalheim.io"
}
}

View File

@ -17,4 +17,8 @@ module "wiki" {
netlify_dns_zone = "wiki.thalheim.io"
nixos_flake_attr = "nixos-wiki-staging"
nixos_vars_file = "${path.module}/nixos-vars.json"
tags = {
Terraform = "true"
Target = "nixos-wiki.thalheim.io"
}
}