|
1 | 1 | locals { |
2 | 2 |
|
3 | | - # Adjust the Virtual Machine's specs here |
4 | | - memory = 1024 |
5 | | - cores = 1 |
| 3 | + # Automatically reboot the VM when parameter changes require this. If disabled the provider will emit a warning when the VM needs to be rebooted. |
| 4 | + automatic_reboot = true |
6 | 5 |
|
7 | | - # Cloudinit Settings |
| 6 | + # Override the default cloud-init user's password. Sensitive. |
| 7 | + cipassword = "my_password" |
| 8 | + |
| 9 | + # Override the default cloud-init user for provisioning. |
8 | 10 | ciuser = "my_username" |
9 | | - # See the homepage README.md on how to add SSH Keys. |
10 | | - sshkeys = "" |
| 11 | + |
| 12 | + # The base VM from which to clone to create the new VM. Note that clone is mutually exclussive with pxe and iso modes. |
| 13 | + clone = var.clone |
| 14 | + |
| 15 | + # The number of CPU cores per CPU socket to allocate to the VM. |
| 16 | + cores = 1 |
| 17 | + |
| 18 | + # The type of CPU to emulate in the Guest. See the docs about CPU Types for more info. ('host' allows you to virtualize on said VM) |
| 19 | + cpu = "host" |
| 20 | + |
| 21 | + # Controls if virtual machine should be created. |
| 22 | + create_vm = true |
| 23 | + |
| 24 | + # The description of the VM. Shows as the 'Notes' field in the Proxmox GUI. |
| 25 | + description = "Virtual Machine's description" |
11 | 26 |
|
12 | 27 | /* |
13 | | - Disk Configurations |
14 | | -
|
15 | | - Create 2 Disks |
16 | | - Disk 1 (virtio0): |
17 | | - - Set type to 'virtio' |
18 | | - - Set storage_location_1 variable in terraform.tfvars |
19 | | - - Set size to 10G |
20 | | - Disk 2 (scsi0): |
21 | | - - Set type to 'scsi' |
22 | | - - Set storage_location_2 variable in terraform.tfvars |
23 | | - - Set size to 25G |
24 | | - - Enable writethrough cache |
25 | | - */ |
26 | | - # Set the disk locations in terraform.tfvars |
27 | | - storage_location_1 = var.storage_location_1 |
28 | | - storage_location_2 = var.storage_location_2 |
| 28 | + Disk Configuration |
29 | 29 |
|
| 30 | + type - The type of disk device to add. Options: ide, sata, scsi, virtio. |
| 31 | + storage - The name of the storage pool on which to store the disk. |
| 32 | + size - The size of the created disk, format must match the regex \d+[GMK], where G, M, and K represent Gigabytes, Megabytes, and Kilobytes respectively. |
| 33 | + format - The drive’s backing file’s data format. |
| 34 | + cache - The drive’s cache mode. Options: directsync, none, unsafe, writeback, writethrough |
| 35 | + backup - Whether the drive should be included when making backups. |
| 36 | + iothread - Whether to use iothreads for this drive. Only effective with a disk of type virtio, or scsi when the the emulated controller type (scsihw top level block argument) is virtio-scsi-single. |
| 37 | + replicate - Whether the drive should considered for replication jobs. |
| 38 | + discard - Controls whether to pass discard/trim requests to the underlying storage. Only effective when the underlying storage supports thin provisioning. |
| 39 | + mbps - Maximum r/w speed in megabytes per second. 0 means unlimited. |
| 40 | + mbps_rd - Maximum read speed in megabytes per second. 0 means unlimited. |
| 41 | + mbps_rd_max - Maximum read speed in megabytes per second. 0 means unlimited. |
| 42 | + mbps_wr - Maximum write speed in megabytes per second. 0 means unlimited. |
| 43 | + mbps_wr_max - Maximum throttled write pool in megabytes per second. 0 means unlimited. |
| 44 | + media - The drive’s media type. Options: cdrom, disk. |
| 45 | + iops - Maximum r/w I/O in operations per second. |
| 46 | + iops_rd - Maximum read I/O in operations per second. |
| 47 | + iops_rd_max - Maximum unthrottled read I/O pool in operations per second. |
| 48 | + iops_rd_max_length - Maximum length of read I/O bursts in seconds. |
| 49 | + iops_wr - Maximum write I/O in operations per second. |
| 50 | + iops_wr_max - Maximum unthrottled write I/O pool in operations per second. |
| 51 | + iops_wr_max_length - Maximum length of write I/O bursts in seconds. |
| 52 | + |
| 53 | + */ |
30 | 54 | disks = [ |
31 | | - # This will create disk virtio0 |
32 | 55 | { |
33 | | - type = "virtio" |
34 | | - storage = local.storage_location_1 |
35 | | - size = "10G" |
36 | | - }, |
37 | | - # This will create disk scsi0 with writethrough cache enabled |
38 | | - { |
39 | | - type = "scsi" |
40 | | - storage = local.storage_location_2 |
41 | | - size = "25G" |
42 | | - cache = "writethrough" |
| 56 | + type = "virtio" |
| 57 | + storage = var.storage_location |
| 58 | + size = "10G" |
| 59 | + format = "raw" |
| 60 | + cache = "writeback" |
| 61 | + backup = true |
| 62 | + iothread = 0 |
| 63 | + replicate = 0 |
| 64 | + discard = 0 |
| 65 | + mbps = 0 |
| 66 | + mbps_rd = 0 |
| 67 | + mbps_rd_max = 0 |
| 68 | + mbps_wr = 0 |
| 69 | + mbps_wr_max = 0 |
| 70 | + media = "disk" |
| 71 | + iops = 0 |
| 72 | + iops_rd = 0 |
| 73 | + iops_rd_max = 0 |
| 74 | + iops_rd_max_length = 0 |
| 75 | + iops_wr = 0 |
| 76 | + iops_wr_max = 0 |
| 77 | + iops_wr_max_length = 0 |
43 | 78 | } |
44 | 79 | ] |
45 | 80 |
|
| 81 | + # If false, and a vm of the same name, on the same node exists, terraform will attempt to reconfigure that VM with these settings. |
| 82 | + # Set to true to always create a new VM (note, the name of the VM must still be unique, otherwise an error will be produced.). |
| 83 | + force_create = false |
| 84 | + /* |
| 85 | + If the value of this string changes, the VM will be recreated. Useful for allowing this resource to be recreated when arbitrary attributes change. |
| 86 | + An example where this is useful is a cloudinit configuration (as the cicustom attribute points to a file not the content). |
| 87 | +
|
| 88 | + force_recreate_on_change_of = data.template_file.cicustom.rendered |
| 89 | + */ |
| 90 | + force_recreate_on_change_of = "" |
| 91 | + |
| 92 | + /* |
| 93 | + hagroup - The HA group identifier the resource belongs to (requires hastate to be set!). |
| 94 | + hastate - Requested HA state for the resource. One of 'started', 'stopped', 'enabled', 'disabled', or 'ignored'. See the docs about HA for more info. |
| 95 | +
|
| 96 | + hagroup = "my_resource_group" |
| 97 | + hastate = enabled |
| 98 | + */ |
| 99 | + hagroup = "" |
| 100 | + hastate = "" |
| 101 | + |
| 102 | + /* |
| 103 | + Comma delimited list of hotplug features to enable. Options: network, disk, cpu, memory, usb. Set to 0 to disable hotplug. |
| 104 | +
|
| 105 | + To add memory into hotplug, you would set the variable to: |
| 106 | + hotplug = "cpu,memory,network,disk,usb" |
| 107 | + */ |
| 108 | + hotplug = "cpu,network,disk,usb" |
| 109 | + |
| 110 | + # The amount of memory to allocate to the VM in Megabytes. |
| 111 | + memory = 2048 |
| 112 | + |
| 113 | + # Sets default DNS server for guest. |
| 114 | + nameserver = "example.com" |
46 | 115 |
|
47 | 116 | /* |
48 | | - Create 3 Network Adapters |
49 | | - - All adapters will be assigned model `virtio` and point to network bridge `vmbr0`. |
50 | | - However, you can adjust these values as needed. |
51 | | - - Network Adapter 1 (net0) - Set to DHCP |
52 | | - - Network Adapter 2 (net1) - IP: 192.168.2.58/24 with gateway of 192.168.2.1 |
53 | | - - Network Adapter 3 (net2) - Set to DHCP |
| 117 | + Network Adapter Configurations |
| 118 | +
|
| 119 | + bridge - Bridge to which the network device should be attached. The Proxmox VE standard bridge is called vmbr0. |
| 120 | + model - Network Card Model. The virtio model provides the best performance with very low CPU overhead. If your VM does not support it, next best option is e1000 |
| 121 | + gateway - The IPv4 Gateway of the Virtual Machine. Does NOT need to be in CIDR-notation (e.g., this will work: 192.168.1.1) |
| 122 | + gateway6 - The IPv6 Gateway of the Virtual Machine. Does NOT need to be in CIDR-notation. |
| 123 | + ip - The IPv4 Address of the Virtual Machine. MUST be in CIDR-notation (e.g., 192.168.1.123/24) |
| 124 | + ip6 - The IPv6 Address of the Virtual Machine. MUST be in CIDR-notation. |
| 125 | + dhcp - Set dhcp to true to enable dhcp for IPv4 Addresses. This will override static IP assignments. |
| 126 | + dhcp6 - Set dhcp6 to true to enable dhcp for IPv6 Addresses. This will override static IP assignments. |
| 127 | + firewall - Whether to enable the Proxmox firewall on this network device. |
| 128 | + link_down - Whether this interface should be disconnected (like pulling the plug). |
| 129 | + macaddr - Override the randomly generated MAC Address for the VM. Requires the MAC Address be Unicast. |
| 130 | + queues - Number of packet queues to be used on the device. Requires virtio model to have an effect. |
| 131 | + rate - Network device rate limit in mbps (megabytes per second) as floating point number. Set to 0 to disable rate limiting. |
| 132 | + vlan_tag - The VLAN tag to apply to packets on this device. -1 disables VLAN tagging. |
54 | 133 | */ |
55 | | - # Network Adapter net0 IP Configuration |
56 | | - network_adapter_1 = { |
57 | | - dhcp = true |
58 | | - } |
59 | | - network_model_1 = "virtio" |
60 | | - network_bridge_1 = "vmbr0" |
61 | | - |
62 | | - # Network Adapter net1 IP Configuration |
63 | | - network_adapter_2 = { |
64 | | - # By default, DHCP is set to False if it isn't provided |
65 | | - ip = "192.168.2.58/24" |
66 | | - gateway = "192.168.2.1" |
67 | | - } |
68 | | - network_model_2 = "virtio" |
69 | | - network_bridge_2 = "vmbr0" |
70 | | - |
71 | | - # Network Adapter net2 IP Configuration |
72 | | - network_adapter_3 = { |
73 | | - # By default, DHCP is set to False if it isn't provided |
74 | | - dhcp = true |
75 | | - } |
76 | | - network_model_3 = "virtio" |
77 | | - network_bridge_3 = "vmbr0" |
| 134 | + networks = [{ |
| 135 | + bridge = "vmbr0" |
| 136 | + model = "virtio" |
| 137 | + gateway = "" |
| 138 | + gateway6 = "" |
| 139 | + ip = "" |
| 140 | + ip6 = "" |
| 141 | + dhcp = true |
| 142 | + dhcp6 = false |
| 143 | + firewall = true |
| 144 | + link_down = false |
| 145 | + #macaddr = "" # Commented-out as this will generate an error if you do not provide an address. |
| 146 | + queues = 1 |
| 147 | + rate = 0 |
| 148 | + vlan_tag = -1 |
| 149 | + }] |
| 150 | + |
| 151 | + # Whether to enable Non-Uniform Memory Access in the guest. Must have 'memory' in hotplug. |
| 152 | + numa = false |
| 153 | + |
| 154 | + # Whether to have the VM startup after the PVE node starts. |
| 155 | + onboot = true |
| 156 | + |
| 157 | + # Whether to have the VM startup after the VM is created. |
| 158 | + oncreate = true |
| 159 | + |
| 160 | + # The resource pool to which the VM will be added. |
| 161 | + pool = "" |
| 162 | + |
| 163 | + # The SCSI controller to emulate. Options: lsi, lsi53c810, megasas, pvscsi, virtio-scsi-pci, virtio-scsi-single. |
| 164 | + scsihw = "virtio-scsi-pci" |
| 165 | + |
| 166 | + # Sets default DNS search domain suffix. |
| 167 | + searchdomain = "example_domain.com" |
| 168 | + |
| 169 | + # The number of CPU sockets for the Master Node. |
| 170 | + sockets = 1 |
| 171 | + |
| 172 | + /* |
| 173 | + Newline delimited list of SSH public keys to add to authorized keys file for the cloud-init user |
| 174 | +
|
| 175 | + Example (omitted most of the key to save space): |
| 176 | +
|
| 177 | + sshkeys = <<EOF |
| 178 | +ssh-rsa AAAAB3NzaC1yc2YcS+LkeTl9JaW/XzZrzGpb5kQhBNXoSXQ== zackshomelab\zack@ZHLDT01 |
| 179 | +EOF |
| 180 | + */ |
| 181 | + sshkeys = "" |
| 182 | + |
| 183 | + # Tags of the VM. This is only meta information. |
| 184 | + tags = ["tag1", "tag2", "tag3"] |
| 185 | + |
| 186 | + |
| 187 | + # The name of the Proxmox Node on which to place the VM. |
| 188 | + target_node = var.target_node |
| 189 | + |
| 190 | + # The virtual machine name. |
| 191 | + vm_name = "vm-name-example" |
| 192 | + |
| 193 | + # The ID of the VM in Proxmox. |
| 194 | + # The default value of 0 indicates it should use the next available ID in the sequence. |
| 195 | + vmid = 0 |
78 | 196 | } |
0 commit comments