Merge pull request 'fenix-admin' (#59) from fenix-admin into main

Reviewed-on: fenix-gitea-admin/iac-teste#59
This commit is contained in:
2025-08-20 22:03:53 +00:00
2 changed files with 31 additions and 10 deletions

View File

@ -6,18 +6,23 @@ provider "proxmox" {
username = "terraform"
}
}
resource "proxmox_virtual_environment_download_file" "Fedora-iso" {
content_type = "import"
datastore_id = "local"
file_name = "debian-12-generic-amd64-20231228-1609.qcow2"
node_name = "fenix"
url = "https://cloud.debian.org/images/cloud/bookworm/20231228-1609/debian-12-generic-amd64-20231228-1609.qcow2"
checksum = "d2fbcf11fb28795842e91364d8c7b69f1870db09ff299eb94e4fbbfa510eb78d141e74c1f4bf6dfa0b7e33d0c3b66e6751886feadb4e9916f778bab1776bdf1b"
checksum_algorithm = "sha512"
resource "null_resource" "download_image" {
provisioner "local-exec" {
command = <<EOT
mkdir -p ./images
if [ ! -f ${var.local_image_path} ]; then
echo "Downloading image from ${var.image_source_url}..."
curl -L -o ${var.local_image_path} ${var.image_source_url}
else
echo "Image already exists: ${var.local_image_path}"
fi
EOT
}
}
resource "proxmox_virtual_environment_vm" "proxmox-kubernetes-VM-template" {
depends_on = [proxmox_virtual_environment_download_file.Fedora-iso]
depends_on = [null_resource.download_image]
name = "proxmox-kubernetes-VM-template"
node_name = "fenix"
vm_id = 1002
@ -50,7 +55,7 @@ resource "proxmox_virtual_environment_vm" "proxmox-kubernetes-VM-template" {
disk {
datastore_id = "local-lvm"
interface = "scsii"
file_id = proxmox_virtual_environment_download_file.Fedora-iso.id
file = "./images/ubuntu-bionic.img"
size = 20
}

View File

@ -9,3 +9,19 @@ variable "proxmox_apikey" {
type = string
sensitive = false
}
variable "image_source_url" {
default = "https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img"
}
variable "local_image_path" {
default = "./images/ubuntu-bionic.img"
}
variable "node_name" {
default = "fenix"
}
variable "datastore_id" {
default = "local-lvm"
}