From bbcf083b994d5ff646842e413e02a7fe33874db0 Mon Sep 17 00:00:00 2001 From: paisley <72166740+paisley@users.noreply.github.com> Date: Thu, 4 Apr 2024 11:06:43 -0400 Subject: [PATCH] Added graphics variable Add the variable var.graphics to allow overriding the default graphics type of 'spice' with 'vnc' which is compatible with RHEL9. --- README.md | 1 + examples/basic/main.tf | 1 + main.tf | 2 +- variables.tf | 11 +++++++++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fce39d4..6cea0f8 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ No modules. | [bridge](#input\_bridge) | Bridge interface | `string` | `"virbr0"` | no | | [cpu\_mode](#input\_cpu\_mode) | CPU mode | `string` | `"host-passthrough"` | no | | [dhcp](#input\_dhcp) | Use DHCP or Static IP settings | `bool` | `false` | no | +| [graphics](#graphics) | Graphics type (can be '`spice`' or '`vnc`') | `string` | `spice` | no | | [index\_start](#input\_index\_start) | From where the indexig start | `number` | `1` | no | | [ip\_address](#input\_ip\_address) | List of IP addresses | `list(string)` |
[
"192.168.123.101"
]
| no | | [ip\_gateway](#input\_ip\_gateway) | IP addresses of a gateway | `string` | `"192.168.123.1"` | no | diff --git a/examples/basic/main.tf b/examples/basic/main.tf index c33b5ac..862f5bf 100644 --- a/examples/basic/main.tf +++ b/examples/basic/main.tf @@ -11,6 +11,7 @@ module "test_nodes" { memory = "512" vcpu = 1 system_volume = 20 + graphics = "vnc" ssh_admin = "admin" ssh_private_key = "~/.ssh/your_key_id_ed25519" ssh_keys = [ diff --git a/main.tf b/main.tf index 4580896..6ed0426 100644 --- a/main.tf +++ b/main.tf @@ -65,7 +65,7 @@ resource "libvirt_domain" "virt-machine" { } graphics { - type = "spice" + type = var.graphics listen_type = "address" autoport = true } diff --git a/variables.tf b/variables.tf index 16163e3..bbd54d3 100644 --- a/variables.tf +++ b/variables.tf @@ -200,3 +200,14 @@ variable "runcmd" { "[ systemctl, restart, systemd-networkd ]" ] } + +variable "graphics" { + description = "Graphics type" + type = string + default = "spice" + + validation { + condition = contains(["spice", "vnc"], var.graphics) + error_message = "Graphics type not supported. Only 'spice' or 'vnc' are valid options." + } +}