mirror of
https://gitea.fenix-dev.com/fenix-gitea-admin/iac-opentofu-private.git
synced 2025-10-27 15:53:06 +00:00
Update proxmox.tf
This commit is contained in:
52
proxmox.tf
52
proxmox.tf
@ -6,6 +6,42 @@ provider "proxmox" {
|
||||
username = "terraform"
|
||||
}
|
||||
}
|
||||
resource "proxmox_virtual_environment_download_file" "fedora_cloud_image" {
|
||||
content_type = "iso"
|
||||
datastore_id = "local"
|
||||
node_name = "fedora"
|
||||
url = "https://dl.fedoraproject.org/pub/fedora/linux/releases/41/Cloud/x86_64/images/Fedora-Cloud-Base-Generic-41-1.4-x86_64.qcow2"
|
||||
file_name = "Fedora-Cloud-Base-41.qcow2.img"
|
||||
}
|
||||
|
||||
resource "proxmox_virtual_environment_file" "fedora_user_data" {
|
||||
content_type = "snippets"
|
||||
datastore_id = "local-snippets" # outro storage configurado com Snippets
|
||||
node_name = "pve"
|
||||
|
||||
source_raw {
|
||||
data = <<-EOF
|
||||
#cloud-config
|
||||
hostname: fedora-template
|
||||
users:
|
||||
- name: meuuser
|
||||
ssh_pwauth: true
|
||||
sudo: ALL=(ALL) NOPASSWD:ALL
|
||||
chpasswd:
|
||||
list: |
|
||||
root:SenhaRoot123
|
||||
meuuser:SenhaUser123
|
||||
expire: False
|
||||
package_update: true
|
||||
packages:
|
||||
- qemu-guest-agent
|
||||
runcmd:
|
||||
- systemctl enable qemu-guest-agent
|
||||
- systemctl start qemu-guest-agent
|
||||
EOF
|
||||
file_name = "fedora-cloud-init.yaml"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
resource "proxmox_virtual_environment_vm" "proxmox-kubernetes-VM-template" {
|
||||
@ -40,12 +76,13 @@ resource "proxmox_virtual_environment_vm" "proxmox-kubernetes-VM-template" {
|
||||
}
|
||||
|
||||
disk {
|
||||
datastore_id = "local-lvm"
|
||||
interface = "scsii"
|
||||
file_id = "local-lvm:iso/ubuntu-cloud.img"
|
||||
size = 20
|
||||
datastore_id = "local-lvm" # armazenamento para disco da VM
|
||||
file_id = proxmox_virtual_environment_download_file.fedora_cloud_image.id
|
||||
interface = "scsi1"
|
||||
size = 10
|
||||
iothread = true
|
||||
discard = "on"
|
||||
}
|
||||
|
||||
# Configuração da interface de rede
|
||||
network_device {
|
||||
bridge = "vmbr0"
|
||||
@ -59,10 +96,7 @@ initialization {
|
||||
gateway = "192.168.1.1" # Gateway da rede
|
||||
}
|
||||
}
|
||||
user_account {
|
||||
password = "passexemplo"
|
||||
username = "userexemplo"
|
||||
}
|
||||
user_data_file_id = proxmox_virtual_environment_file.fedora_user_data.id
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user