@@ -4,13 +4,21 @@ terraform {
44 source = " bpg/proxmox"
55 version = " 0.43.2"
66 }
7+ random = {
8+ source = " hashicorp/random"
9+ version = " 3.6.0"
10+ }
711 }
812}
13+
14+ resource "random_uuid" "name_suffix" {}
15+
916locals {
10- container_template_file_insecure = can (regex (" ^https:\\ /\\ /.*" , var. container_template_file )) ? " false" : " true"
11- container_template_file_download = (can (regex (" ^https?:\\ /\\ /.*" , var. container_template_file )) && var. migrate_template_file == true ) ? 1 : 0
12- container_template_file_local = (local. container_template_file_download == 0 || var. migrate_template_file == false ) ? 1 : 0
13- container_template = (local. container_template_file_download == 1 && var. migrate_template_file == true ) ? proxmox_virtual_environment_download_file. container_template [0 ]. id : proxmox_virtual_environment_file. container_template [0 ]. id
17+ container_template_file_insecure = can (regex (" ^https:\\ /\\ /.*" , var. container_template_file )) ? " false" : " true"
18+ container_template_file_download = (can (regex (" ^https?:\\ /\\ /.*" , var. container_template_file )) && var. migrate_template_file == true ) ? 1 : 0
19+ container_template_file_download_name = local. container_template_file_download == 1 ? format (" %s-%s" , random_uuid. name_suffix . result , join (" " , regex (" ^https?:\\ /\\ /.*\\ /.*?\\ /?(.*)" , var. container_template_file ))) : null
20+ container_template_file_local = (local. container_template_file_download == 0 || var. migrate_template_file == false ) ? 1 : 0
21+ container_template = (local. container_template_file_download == 1 && var. migrate_template_file == true ) ? proxmox_virtual_environment_download_file. container_template [0 ]. id : proxmox_virtual_environment_file. container_template [0 ]. id
1422}
1523
1624resource "proxmox_virtual_environment_container" "proxmox_lxc" {
@@ -61,6 +69,7 @@ resource "proxmox_virtual_environment_file" "container_template" {
6169
6270resource "proxmox_virtual_environment_download_file" "container_template" {
6371 count = local. container_template_file_download
72+ file_name = local. container_template_file_download_name
6473 content_type = " vztmpl"
6574 datastore_id = " local"
6675 node_name = var. node_name
0 commit comments