Dynamic generation of infrastructure

Project summary
I am currently working on a project, where i am trying to make better device testing. My issue is that I need to generate a infrastructure based on different underlying hardware (interface names, USB devices, etc…).

Solution ish…
My idea was to create a device definition file on each host, and then generate the infrastructure, based on the parameters in the definition file.

Summarized Issues

  1. Can’t find a way to generate dynamic infrastructure for Terraform/OpenTofu using Python
  2. Found CDKTF, but seems like a weird concept.

Question

  1. What would be the best way to generate a dynamic infrastructure?

Maybe Ansible?