Compare commits

...

2 Commits

Author SHA1 Message Date
753d5c38e4 add package upgrades and output of VM IP 2025-03-21 21:57:26 +00:00
a39d0ceacb use env file for cloud-init 2025-03-21 21:09:50 +00:00
3 changed files with 52 additions and 64 deletions

View File

@ -5,95 +5,83 @@ data "proxmox_virtual_environment_vms" "template" {
} }
} }
# resource "proxmox_virtual_environment_file" "cloud_config" { resource "proxmox_virtual_environment_file" "cloud_config" {
# content_type = "snippets" content_type = "snippets"
# datastore_id = "local" datastore_id = "local"
# node_name = "zenith" node_name = "zenith"
source_raw {
# source_raw { file_name = "simple_vm.cloud-config.yaml"
# data = <<-EOF data = <<-EOF
# #cloud-config #cloud-config
# hostname: simple-vm hostname: simple-vm
# packages: package_update: true
# - qemu-guest-agent package_upgrade: true
# users: packages:
# - default - qemu-guest-agent
# - name: vez users:
# groups: sudo - default
# shell: /bin/bash - name: vez
# ssh-authorized-keys: groups: sudo
# - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICxWxrBF6W6N2ZrzoKhTwDTZ49tlYzvki+4naHjo8DhB vez-key" shell: /bin/bash
# sudo: ALL=(ALL) NOPASSWD:ALL ssh-authorized-keys:
# EOF - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID62LmYRu1rDUha3timAIcA39LtcIOny1iAgFLnxoBxm vez@bastion"
sudo: ALL=(ALL) NOPASSWD:ALL
# file_name = "example.cloud-config.yaml" runcmd:
# } - systemctl enable qemu-guest-agent
# } - reboot
EOF
}
}
resource "proxmox_virtual_environment_vm" "simple_vm" { resource "proxmox_virtual_environment_vm" "simple_vm" {
name = "simple-vm" name = "simple-vm"
node_name = "zenith" node_name = "zenith"
tags = ["test"] tags = ["test"]
agent { agent {
enabled = false enabled = true
} }
# if agent is not enabled, the VM may not be able to shutdown properly, and may need to be forced off
stop_on_destroy = true stop_on_destroy = true
clone { clone {
vm_id = data.proxmox_virtual_environment_vms.template.vms[0].vm_id vm_id = data.proxmox_virtual_environment_vms.template.vms[0].vm_id
} }
bios = "ovmf" bios = "ovmf"
machine = "q35" machine = "q35"
cpu { cpu {
cores = 2 cores = 2
type = "host" type = "host"
} }
memory { memory {
dedicated = 2048 dedicated = 2048
} }
disk { disk {
datastore_id = "ceph-workload" datastore_id = "ceph-workload"
#file_id = proxmox_virtual_environment_download_file.latest_ubuntu_22_jammy_qcow2_img.id
interface = "scsi0" interface = "scsi0"
size = 4 size = 4
} }
initialization { initialization {
user_data_file_id = proxmox_virtual_environment_file.cloud_config.id
datastore_id = "ceph-workload" datastore_id = "ceph-workload"
interface = "scsi1" interface = "scsi1"
ip_config { ip_config {
ipv4 { ipv4 {
address = "dhcp" address = "dhcp"
} }
} }
user_account {
keys = ["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID62LmYRu1rDUha3timAIcA39LtcIOny1iAgFLnxoBxm vez@bastion"]
username = "vez"
} }
#user_data_file_id = proxmox_virtual_environment_file.cloud_config.id
}
network_device { network_device {
bridge = "vmbr0" bridge = "vmbr0"
vlan_id = 66 vlan_id = 66
} }
operating_system { operating_system {
type = "l26" type = "l26"
} }
vga { vga {
type = "std" type = "std"
} }
} }
output "vm_ip" {
value = proxmox_virtual_environment_vm.simple_vm.ipv4_addresses[1][0]
description = "VM IP"
}