Skip to content

karkcoder/proxmox-terraform-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

This Terraform code is used to provision a virtual machine (VM) on a Proxmox server. Let's break down the code and understand what each section does:

  1. The terraform block specifies the required provider for this configuration. In this case, it requires the "proxmox" provider, which is sourced from the "telmate/proxmox" repository and requires a version greater than or equal to 2.9.14.

  2. The provider block configures the Proxmox provider. It specifies the API URL, token ID, token secret, and enables insecure TLS connections (pm_tls_insecure = true).

  3. The resource block defines a Proxmox QEMU VM resource named "test_server". This block represents the VM that will be created on the Proxmox server.

    • The define_connection_info attribute is set to false, which means that Terraform will not create connection information for this VM. It's useful when you don't need SSH or other connection details managed by Terraform.

    • The agent attribute is set to 1, indicating that the guest agent should be enabled for this VM.

    • The count attribute is set to 1, meaning that only one instance of this VM will be created. If you set it to 0 and apply the configuration, it will destroy the existing VM.

    • The name attribute sets the name of the VM using an interpolated string. The ${count.index + 1} expression is used to generate a unique name by adding 1 to the index of the VM. For example, the first VM will be named "test-vm-1".

    • The target_node attribute specifies the Proxmox host where the VM will be created.

    • The iso attribute specifies the path to an ISO file that will be used to install the operating system on the VM. In this case, it references an Ubuntu 22.04.1 Live Server ISO file located at "local:iso/ubuntu-22.04.1-live-server-amd64.iso".

    • Various other attributes configure the VM's resources and settings, such as CPU, memory, disk, and network configurations.

    • The lifecycle block specifies that certain changes, specifically to the network and vmid attributes, should be ignored during updates. This means that if you modify these attributes after the initial creation, Terraform will not attempt to modify the existing VM.

In summary, this Terraform code provisions a Proxmox VM named "test_server" with specific resource and configuration settings, such as CPU, memory, disk, and network.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages