propagate ips

Signed-off-by: Kiara Grouwstra <kiara@procolix.eu>
This commit is contained in:
Kiara Grouwstra 2025-10-13 15:25:20 +02:00
parent 40fad454a7
commit d3a4137900
Signed by: kiara
SSH key fingerprint: SHA256:COspvLoLJ5WC5rFb9ZDe5urVCkK4LJZOsjfF4duRJFU
7 changed files with 102 additions and 13 deletions

View file

@ -32,6 +32,10 @@ let
vlanId
imageDatastoreId
vmDatastoreId
ipv4Gateway
ipv4Address
ipv6Gateway
ipv6Address
;
inherit (lib) mkOption types;
eval =
@ -348,6 +352,10 @@ let
vlanId
imageDatastoreId
vmDatastoreId
ipv4Gateway
ipv4Address
ipv6Gateway
ipv6Address
;
root-path = pathToRoot;
};

View file

@ -27,6 +27,10 @@ let
vlanId = 0;
imageDatastoreId = "local";
vmDatastoreId = "local";
ipv4Gateway = "192.168.1.1";
ipv4Address = "192.168.1.236/24";
ipv6Gateway = "";
ipv6Address = "";
};
# FIXME generate the image `nixos-generate` was to make, but now do it for a desired `-c configuration.nix` rather than whatever generic thing now
deployment =

View file

@ -54,5 +54,25 @@ in
type = types.str;
default = "local";
};
ipv4Gateway = mkOption {
description = "Gateway for IPv4.";
type = types.str;
default = "";
};
ipv4Address = mkOption {
description = "IPv4 address.";
type = types.str;
default = "";
};
ipv6Gateway = mkOption {
description = "Gateway for IPv6.";
type = types.str;
default = "";
};
ipv6Address = mkOption {
description = "IPv6 address.";
type = types.str;
default = "";
};
};
}

View file

@ -349,6 +349,26 @@ let
type = types.str;
default = "local";
};
ipv4Gateway = mkOption {
description = "Gateway for IPv4.";
type = types.str;
default = "";
};
ipv4Address = mkOption {
description = "IPv4 address.";
type = types.str;
default = "";
};
ipv6Gateway = mkOption {
description = "Gateway for IPv6.";
type = types.str;
default = "";
};
ipv6Address = mkOption {
description = "IPv6 address.";
type = types.str;
default = "";
};
run = mkOption {
type = types.package;
# error: The option `tf-deployment.tf-host.run' is read-only, but it's set multiple times.
@ -370,6 +390,10 @@ let
vlanId
imageDatastoreId
vmDatastoreId
ipv4Gateway
ipv4Address
ipv6Gateway
ipv6Address
;
inherit (ssh)
host
@ -440,6 +464,10 @@ let
vlan_id = vlanId;
image_datastore_id = imageDatastoreId;
vm_datastore_id = vmDatastoreId;
ipv4_gateway = ipv4Gateway;
ipv4_address = ipv4Address;
ipv6_gateway = ipv6Gateway;
ipv6_address = ipv6Address;
};
tf-env = pkgs.callPackage ./run/tf-env.nix {
inherit httpBackend;

View file

@ -163,19 +163,18 @@ resource "proxmox_virtual_environment_vm" "nix_vm" {
scsi_hardware = "virtio-scsi-single"
bios = "ovmf"
# # used only for cloud-init
# initialization {
# ip_config {
# ipv4 {
# gateway = "eth0"
# address = "95.215.187.${proxmox_virtual_environment_vm.nix_vm.vm_id}" # error: self-referential block
# }
# ipv6 {
# gateway = "eth0"
# address = "2a00:51c0:13:1305::${proxmox_virtual_environment_vm.nix_vm.vm_id}"
# }
# }
# }
initialization {
ip_config {
ipv4 {
gateway = var.ipv4_gateway
address = var.ipv4_address
}
# ipv6 {
# gateway = var.ipv6_gateway
# address = var.ipv6_address
# }
}
}
}
resource "null_resource" "wait_for_ssh" {

View file

@ -76,6 +76,30 @@ variable "vm_datastore_id" {
default = "local"
}
variable "ipv4_gateway" {
description = "Gateway for IPv4."
type = string
default = ""
}
variable "ipv4_address" {
description = "IPv4 address."
type = string
default = ""
}
variable "ipv6_gateway" {
description = "Gateway for IPv6."
type = string
default = ""
}
variable "ipv6_address" {
description = "IPv6 address."
type = string
default = ""
}
#########################################
variable "category" {

View file

@ -99,6 +99,12 @@
vlanId = 1305;
imageDatastoreId = "local";
vmDatastoreId = "linstor_storage";
ipv4Gateway = "eth0";
ipv4Address = "";
# ipv4Address = "95.215.187.${vm-id}";
ipv6Gateway = "eth0";
ipv6Address = "";
# ipv6Address = "2a00:51c0:13:1305::${vm-id}";
};
# opt not to pass `inputs`, as we could only pass serializable arguments through to its self-call
})."tf-proxmox-deployment".tf-proxmox-host;