Project

General

Profile

Task #50

Updated by Frank Refol 5 months ago

An Ubuntu virtual machine is currently being provisioned using a pure Ansible playbook and using a virtual machine template in Proxmox. Convert this so that it uses Terraform or OpenTofu instead. 

 https://www.youtube.com/watch?v=Rey7LdSdjJY 

 ## HCL File Example 

 Here is an example of a Terraform configuration file (HCL), 

 ``` yaml 
 provider "proxmox" { 
   pm_api_url        = "https://your-proxmox-server:8006/api2/json" 
   pm_user           = "root@pam" 
   pm_password       = "your-password" 
   pm_tls_insecure = true    # Set to false if using valid TLS 
 } 

 resource "proxmox_vm_qemu" "vm" { 
   name          = "terraform-vm" 
   target_node = "proxmox-node" 

   clone        = "template-name"    # Replace with your Proxmox VM template name 
   vmid         = 100 
   cores        = 2 
   memory       = 4096 
   sockets      = 1 
   disk { 
     storage = "local-lvm" 
     size      = "50G" 
   } 

   network { 
     model    = "virtio" 
     bridge = "vmbr0" 
   } 

   agent = 1 
 } 

 ``` 

 ## Providers 

 BPG  

 https://search.opentofu.org/provider/bpg/proxmox/latest 
 https://registry.terraform.io/providers/bpg/proxmox/latest/docs#example-usage 

 Telmate 

 https://search.opentofu.org/provider/telmate/proxmox/latest 

Back