fix(tofu): volume-provisioning

A Proxmox update probably broke/changed the way API requests are handled, giving errors on UPDATE calls with parameters that aren't used

Error: unexpected response code '400': {"data":null,"errors":{"format":"property is not defined in schema and the schema does not allow additional properties","vmid":"property is not defined in schema and the schema does not allow additional properties","size":"property is not defined in schema and the schema does not allow additional properties","filename":"property is not defined in schema and the schema does not allow additional properties"}}

Also update Mastercard/restapi provider
This commit is contained in:
Vegard Hagen
2025-04-17 18:23:34 +02:00
parent c17687a058
commit 67f160fea1
5 changed files with 54 additions and 38 deletions

View File

@@ -20,36 +20,39 @@ curl --request POST \
## rm state
```shell
tofu state rm 'module.volumes.module.proxmox-volume["pv-lidarr-config"].restapi_object.proxmox-volume'
tofu state rm 'module.volumes.module.proxmox-volume["pv-radarr-config"].restapi_object.proxmox-volume'
tofu state rm 'module.volumes.module.proxmox-volume["pv-sonarr-config"].restapi_object.proxmox-volume'
tofu state rm 'module.volumes.module.proxmox-volume["pv-plex-config"].restapi_object.proxmox-volume'
tofu state rm 'module.volumes.module.proxmox-volume["pv-jellyfin-config"].restapi_object.proxmox-volume'
tofu state rm 'module.volumes.module.proxmox-volume["pv-qbittorrent-config"].restapi_object.proxmox-volume'
tofu state rm 'module.volumes.module.proxmox-volume["pv-sonarr"].restapi_object.proxmox-volume'
tofu state rm 'module.volumes.module.proxmox-volume["pv-radarr"].restapi_object.proxmox-volume'
tofu state rm 'module.volumes.module.proxmox-volume["pv-lidarr"].restapi_object.proxmox-volume'
tofu state rm 'module.volumes.module.proxmox-volume["pv-prowlarr"].restapi_object.proxmox-volume'
tofu state rm 'module.volumes.module.proxmox-volume["pv-torrent"].restapi_object.proxmox-volume'
tofu state rm 'module.volumes.module.proxmox-volume["pv-remark42"].restapi_object.proxmox-volume'
tofu state rm 'module.volumes.module.proxmox-volume["pv-authelia-postgres"].restapi_object.proxmox-volume'
tofu state rm 'module.volumes.module.proxmox-volume["pv-lldap-postgres"].restapi_object.proxmox-volume'
tofu state rm 'module.volumes.module.proxmox-volume["pv-keycloak-postgres"].restapi_object.proxmox-volume'
tofu state rm 'module.volumes.module.proxmox-volume["pv-netbird-management"].restapi_object.proxmox-volume'
tofu state rm 'module.volumes.module.proxmox-volume["pv-jellyfin-config"].restapi_object.proxmox-volume'
tofu state rm 'module.volumes.module.proxmox-volume["pv-netbird-signal"].restapi_object.proxmox-volume'
tofu state rm 'module.volumes.module.proxmox-volume["pv-database"].restapi_object.proxmox-volume'
tofu state rm 'module.volumes.module.proxmox-volume["pv-authelia-database"].restapi_object.proxmox-volume'
tofu state rm 'module.volumes.module.proxmox-volume["pv-lldap-database"].restapi_object.proxmox-volume'
tofu state rm 'module.volumes.module.proxmox-volume["pv-netbird-management"].restapi_object.proxmox-volume'
tofu state rm 'module.volumes.module.proxmox-volume["pv-plex"].restapi_object.proxmox-volume'
tofu state rm 'module.volumes.module.proxmox-volume["pv-prometheus"].restapi_object.proxmox-volume'
```
## import proxmox volume
```shell
tofu import 'module.volumes.module.proxmox-volume["pv-jellyfin-config"].restapi_object.proxmox-volume' /api2/json/nodes/euclid/storage/local-zfs/content/local-zfs:vm-9999-pv-jellyfin-config
tofu import 'module.volumes.module.proxmox-volume["pv-keycloak-db"].restapi_object.proxmox-volume' /api2/json/nodes/euclid/storage/local-zfs/content/local-zfs:vm-9999-pv-keycloak-db
tofu import 'module.volumes.module.proxmox-volume["pv-lidarr-config"].restapi_object.proxmox-volume' /api2/json/nodes/cantor/storage/local-zfs/content/local-zfs:vm-9999-pv-lidarr-config
tofu import 'module.volumes.module.proxmox-volume["pv-netbird-management"].restapi_object.proxmox-volume' /api2/json/nodes/abel/storage/local-zfs/content/local-zfs:vm-9999-pv-netbird-management
tofu import 'module.volumes.module.proxmox-volume["pv-netbird-signal"].restapi_object.proxmox-volume' /api2/json/nodes/abel/storage/local-zfs/content/local-zfs:vm-9999-pv-netbird-signal
tofu import 'module.volumes.module.proxmox-volume["pv-plex-config"].restapi_object.proxmox-volume' /api2/json/nodes/abel/storage/local-zfs/content/local-zfs:vm-9999-pv-plex-config
tofu import 'module.volumes.module.proxmox-volume["pv-prometheus"].restapi_object.proxmox-volume' /api2/json/nodes/abel/storage/local-zfs/content/local-zfs:vm-9999-pv-prometheus
tofu import 'module.volumes.module.proxmox-volume["pv-prowlarr-config"].restapi_object.proxmox-volume' /api2/json/nodes/euclid/storage/local-zfs/content/local-zfs:vm-9999-pv-prowlarr-config
tofu import 'module.volumes.module.proxmox-volume["pv-radarr-config"].restapi_object.proxmox-volume' /api2/json/nodes/cantor/storage/local-zfs/content/local-zfs:vm-9999-pv-radarr-config
tofu import 'module.volumes.module.proxmox-volume["pv-sonarr"].restapi_object.proxmox-volume' /api2/json/nodes/cantor/storage/local-zfs/content/local-zfs:vm-9999-pv-sonarr
tofu import 'module.volumes.module.proxmox-volume["pv-radarr"].restapi_object.proxmox-volume' /api2/json/nodes/cantor/storage/local-zfs/content/local-zfs:vm-9999-pv-radarr
tofu import 'module.volumes.module.proxmox-volume["pv-lidarr"].restapi_object.proxmox-volume' /api2/json/nodes/cantor/storage/local-zfs/content/local-zfs:vm-9999-pv-lidarr
tofu import 'module.volumes.module.proxmox-volume["pv-prowlarr"].restapi_object.proxmox-volume' /api2/json/nodes/euclid/storage/local-zfs/content/local-zfs:vm-9999-pv-prowlarr
tofu import 'module.volumes.module.proxmox-volume["pv-torrent"].restapi_object.proxmox-volume' /api2/json/nodes/euclid/storage/local-zfs/content/local-zfs:vm-9999-pv-torrent
tofu import 'module.volumes.module.proxmox-volume["pv-remark42"].restapi_object.proxmox-volume' /api2/json/nodes/euclid/storage/local-zfs/content/local-zfs:vm-9999-pv-remark42
tofu import 'module.volumes.module.proxmox-volume["pv-sonarr-config"].restapi_object.proxmox-volume' /api2/json/nodes/cantor/storage/local-zfs/content/local-zfs:vm-9999-pv-sonarr-config
tofu import 'module.volumes.module.proxmox-volume["pv-torrent-config"].restapi_object.proxmox-volume' /api2/json/nodes/euclid/storage/local-zfs/content/local-zfs:vm-9999-pv-torrent-config
tofu import 'module.volumes.module.proxmox-volume["pv-database"].restapi_object.proxmox-volume' /api2/json/nodes/euclid/storage/local-zfs/content/local-zfs:vm-9999-pv-database
tofu import 'module.volumes.module.proxmox-volume["pv-authelia-postgres"].restapi_object.proxmox-volume' /api2/json/nodes/euclid/storage/local-zfs/content/local-zfs:vm-9999-pv-authelia-postgres
tofu import 'module.volumes.module.proxmox-volume["pv-lldap-postgres"].restapi_object.proxmox-volume' /api2/json/nodes/euclid/storage/local-zfs/content/local-zfs:vm-9999-pv-lldap-postgres
tofu import 'module.volumes.module.proxmox-volume["pv-keycloak-postgres"].restapi_object.proxmox-volume' /api2/json/nodes/euclid/storage/local-zfs/content/local-zfs:vm-9999-pv-keycloak-postgres
tofu import 'module.volumes.module.proxmox-volume["pv-jellyfin-config"].restapi_object.proxmox-volume' /api2/json/nodes/euclid/storage/local-zfs/content/local-zfs:vm-9999-pv-jellyfin-config
tofu import 'module.volumes.module.proxmox-volume["pv-netbird-signal"].restapi_object.proxmox-volume' /api2/json/nodes/abel/storage/local-zfs/content/local-zfs:vm-9999-pv-netbird-signal
tofu import 'module.volumes.module.proxmox-volume["pv-netbird-management"].restapi_object.proxmox-volume' /api2/json/nodes/abel/storage/local-zfs/content/local-zfs:vm-9999-pv-netbird-management
tofu import 'module.volumes.module.proxmox-volume["pv-plex"].restapi_object.proxmox-volume' /api2/json/nodes/abel/storage/local-zfs/content/local-zfs:vm-9999-pv-plex
tofu import 'module.volumes.module.proxmox-volume["pv-prometheus"].restapi_object.proxmox-volume' /api2/json/nodes/abel/storage/local-zfs/content/local-zfs:vm-9999-pv-prometheus
```
## import persistent volume
@@ -59,16 +62,18 @@ tofu state rm module.volumes.module.persistent-volume
```
```shell
tofu import 'module.volumes.module.persistent-volume["pv-jellyfin-config"].kubernetes_persistent_volume.pv' pv-jellyfin-config
tofu import 'module.volumes.module.persistent-volume["pv-keycloak"].kubernetes_persistent_volume.pv' pv-keycloak-db
tofu import 'module.volumes.module.persistent-volume["pv-lidarr-config"].kubernetes_persistent_volume.pv' pv-lidarr-config
tofu import 'module.volumes.module.persistent-volume["pv-netbird-management"].kubernetes_persistent_volume.pv' pv-netbird-management
tofu import 'module.volumes.module.persistent-volume["pv-netbird-signal"].kubernetes_persistent_volume.pv' pv-netbird-signal
tofu import 'module.volumes.module.persistent-volume["pv-plex-config"].kubernetes_persistent_volume.pv' pv-plex-config
tofu import 'module.volumes.module.persistent-volume["pv-prometheus"].kubernetes_persistent_volume.pv' pv-prometheus
tofu import 'module.volumes.module.persistent-volume["pv-prowlarr-config"].kubernetes_persistent_volume.pv' pv-prowlarr-config
tofu import 'module.volumes.module.persistent-volume["pv-radarr-config"].kubernetes_persistent_volume.pv' pv-radarr-config
tofu import 'module.volumes.module.persistent-volume["pv-sonarr"].kubernetes_persistent_volume.pv' pv-sonarr
tofu import 'module.volumes.module.persistent-volume["pv-radarr"].kubernetes_persistent_volume.pv' pv-radarr
tofu import 'module.volumes.module.persistent-volume["pv-lidarr"].kubernetes_persistent_volume.pv' pv-lidarr
tofu import 'module.volumes.module.persistent-volume["pv-prowlarr"].kubernetes_persistent_volume.pv' pv-prowlarr
tofu import 'module.volumes.module.persistent-volume["pv-torrent"].kubernetes_persistent_volume.pv' pv-torrent
tofu import 'module.volumes.module.persistent-volume["pv-remark42"].kubernetes_persistent_volume.pv' pv-remark42
tofu import 'module.volumes.module.persistent-volume["pv-sonarr-config"].kubernetes_persistent_volume.pv' pv-sonarr-config
tofu import 'module.volumes.module.persistent-volume["pv-torrent-config"].kubernetes_persistent_volume.pv' pv-torrent-config
tofu import 'module.volumes.module.persistent-volume["pv-authelia-postgres"].kubernetes_persistent_volume.pv' pv-authelia-postgres
tofu import 'module.volumes.module.persistent-volume["pv-lldap-postgres"].kubernetes_persistent_volume.pv' pv-lldap-postgres
tofu import 'module.volumes.module.persistent-volume["pv-keycloak-postgres"].kubernetes_persistent_volume.pv' pv-keycloak-postgres
tofu import 'module.volumes.module.persistent-volume["pv-jellyfin-config"].kubernetes_persistent_volume.pv' pv-jellyfin-config
tofu import 'module.volumes.module.persistent-volume["pv-netbird-signal"].kubernetes_persistent_volume.pv' pv-netbird-signal
tofu import 'module.volumes.module.persistent-volume["pv-netbird-management"].kubernetes_persistent_volume.pv' pv-netbird-management
tofu import 'module.volumes.module.persistent-volume["pv-plex"].kubernetes_persistent_volume.pv' pv-plex
tofu import 'module.volumes.module.persistent-volume["pv-prometheus"].kubernetes_persistent_volume.pv' pv-prometheus
```

View File

@@ -6,7 +6,7 @@ terraform {
}
restapi = {
source = "Mastercard/restapi"
version = ">= 1.12.0"
version = ">= 2.0.0"
}
}
}

View File

@@ -3,11 +3,11 @@ locals {
}
resource "restapi_object" "proxmox-volume" {
path = "/api2/json/nodes/${var.volume.node}/storage/${var.volume.storage}/content/"
path = "/api2/json/nodes/${var.volume.node}/storage/${var.volume.storage}/content"
id_attribute = "data"
force_new = [var.volume.size]
debug = true
data = jsonencode({
vmid = var.volume.vmid
@@ -16,6 +16,17 @@ resource "restapi_object" "proxmox-volume" {
format = var.volume.format
})
// Proxmox returns a different object which we ignore.
// The size is also returned in bytes, not with prefix, e.g. 1G, 512Mi.
// Setting to false (default) triggers a change each run
ignore_all_server_changes = true
// Providing a supported parameter that doesn't do anything.
// Supplying either `null` or an empty object makes this fall back to the `data` object.
update_data = jsonencode({
node = var.volume.node
})
lifecycle {
prevent_destroy = false
}

View File

@@ -2,7 +2,7 @@ terraform {
required_providers {
restapi = {
source = "Mastercard/restapi"
version = ">= 1.19.1"
version = ">= 2.0.0"
}
}
}

View File

@@ -14,7 +14,7 @@ terraform {
}
restapi = {
source = "Mastercard/restapi"
version = "1.20.0"
version = "2.0.1"
}
}
}