diff --git a/deployment/check/common/data-model.nix b/deployment/check/common/data-model.nix index e32e6083..ff29326c 100644 --- a/deployment/check/common/data-model.nix +++ b/deployment/check/common/data-model.nix @@ -30,6 +30,8 @@ let node-name bridge vlanId + imageDatastoreId + vmDatastoreId ; inherit (lib) mkOption types; eval = @@ -344,6 +346,8 @@ let node-name bridge vlanId + imageDatastoreId + vmDatastoreId ; root-path = pathToRoot; }; diff --git a/deployment/check/data-model-tf-proxmox/nixosTest.nix b/deployment/check/data-model-tf-proxmox/nixosTest.nix index 503e02f0..484c7b1d 100644 --- a/deployment/check/data-model-tf-proxmox/nixosTest.nix +++ b/deployment/check/data-model-tf-proxmox/nixosTest.nix @@ -25,6 +25,8 @@ let node-name = "pve"; bridge = "br0"; vlanId = 0; + imageDatastoreId = "local"; + vmDatastoreId = "local"; }; # 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 = diff --git a/deployment/check/data-model-tf/options.nix b/deployment/check/data-model-tf/options.nix index 8100c8c4..c0d4cf59 100644 --- a/deployment/check/data-model-tf/options.nix +++ b/deployment/check/data-model-tf/options.nix @@ -44,5 +44,15 @@ in type = types.int; default = 0; }; + imageDatastoreId = mkOption { + description = "ID of the datastore of the image."; + type = types.str; + default = "local"; + }; + vmDatastoreId = mkOption { + description = "ID of the datastore of the VM."; + type = types.str; + default = "local"; + }; }; } diff --git a/deployment/data-model.nix b/deployment/data-model.nix index 4a5369b7..0ddb7262 100644 --- a/deployment/data-model.nix +++ b/deployment/data-model.nix @@ -364,6 +364,16 @@ let type = types.int; default = 0; }; + imageDatastoreId = mkOption { + description = "ID of the datastore of the image."; + type = types.str; + default = "local"; + }; + vmDatastoreId = mkOption { + description = "ID of the datastore of the VM."; + type = types.str; + default = "local"; + }; run = mkOption { type = types.package; # error: The option `tf-deployment.tf-host.run' is read-only, but it's set multiple times. @@ -383,6 +393,8 @@ let node-name bridge vlanId + imageDatastoreId + vmDatastoreId ; inherit (ssh) host @@ -451,6 +463,8 @@ let proxmox_password = proxmox-password; ssh_user = username; vlan_id = vlanId; + image_datastore_id = imageDatastoreId; + vm_datastore_id = vmDatastoreId; }; tf-env = pkgs.callPackage ./run/tf-env.nix { inherit httpBackend; diff --git a/deployment/run/tf-proxmox/main.tf b/deployment/run/tf-proxmox/main.tf index 3ac2f2fe..703ebd44 100644 --- a/deployment/run/tf-proxmox/main.tf +++ b/deployment/run/tf-proxmox/main.tf @@ -75,7 +75,7 @@ resource "proxmox_virtual_environment_file" "upload" { # https://192.168.51.81:8006/#v1:0:=storage%2Fnode051%2Flocal:4::=contentIso::::: # PVE -> Datacenter -> Storage -> local -> Edit -> General -> Content -> check Import + Disk Images -> OK # that UI action also adds it in `/etc/pve/storage.cfg` - datastore_id = "local" + datastore_id = var.image_datastore_id # datastore_id = "local-lvm" # datastore_id = "backup" node_name = var.node_name @@ -133,7 +133,7 @@ resource "proxmox_virtual_environment_vm" "nix_vm" { disk { # datastore_id = "linstor_storage" - datastore_id = "local" + datastore_id = var.vm_datastore_id file_format = "qcow2" interface = "scsi0" discard = "on" @@ -154,7 +154,7 @@ resource "proxmox_virtual_environment_vm" "nix_vm" { efi_disk { # datastore_id = "linstor_storage" - datastore_id = "local" + datastore_id = var.vm_datastore_id file_format = "qcow2" type = "4m" } diff --git a/deployment/run/tf-proxmox/variables.tf b/deployment/run/tf-proxmox/variables.tf index 04adf5b2..99d03ce5 100644 --- a/deployment/run/tf-proxmox/variables.tf +++ b/deployment/run/tf-proxmox/variables.tf @@ -64,6 +64,18 @@ variable "vlan_id" { default = 0 } +variable "image_datastore_id" { + description = "ID of the datastore of the image." + type = string + default = "local" +} + +variable "vm_datastore_id" { + description = "ID of the datastore of the VM." + type = string + default = "local" +} + ######################################### variable "category" { diff --git a/flake.nix b/flake.nix index fa567ae5..b90c0f18 100644 --- a/flake.nix +++ b/flake.nix @@ -97,6 +97,8 @@ node-name = "node051"; bridge = "ovsbr0"; vlanId = 1305; + imageDatastoreId = "local"; + vmDatastoreId = "linstor_storage"; }; # opt not to pass `inputs`, as we could only pass serializable arguments through to its self-call })."tf-proxmox-deployment".tf-proxmox-host;