Giter VIP home page Giter VIP logo

Comments (9)

bpg avatar bpg commented on August 9, 2024 1

Awesome! Thanks for the details šŸ‘

from terraform-provider-proxmox.

mirceanton avatar mirceanton commented on August 9, 2024 1

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.

numkem avatar numkem commented on August 9, 2024 1

This feature is what Iā€™m waiting for setting up a new server with proxmox. Thank you!

from terraform-provider-proxmox.

mirceanton avatar mirceanton commented on August 9, 2024 1

@bpg Thank you for implementing this! šŸŽ‰

from terraform-provider-proxmox.

bpg avatar bpg commented on August 9, 2024

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.

mirceanton avatar mirceanton commented on August 9, 2024

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.

mirceanton avatar mirceanton commented on August 9, 2024

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

image

And with that, we would cover 99% of the use-cases, I would say

from terraform-provider-proxmox.

mirceanton avatar mirceanton commented on August 9, 2024

@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.

numkem avatar numkem commented on August 9, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.