Merge pull request '#cloud-init' (#206) from fenix-admin into main

Reviewed-on: fenix-gitea-admin/iac-teste#206
This commit is contained in:
2025-08-28 16:58:44 +00:00
3 changed files with 34 additions and 58 deletions

View File

@ -1,5 +1,10 @@
hostname: test-ubuntu locale: "pt_PT.UTF-8"
timezone: America/Toronto keyboard:
layout: "pt"
variant: "nodeadkeys"
users:
- default
ssh_pwauth: true ssh_pwauth: true

View File

@ -0,0 +1,2 @@
#cloud-config
${content}

View File

@ -79,7 +79,9 @@ resource "proxmox_virtual_environment_file" "vm_user_data" {
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 = data.external.merged_yaml[each.key].result["merged_yaml"] data = templatefile("${path.module}/cloud-init-wrapper.yaml.tpl", {
content = data.external.merged_yaml[each.key].result["merged_yaml"]
})
} }
} }
@ -109,13 +111,6 @@ resource "proxmox_virtual_environment_vm" "proxmox-kubernetes-VM-template" {
dedicated = 4096 dedicated = 4096
} }
# Configuração do disco rígido
#disk {
# datastore_id = "local-lvm"
# interface = "scsi1"
# size = 64
#}
disk { disk {
datastore_id = "local-lvm" datastore_id = "local-lvm"
file_id = proxmox_virtual_environment_download_file.latest_ubunto_cloud_img.id file_id = proxmox_virtual_environment_download_file.latest_ubunto_cloud_img.id
@ -128,17 +123,17 @@ resource "proxmox_virtual_environment_vm" "proxmox-kubernetes-VM-template" {
bridge = "vmbr0" bridge = "vmbr0"
} }
#initialization { initialization {
# dns { dns {
# servers = ["1.1.1.1"] servers = ["1.1.1.1"]
# } }
# ip_config { ip_config {
# ipv4 { ipv4 {
# address = "dhcp" address = "dhcp"
# } }
# } }
#user_data_file_id = proxmox_virtual_environment_file.cloud_init_yaml.id user_data_file_id = proxmox_virtual_environment_file.cloud_init_yaml.id
# } }
} }
@ -149,12 +144,6 @@ resource "proxmox_virtual_environment_vm" "k8s_vms" {
node_name = each.value.node_name node_name = each.value.node_name
vm_id = each.value.vm_id vm_id = each.value.vm_id
started = false
tags = ["opentofu", "kubernetes", "fedora"]
machine = "q35"
bios = "seabios"
description = "kubernetes VM Template created via iac"
cpu { cpu {
cores = each.value.cores cores = each.value.cores
} }
@ -169,38 +158,18 @@ resource "proxmox_virtual_environment_vm" "k8s_vms" {
interface = "scsi1" interface = "scsi1"
} }
initialization {
initialization { ip_config {
dns { ipv4 {
servers = ["1.1.1.1"] address = each.value.ip
} gateway = each.value.gateway
ip_config { }
ipv4 {
address = "dhcp"
} }
user_data_file_id = proxmox_virtual_environment_file.vm_user_data[each.key].id
} }
# ip_config {
# ipv4 {
# address = each.value.ip
# gateway = each.value.gateway
# }
# }
user_data_file_id = proxmox_virtual_environment_file.vm_user_data[each.key].id agent {
enabled = true
}
} }
disk {
datastore_id = "local-lvm"
file_id = proxmox_virtual_environment_download_file.latest_ubunto_cloud_img.id
interface = "scsi0"
file_format = "qcow2"
}
# Configuração da interface de rede
network_device {
bridge = "vmbr0"
}
agent {
enabled = true
}
}