From fc364e73eb45f6ec49a417f8551a64dd891f8cdc Mon Sep 17 00:00:00 2001 From: "igor.pinchuk" Date: Thu, 23 May 2024 01:05:48 +0300 Subject: [PATCH] Misc improvemnts --- main.tf | 13 ++++++++----- variables.tf | 42 +++++++++++++++++++++++++++++++++++++++++- xslt/template.tftpl | 23 +++++++++++++++++++++++ 3 files changed, 72 insertions(+), 6 deletions(-) diff --git a/main.tf b/main.tf index 6ed0426..c2badd1 100644 --- a/main.tf +++ b/main.tf @@ -76,11 +76,14 @@ resource "libvirt_domain" "virt-machine" { "date" ] connection { - type = "ssh" - user = var.ssh_admin - host = self.network_interface[0].addresses[0] - private_key = var.ssh_private_key != null ? file(var.ssh_private_key) : null - timeout = "2m" + type = "ssh" + user = var.ssh_admin + host = self.network_interface[0].addresses[0] + private_key = try(file(var.ssh_private_key), var.ssh_private_key, null) + timeout = "2m" + bastion_host = var.bastion_host + bastion_user = var.bastion_user + bastion_private_key = try(file(var.bastion_ssh_private_key), var.bastion_ssh_private_key, null) } } } diff --git a/variables.tf b/variables.tf index bbd54d3..e73d2e1 100644 --- a/variables.tf +++ b/variables.tf @@ -70,6 +70,16 @@ variable "xml_override" { vendor = string product = string })) + pci_devices_passthrough = list(object({ + src_domain = string + src_bus = string + src_slot = string + src_func = string + dst_domain = string + dst_bus = string + dst_slot = string + dst_func = string + })) }) default = { @@ -86,6 +96,18 @@ variable "xml_override" { # vendor = "0x0123", # product = "0xabcd" # } + ], + pci_devices_passthrough = [ + #{ + # src_domain = "0x0000", + # src_bus = "0xc1", + # src_slot = "0x00", + # src_func = "0x0", + # dst_domain = "0x0000", + # dst_bus = "0x00", + # dst_slot = "0x08" + # dst_func = "0x0" + #} ] } @@ -185,7 +207,7 @@ variable "time_zone" { } variable "ssh_private_key" { - description = "Private key for SSH connection test" + description = "Private key for SSH connection test (either path to file or key content)" type = string default = null } @@ -211,3 +233,21 @@ variable "graphics" { error_message = "Graphics type not supported. Only 'spice' or 'vnc' are valid options." } } + +variable "bastion_host" { + description = "Bastion host" + type = string + default = null +} + +variable "bastion_user" { + description = "Bastion ssh user" + type = string + default = null +} + +variable "bastion_ssh_private_key" { + description = "Bastion private key for SSH connection test (either path to file or key content)" + type = string + default = null +} \ No newline at end of file diff --git a/xslt/template.tftpl b/xslt/template.tftpl index 17d8ae7..8b4df8d 100644 --- a/xslt/template.tftpl +++ b/xslt/template.tftpl @@ -44,6 +44,29 @@ ${usb_controller.model} %{ endfor ~} +%{if pci_devices_passthrough != [] ~} +%{ for pci_devices in pci_devices_passthrough ~} + + pci + yes + + + ${pci_devices.src_domain} + ${pci_devices.src_bus} + ${pci_devices.src_slot} + ${pci_devices.src_func} + + + + pci + ${pci_devices.dst_domain} + ${pci_devices.dst_bus} + ${pci_devices.dst_slot} + ${pci_devices.dst_func} + + +%{ endfor ~} +%{ endif ~}