Comments (9)
Awesome! Thanks for the details š
from terraform-provider-proxmox.
Let me know if there is any way I can help! I am not too familiar with go or writing terraform providers, but I do have quite a bit of coding experience
from terraform-provider-proxmox.
This feature is what Iām waiting for setting up a new server with proxmox. Thank you!
from terraform-provider-proxmox.
@bpg Thank you for implementing this! š
from terraform-provider-proxmox.
Hi @mirceanton, thanks for submitting this. I don't use PCI pass-through in my environment, so I'm lacking some context here. Could you please provide some examples of the configuration you have to do, or references to PVE documentation that describes what needs to be done to configure that?
from terraform-provider-proxmox.
Hi, @bpg! Sure.
So basically, I am creating a VM Template with Packer (to automatically go through the OS install) and then cloning that template via Terraform, with your provider.
At the end of the process, my vm file looks like this:
root@bingus: cat /etc/pve/qemu-server/105.conf
agent: enabled=0,fstrim_cloned_disks=0,type=virtio
arch: x86_64
balloon: 0
boot: c
cores: 12
cpu: cputype=host
cpuunits: 1024
ide2: none,media=cdrom
kvm: 1
machine: q35
memory: 16384
meta: creation-qemu=7.1.0,ctime=1669555324
name: TrueNAS
net0: virtio=8A:6E:A1:52:69:BA,bridge=vmbr0
numa: 0
onboot: 1
ostype: l26
scsi0: local-zfs:vm-105-disk-0,iothread=0,size=16G
scsihw: virtio-scsi-pci
smbios1: uuid=4dc1e915-6aff-49e4-8844-3de0bd56150a
sockets: 1
tablet: 0
vga: memory=16,type=qxl
vmgenid: 0361d442-79b3-4065-8948-61b5fa14118a
After that, I go into the webUI of proxmox, go to my VM and in the Hardware tab, select Add > PCI Device and select my device from the list.
The VM config file now looks like this:
root@bingus: cat /etc/pve/qemu-server/105.conf
agent: enabled=0,fstrim_cloned_disks=0,type=virtio
arch: x86_64
balloon: 0
boot: c
cores: 12
cpu: cputype=host
cpuunits: 1024
hostpci0: 0000:17:00,pcie=1 # <-- note this hostpci0 entry
ide2: none,media=cdrom
kvm: 1
machine: q35
memory: 16384
meta: creation-qemu=7.1.0,ctime=1669555324
name: TrueNAS
net0: virtio=8A:6E:A1:52:69:BA,bridge=vmbr0
numa: 0
onboot: 1
ostype: l26
scsi0: local-zfs:vm-105-disk-0,iothread=0,size=16G
scsihw: virtio-scsi-pci
smbios1: uuid=4dc1e915-6aff-49e4-8844-3de0bd56150a
sockets: 1
tablet: 0
vga: memory=16,type=qxl
vmgenid: 0361d442-79b3-4065-8948-61b5fa14118a
The proxmox documentation for pci device passthrough can be found here.
Note that, at least in my original idea, we assume the user has a properly configure PVE host (so iommu and all the other things in the guide are already configured), so all that is left for this provider to do is to add the hostpci0: 0000:17:00,pcie=1
line in the config.
from terraform-provider-proxmox.
In terms of the format, I was thinking to add a hostpci
block, something like
hostpci {
id = "0000:17:00"
rombar = true
pcie = true
primary_gpu = false
}
And for the output to the config file, something like (pseudocode/logic):
- for each hostpci block, increment the
counter
- set `hostpci_line="hostpci: "
- if
rombar
is false:hostpci_line += ,rombar=0
- if
pcie
is true:hostpci_line += ,pcie=1
- if
primary_gpu
is true:hostpci_line += ,x-vga=1
And with that, we would cover 99% of the use-cases, I would say
from terraform-provider-proxmox.
@numkem In the meantime, if you are ok with using multiple tools, you can take a look at how I solved this problem in my project here
Basically, I am using Ansible to apply Terraform and then modify the VM definition file manually to add the hostpci
field. Maybe something like this could also work for you.
from terraform-provider-proxmox.
@mirceanton I appreciate the example but I think I might just import the resource when the provider supports it.
from terraform-provider-proxmox.
Related Issues (20)
- proxmox_virtual_environment_container managing mount_points HOT 7
- Cannot create volume mount point in LXC HOT 7
- Add support for `proxmox_virtual_environment_file` data source HOT 4
- Terraform VM Creation crashes plugin when adding ipv4 configuration to VM HOT 3
- Context Deadline Exceeded only on certain resources HOT 11
- Using Cloud Init package_upgrade: false HOT 1
- Error: resizing disk: error waiting for VM disk resize: All attempts fail: HOT 5
- After import command or block, unprivileged forces replacement HOT 2
- Live Migration error: retrieving VM 100: the requested resource does not exist HOT 3
- Recommended way to get Packer built VM ID into Terraform control HOT 9
- proxmox_virtual_environment_vm.virtual_machine already exists error HOT 2
- Please add new arguments and attributes to the `proxmox_virtual_environment_vms` data source HOT 2
- Unknown timezone "Europe/Amsterdam" with proxmox_virtual_environment_time HOT 2
- Changing disk size of 'proxmox_virtual_environment_container' forces replacement HOT 4
- proxmox_virtual_environment_download_file can't read metadata HOT 2
- CloudImage size changes forces replacement of VM HOT 2
- proxmox_virtual_environment_vm forces replacement by unchanged initialization.user_account.keys HOT 2
- A question about documentation related to the proxmox_virtual_environment_container resource
- Error listing files from datastore using API Token as credentials HOT 2
- Unable to download iso (OpenTofu) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from terraform-provider-proxmox.