this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(infra): pass hosts metadata to flake

Khue Doan 50819067 f42c68d5

+90 -50
+3
infra/_modules/nixos/configuration.nix
··· 1 1 { modulesPath, ... }: 2 2 3 + let 4 + hosts = builtins.fromJSON (builtins.readFile ./hosts.json); 5 + in 3 6 { 4 7 imports = [ 5 8 (modulesPath + "/profiles/all-hardware.nix")
+19 -1
infra/_modules/nixos/flake.nix
··· 25 25 ./profiles/devbox.nix 26 26 ]; 27 27 }; 28 - k3s = nixpkgs.lib.nixosSystem { 28 + kube-1 = nixpkgs.lib.nixosSystem { 29 + system = "x86_64-linux"; 30 + modules = [ 31 + disko.nixosModules.disko 32 + ./configuration.nix 33 + ./disks.nix 34 + ./profiles/k3s.nix 35 + ]; 36 + }; 37 + kube-2 = nixpkgs.lib.nixosSystem { 38 + system = "x86_64-linux"; 39 + modules = [ 40 + disko.nixosModules.disko 41 + ./configuration.nix 42 + ./disks.nix 43 + ./profiles/k3s.nix 44 + ]; 45 + }; 46 + kube-3 = nixpkgs.lib.nixosSystem { 29 47 system = "x86_64-linux"; 30 48 modules = [ 31 49 disko.nixosModules.disko
+1
infra/_modules/nixos/hosts.json
··· 1 + {"kube-1":{"ipv6_address":"2402:800:63e2:5af5:57e2:ac2e:7bfa:b4ee"},"kube-2":{"ipv6_address":"2402:800:63e2:5af5:2eb2:b07e:ced0:5d7f"},"kube-3":{"ipv6_address":"2402:800:63e2:5af5:a811:9da5:775e:addc"}}
+11
infra/_modules/nixos/main.tf
··· 1 + resource "local_file" "hosts" { 2 + content = jsonencode(var.hosts) # Converts variables to JSON 3 + filename = "${var.flake}/hosts.json" 4 + file_permission = "600" 5 + 6 + provisioner "local-exec" { 7 + interpreter = ["bash", "-c"] 8 + command = "git add -f '${var.flake}/hosts.json'" 9 + } 10 + } 11 + 1 12 module "nixos" { 2 13 for_each = var.hosts 3 14
+11 -12
infra/_modules/proxmox-vm/main.tf
··· 1 1 resource "proxmox_virtual_environment_vm" "main" { 2 - name = var.name 2 + for_each = var.hosts 3 + 4 + name = each.key 3 5 node_name = var.node_name 4 6 5 7 cpu { 6 - cores = var.cpu.cores 8 + cores = each.value.cpu 7 9 } 8 10 9 11 memory { 10 - dedicated = 1024 * var.memory.dedicated 12 + dedicated = 1024 * each.value.memory 11 13 # Set floating to the same value as dedicated to enable ballooning device 12 - floating = 1024 * var.memory.dedicated 14 + floating = 1024 * each.value.memory 13 15 } 14 16 15 17 cdrom { ··· 18 20 interface = "ide3" 19 21 } 20 22 21 - dynamic "disk" { 22 - for_each = var.disks 23 - content { 24 - datastore_id = "local-lvm" 25 - interface = "scsi0" 26 - size = disk.value.size 27 - file_format = "raw" 28 - } 23 + disk { 24 + datastore_id = "local-lvm" 25 + interface = "scsi0" 26 + size = each.value.disk 27 + file_format = "raw" 29 28 } 30 29 31 30 boot_order = [
+6 -2
infra/_modules/proxmox-vm/outputs.tf
··· 1 - output "ipv6_address" { 2 - value = proxmox_virtual_environment_vm.main.ipv6_addresses[1][0] 1 + output "hosts" { 2 + value = { 3 + for node in proxmox_virtual_environment_vm.main : node.name => { 4 + ipv6_address = node.ipv6_addresses[1][0] 5 + } 6 + } 3 7 }
+6 -20
infra/_modules/proxmox-vm/variables.tf
··· 1 - variable "name" { 2 - type = string 1 + variable "hosts" { 2 + type = map(object({ 3 + cpu = number 4 + memory = number 5 + disk = number 6 + })) 3 7 } 4 8 5 9 variable "node_name" { ··· 7 11 default = "proxmox" 8 12 } 9 13 10 - variable "cpu" { 11 - type = object({ 12 - cores = number 13 - }) 14 - } 15 - 16 - variable "memory" { 17 - type = object({ 18 - dedicated = number 19 - }) 20 - } 21 - 22 14 variable "cdrom" { 23 15 type = object({ 24 16 file = string ··· 27 19 default = { 28 20 file = "nixos-24.11.20250123.035f8c0-x86_64-linux.iso" 29 21 } 30 - } 31 - 32 - variable "disks" { 33 - type = map(object({ 34 - size = number 35 - })) 36 22 } 37 23 38 24 variable "tags" {
+17
infra/production/nixos/.terraform.lock.hcl
··· 18 18 ] 19 19 } 20 20 21 + provider "registry.opentofu.org/hashicorp/local" { 22 + version = "2.5.3" 23 + hashes = [ 24 + "h1:mC9+u1eaUILTjxey6Ivyf/3djm//RNNze9kBVX/trng=", 25 + "zh:32e1d4b0595cea6cda4ca256195c162772ddff25594ab4008731a2ec7be230bf", 26 + "zh:48c390af0c87df994ec9796f04ec2582bcac581fb81ed6bb58e0671da1c17991", 27 + "zh:4be7289c969218a57b40902e2f359914f8d35a7f97b439140cb711aa21e494bd", 28 + "zh:4cf958e631e99ed6c8b522c9b22e1f1b568c0bdadb01dd002ca7dffb1c927764", 29 + "zh:7a0132c0faca4c4c96aa70808effd6817e28712bf5a39881666ac377b4250acf", 30 + "zh:7d60de08fac427fb045e4590d1b921b6778498eee9eb16f78c64d4c577bde096", 31 + "zh:91003bee5981e99ec3925ce2f452a5f743827f9d0e131a86613549c1464796f0", 32 + "zh:9fe2fe75977c8149e2515fb30c6cc6cfd57b225d4ce592c570d81a3831d7ffa3", 33 + "zh:e210e6be54933ce93e03d0994e520ba289aa01b2c1f70e77afb8f2ee796b0fe3", 34 + "zh:e8793e5f9422f2b31a804e51806595f335b827c9a38db18766960464566f21d5", 35 + ] 36 + } 37 + 21 38 provider "registry.opentofu.org/hashicorp/null" { 22 39 version = "3.2.4" 23 40 hashes = [
+1 -5
infra/production/nixos/terragrunt.hcl
··· 13 13 14 14 inputs = { 15 15 flake = "${find_in_parent_folders("_modules")}//nixos" 16 - hosts = { 17 - k3s = { 18 - ipv6_address = dependency.proxmox.outputs.ipv6_address 19 - } 20 - } 16 + hosts = dependency.proxmox.outputs.hosts 21 17 }
+15 -10
infra/production/proxmox/compute/terragrunt.hcl
··· 8 8 } 9 9 10 10 inputs = { 11 - name = "k3s" 12 - cpu = { 13 - cores = 8 14 - } 15 - memory = { 16 - dedicated = 16 17 - } 18 - disks = { 19 - os = { 20 - size = 256 11 + hosts = { 12 + "kube-1" = { 13 + cpu = 2 14 + memory = 4 15 + disk = 128 16 + } 17 + "kube-2" = { 18 + cpu = 2 19 + memory = 4 20 + disk = 128 21 + } 22 + "kube-3" = { 23 + cpu = 8 24 + memory = 16 25 + disk = 128 21 26 } 22 27 } 23 28 }