Skip to content

Commit 8624c8e

Browse files
committed
Enable libvirt verbose logging
1 parent c5a1232 commit 8624c8e

File tree

3 files changed

+63
-52
lines changed

3 files changed

+63
-52
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,24 @@ jobs:
5151
virsh -c qemu:///system net-list --all
5252
stat /var/run/libvirt/libvirt-sock /var/lib/libvirt/images
5353
54+
- name: Verbose logging
55+
run: |
56+
sudo virt-admin -c virtqemud:///system daemon-log-outputs "3:journald 1:file:/var/log/libvirt/libvirtd.log"
57+
sudo virt-admin -c virtqemud:///system daemon-log-filters "3:remote 4:event 3:util.json 3:util.object 3:util.dbus 3:util.netlink 3:node_device 3:rpc 3:access 1:*"
58+
sudo virt-admin -c virtqemud:///system daemon-timeout --timeout 0
59+
5460
- name: Enable KVM group perms
5561
run: |
5662
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
5763
sudo udevadm control --reload-rules
5864
sudo udevadm trigger --name-match=kvm
5965
6066
- name: Run tofu
67+
continue-on-error: true
6168
run: |
62-
tofu init &&
63-
tofu apply -auto-approve; ls -lh /var/lib/libvirt/images
69+
tofu init
70+
tofu apply -auto-approve
71+
72+
- name: Dump logs
73+
run:
74+
cat /var/log/libvirt/libvirtd.log

main.tf

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
locals {
1414
nodename = var.nodename == "" ? var.name_prefix : var.nodename
15-
# address = libvirt_domain.node.network_interface[0].addresses[0]
15+
address = libvirt_domain.node.network_interface[0].addresses[0]
1616
use_generated_keypair = var.ssh_private_key == "" || var.ssh_public_key == ""
1717
ssh_public_key = local.use_generated_keypair ? tls_private_key.keypair[0].public_key_openssh : var.ssh_public_key
1818
ssh_private_key = local.use_generated_keypair ? tls_private_key.keypair[0].private_key_openssh : var.ssh_private_key
@@ -52,48 +52,48 @@ resource "libvirt_volume" "root" {
5252
size = 21474836480
5353
}
5454

55-
# resource "libvirt_domain" "node" {
56-
# name = var.name_prefix
57-
# machine = "q35"
58-
# cloudinit = libvirt_cloudinit_disk.ci.id
59-
# memory = 2048
60-
# vcpu = 2
61-
# qemu_agent = true
62-
# xml {
63-
# xslt = file("${path.module}/libvirt-domain.xsl")
64-
# }
65-
# cpu {
66-
# mode = "host-passthrough"
67-
# }
68-
# disk {
69-
# volume_id = libvirt_volume.root.id
70-
# scsi = true
71-
# }
72-
# network_interface {
73-
# network_name = var.libvirt_network_name
74-
# hostname = local.nodename
75-
# wait_for_lease = true
76-
# }
77-
# console {
78-
# type = "pty"
79-
# target_port = "0"
80-
# target_type = "serial"
81-
# }
82-
# provisioner "remote-exec" {
83-
# inline = [
84-
# "cloud-init status --wait",
85-
# templatefile("${path.module}/provision/setup-hostname.sh.tftpl", {
86-
# hostname = local.nodename
87-
# ipv4 = self.network_interface[0].addresses[0]
88-
# }),
89-
# file("${path.module}/provision/install-pve.sh"),
90-
# file("${path.module}/provision/setup-interfaces-sdn.sh")
91-
# ]
92-
# connection {
93-
# type = "ssh"
94-
# user = "debian"
95-
# private_key = local.ssh_private_key
96-
# host = self.network_interface[0].addresses[0]
97-
# }
98-
# }
99-
# }
55+
resource "libvirt_domain" "node" {
56+
name = var.name_prefix
57+
machine = "q35"
58+
cloudinit = libvirt_cloudinit_disk.ci.id
59+
memory = 2048
60+
vcpu = 2
61+
qemu_agent = true
62+
xml {
63+
xslt = file("${path.module}/libvirt-domain.xsl")
64+
}
65+
cpu {
66+
mode = "host-passthrough"
67+
}
68+
disk {
69+
volume_id = libvirt_volume.root.id
70+
scsi = true
71+
}
72+
network_interface {
73+
network_name = var.libvirt_network_name
74+
hostname = local.nodename
75+
wait_for_lease = true
76+
}
77+
console {
78+
type = "pty"
79+
target_port = "0"
80+
target_type = "serial"
81+
}
82+
provisioner "remote-exec" {
83+
inline = [
84+
"cloud-init status --wait",
85+
templatefile("${path.module}/provision/setup-hostname.sh.tftpl", {
86+
hostname = local.nodename
87+
ipv4 = self.network_interface[0].addresses[0]
88+
}),
89+
file("${path.module}/provision/install-pve.sh"),
90+
file("${path.module}/provision/setup-interfaces-sdn.sh")
91+
]
92+
connection {
93+
type = "ssh"
94+
user = "debian"
95+
private_key = local.ssh_private_key
96+
host = self.network_interface[0].addresses[0]
97+
}
98+
}
99+
}

outputs.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# output "node_url" {
2-
# value = "https://${local.address}:8006/"
3-
# description = "Web URL of the PVE manager."
4-
# }
1+
output "node_url" {
2+
value = "https://${local.address}:8006/"
3+
description = "Web URL of the PVE manager."
4+
}
55

66
output "password" {
77
value = local.use_generated_password ? random_password.root[0].result : ""

0 commit comments

Comments
 (0)