terraform-provider-libvirt
terraform-provider-libvirt copied to clipboard
Rework/redisign cloudinit iso-generation
So this is issue is for improving the cloudinit
design.
We find out currently that requiring mkisofs
is not universal enough in different os ( some version of SLES/ and some debian lack on this pkg).
Using also geniso
was the same issue.
This issue is more about thinking on how we could redisign the iso generation part in more scalable/universal way.
I was thinking to use usb
disk and dd
. I think this could be possible and more universal.
But maybe other ways are possible
How about using https://github.com/kdomanski/iso9660, do you see any immediate downside or roadblock?
good point. I think i didn't check it but is a good link to look at. thx for re-opining :)
For debian:
apt update && apt install xorriso && update-alternatives --install /usr/bin/mkisofs mkisofs /usr/bin/xorrisofs 10
In the mean time https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=680949 has been fixed in debian unstable/testing so installing the genisoimage
package should be enough
thx
Hi, we create our config isos with https://github.com/diskfs/go-diskfs
Example: https://gist.github.com/kstieger/66399edf56ca967b9ac232e6c438c4cd
Hm, not sure if this is the right place to put this but using 0.7.1
I seem to get an infinite hang when generating the cloudinit disk using archlinux as the host to create a rocklylinux guest.
I saw in the debug logs that I needed mkisofs
however this doesnt seem to have resolved the issue, if this was brought into the application itself it might prevent weirdness like this.
As example here is a tiny snippet of a build reaching the 22 minute mark despite it only trying to create a single host: Where the cloud-init contents is literally "set a public key"
libvirt_cloudinit_disk.commoninit: Still creating... [22m11s elapsed]
libvirt_volume.rocky9: Still creating... [22m21s elapsed]
libvirt_cloudinit_disk.commoninit: Still creating... [22m21s elapsed]
main.tf
terraform {
required_version = ">= 0.13"
required_providers {
libvirt = {
source = "dmacvicar/libvirt"
version = "0.7.1"
}
}
}
# instance the provider
provider "libvirt" {
uri = "qemu:///system"
}
# We fetch the latest ubuntu release image from their mirrors
resource "libvirt_volume" "rocky9" {
name = "rocky9"
source = "https://download.rockylinux.org/pub/rocky/9/images/x86_64/Rocky-9-GenericCloud.latest.x86_64.qcow2"
format = "qcow2"
}
data "template_file" "user_data" {
template = file("${path.module}/cloud_init.cfg")
}
data "template_file" "network_config" {
template = file("${path.module}/network_config.cfg")
}
# for more info about paramater check this out
# https://github.com/dmacvicar/terraform-provider-libvirt/blob/master/website/docs/r/cloudinit.html.markdown
# Use CloudInit to add our ssh-key to the instance
# you can add also meta_data field
resource "libvirt_cloudinit_disk" "commoninit" {
name = "commoninit.iso"
user_data = data.template_file.user_data.rendered
network_config = data.template_file.network_config.rendered
}
# Create the machine
resource "libvirt_domain" "domain-rocky9" {
name = "rocky9-terraform"
memory = "2048"
vcpu = 2
cloudinit = libvirt_cloudinit_disk.commoninit.id
network_interface {
network_name = "default"
wait_for_lease = true
}
cpu {
mode = "host-passthrough"
}
# IMPORTANT: this is a known bug on cloud images, since they expect a console
# we need to pass it
# https://bugs.launchpad.net/cloud-images/+bug/1573095
console {
type = "pty"
target_port = "0"
target_type = "serial"
}
console {
type = "pty"
target_type = "virtio"
target_port = "1"
}
disk {
volume_id = libvirt_volume.rocky9.id
}
graphics {
type = "vnc"
autoport = true
}
}
Ah okay, terraform 1.5.0 is broken, terraform 1.4.6 is totally fine. This isnt an issue for here I'll open one directly.