mirror of
https://gitea.fenix-dev.com/fenix-gitea-admin/iac-opentofu-private.git
synced 2025-10-27 15:53:06 +00:00
python
This commit is contained in:
31
proxmox.tf
31
proxmox.tf
@ -35,6 +35,15 @@ resource "proxmox_virtual_environment_file" "cloud_init_yaml" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
data "external" "merged_yaml" {
|
||||||
|
program = ["python3", "${path.module}/merge_yaml.py"]
|
||||||
|
|
||||||
|
query = {
|
||||||
|
file1 = "${path.module}/cloud-init-base.yaml"
|
||||||
|
file2 = "${path.module}/cloud-init-extra.yaml"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Gerar um snippet cloud-init por VM
|
# Gerar um snippet cloud-init por VM
|
||||||
resource "proxmox_virtual_environment_file" "vm_user_data" {
|
resource "proxmox_virtual_environment_file" "vm_user_data" {
|
||||||
@ -43,30 +52,10 @@ resource "proxmox_virtual_environment_file" "vm_user_data" {
|
|||||||
node_name = "fenix"
|
node_name = "fenix"
|
||||||
datastore_id = "local-snippets"
|
datastore_id = "local-snippets"
|
||||||
content_type = "snippets"
|
content_type = "snippets"
|
||||||
|
|
||||||
source_raw {
|
source_raw {
|
||||||
file_name = "cloud-init-iac-k8s-${each.key}.yaml"
|
file_name = "cloud-init-iac-k8s-${each.key}.yaml"
|
||||||
data = yamlencode(
|
data = data.external.merged_yaml.result["merged_yaml"]
|
||||||
merge(
|
|
||||||
yamldecode(file("${path.module}/cloud-init-base.yaml")),
|
|
||||||
{
|
|
||||||
packages = concat(
|
|
||||||
try(yamldecode(file("${path.module}/cloud-init-base.yaml")).packages, []),
|
|
||||||
try(each.value.extra_packages, [])
|
|
||||||
),
|
|
||||||
users = concat(
|
|
||||||
try(yamldecode(file("${path.module}/cloud-init-base.yaml")).users, []),
|
|
||||||
try(each.value.extra_users, [])
|
|
||||||
),
|
|
||||||
runcmd = concat(
|
|
||||||
try(yamldecode(file("${path.module}/cloud-init-base.yaml")).runcmd, []),
|
|
||||||
try(each.value.extra_runcmd, [])
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user