mirror of
https://gitea.fenix-dev.com/fenix-gitea-admin/iac-opentofu-private.git
synced 2025-10-27 15:53:06 +00:00
Merge pull request 'fenix-admin' (#59) from fenix-admin into main
Reviewed-on: fenix-gitea-admin/iac-teste#59
This commit is contained in:
25
proxmox.tf
25
proxmox.tf
@ -6,18 +6,23 @@ provider "proxmox" {
|
|||||||
username = "terraform"
|
username = "terraform"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resource "proxmox_virtual_environment_download_file" "Fedora-iso" {
|
|
||||||
content_type = "import"
|
resource "null_resource" "download_image" {
|
||||||
datastore_id = "local"
|
provisioner "local-exec" {
|
||||||
file_name = "debian-12-generic-amd64-20231228-1609.qcow2"
|
command = <<EOT
|
||||||
node_name = "fenix"
|
mkdir -p ./images
|
||||||
url = "https://cloud.debian.org/images/cloud/bookworm/20231228-1609/debian-12-generic-amd64-20231228-1609.qcow2"
|
if [ ! -f ${var.local_image_path} ]; then
|
||||||
checksum = "d2fbcf11fb28795842e91364d8c7b69f1870db09ff299eb94e4fbbfa510eb78d141e74c1f4bf6dfa0b7e33d0c3b66e6751886feadb4e9916f778bab1776bdf1b"
|
echo "Downloading image from ${var.image_source_url}..."
|
||||||
checksum_algorithm = "sha512"
|
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" {
|
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"
|
name = "proxmox-kubernetes-VM-template"
|
||||||
node_name = "fenix"
|
node_name = "fenix"
|
||||||
vm_id = 1002
|
vm_id = 1002
|
||||||
@ -50,7 +55,7 @@ resource "proxmox_virtual_environment_vm" "proxmox-kubernetes-VM-template" {
|
|||||||
disk {
|
disk {
|
||||||
datastore_id = "local-lvm"
|
datastore_id = "local-lvm"
|
||||||
interface = "scsii"
|
interface = "scsii"
|
||||||
file_id = proxmox_virtual_environment_download_file.Fedora-iso.id
|
file = "./images/ubuntu-bionic.img"
|
||||||
size = 20
|
size = 20
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,4 +8,20 @@ variable "proxmox_apikey" {
|
|||||||
description = "Proxmox server api key"
|
description = "Proxmox server api key"
|
||||||
type = string
|
type = string
|
||||||
sensitive = false
|
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"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user