Last active
April 16, 2021 13:23
-
-
Save dariush/7405cbf62835e03d0b5c953d798a87cd to your computer and use it in GitHub Desktop.
workaround to get cloud-init cdrom to work when using q35 libvirt/qemu machine type with dmacvicar/libvirt terraform provider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Please see https://github.com/dmacvicar/terraform-provider-libvirt/issues/667 | |
# add the snippet below to your libvirt domain definition | |
resource "libvirt_domain" "node_name" { | |
# ...rest of domain declaration | |
xml { | |
xslt = file("${path.module}/nodes-adjust.xslt") | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" ?> | |
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
<xsl:output omit-xml-declaration="yes" indent="yes"/> | |
<!-- copy the whole xml doc to start with --> | |
<xsl:template match="node()|@*"> | |
<xsl:copy> | |
<xsl:apply-templates select="node()|@*"/> | |
</xsl:copy> | |
</xsl:template> | |
<!-- replace <target dev='hdd'...> with <target dev='sda'...> --> | |
<xsl:template match="/domain/devices/disk[@device='cdrom']/target/@dev"> | |
<xsl:attribute name="dev"> | |
<xsl:value-of select="'sda'"/> | |
</xsl:attribute> | |
</xsl:template> | |
<!-- replace <target bus='ide'...> with <target bus='sata'...> --> | |
<xsl:template match="/domain/devices/disk[@device='cdrom']/target/@bus"> | |
<xsl:attribute name="bus"> | |
<xsl:value-of select="'sata'"/> | |
</xsl:attribute> | |
</xsl:template> | |
<!-- replace <alias...> with nothing ie delete the <alias...> element --> | |
<xsl:template match="/domain/devices/disk[@device='cdrom']/alias" /> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment