forked from fediversity/fediversity
55 lines
1.1 KiB
HCL
55 lines
1.1 KiB
HCL
terraform {
|
|
required_providers {
|
|
proxmox = {
|
|
source = "bpg/proxmox"
|
|
version = "= 0.81.0"
|
|
}
|
|
}
|
|
backend "http" {
|
|
}
|
|
}
|
|
|
|
locals {
|
|
dump_name = "qemu-nixos-fediversity-${var.category}.qcow2"
|
|
}
|
|
|
|
# https://registry.terraform.io/providers/bpg/proxmox/latest/docs
|
|
provider "proxmox" {
|
|
endpoint = "https://${var.host}:8006/"
|
|
|
|
# used for upload
|
|
ssh {
|
|
agent = true
|
|
username = "root"
|
|
}
|
|
}
|
|
|
|
# hash of our code directory, used to trigger re-deploy
|
|
# FIXME calculate separately to reduce false positives
|
|
data "external" "hash" {
|
|
program = ["sh", "-c", "echo \"{\\\"hash\\\":\\\"$(nix-hash ../../..)\\\"}\""]
|
|
}
|
|
|
|
resource "proxmox_virtual_environment_file" "upload" {
|
|
depends_on = [
|
|
data.external.hash,
|
|
]
|
|
content_type = "import"
|
|
datastore_id = var.image_datastore_id
|
|
node_name = var.node_name
|
|
overwrite = true
|
|
timeout_upload = 500
|
|
|
|
source_file {
|
|
path = var.image
|
|
file_name = local.dump_name
|
|
checksum = var.checksum
|
|
}
|
|
}
|
|
|
|
output "id" {
|
|
value = proxmox_virtual_environment_file.upload.id
|
|
}
|
|
output "path" {
|
|
value = proxmox_virtual_environment_file.upload.source_file[0].file_name
|
|
}
|