This example demonstrates how you would deploy a Virtual Machine with multiple network adapters using an Ubuntu Cloudinit template.
Network Adapter net0
is set to DHCP.
Network Adapter net1
has a static IP assigned.
Network Adapter net2
has a static IP assigned, different network bridge, and has a tagged VLAN.
NOTE: If your Virtual Machine template does NOT have the Cloudinit drive set to ide2
, the Terraform provider may fail to provision your Virtual Machine.
Example 1: Using token and secret
# Using API Token & Secret example:
export PM_API_URL="https://pve1.yourdomain.com:8006/api2/json"
export PM_API_TOKEN_ID="svc-acc-terraform@pam!svc-acc-token-id"
export PM_API_TOKEN_SECRET="12341234-1234-1234-1234-123412341234"
Example 2: Using username and password
# Using username and password example:
export PM_API_URL="https://pve1.yourdomain.com:8006/api2/json"
export PM_USER="svc-acc-terraform@pam"
export PM_PASS="proxmox_account_password"
Rename terraform.tfvars.example
to terraform.tfvars
. Once renamed, modify the three variables within the file to match your environment.
I've pre-configured a few network adapters residing in locals.tf
. Feel free to mess around with the IP Addressing for each of the Network Adapters to understand the syntax.
Run the following commands to deploy said Virtual Machine
terraform init
terraform plan
terraform apply
Name | Version |
---|---|
terraform | >=1.3.0 |
proxmox | 2.9.14 |
No providers.
Name | Source | Version |
---|---|---|
multi_nic | ../../ | n/a |
No resources.
Name | Description | Type | Default | Required |
---|---|---|---|---|
clone | The base VM from which to clone to create the new VM. Note that clone is mutually exclussive with pxe and iso modes. | string |
n/a | yes |
storage_location | The storage location where your Virtual Machine will reside. | string |
n/a | yes |
target_node | The name of the Proxmox Node on which to place the VM. | string |
n/a | yes |
Name | Description |
---|---|
disks | The Disk(s) affiliated with said Virtual Machine. |
ip | The Virtual Machine's IP on the first Network Adapter. |
name | The Virtual Machine's name. |
nics | The Network Adapter(s) affiliated with said Virtual Machine. |
node | The Proxmox Node the Virtual Machine was created on. |
ssh | The Virtual Machine's SSH Settings. |
template | The name of the template in which the Virtual Machine was created on. |
vmid | The Virtual Machine's Id. |