openSUSE / combustion

Configure MicroOS on the first boot
GNU General Public License v2.0
14 stars 7 forks source link

OVF is not supported #23

Open zinstack625 opened 4 weeks ago

zinstack625 commented 4 weeks ago

Bug

Combustion does not pick up the passed script in some VMware hypervisors, and skips OS initialization as a result

Environment

VMware ESXI 7.0.3

Version

1.3+git9-1.2

Expected behavior

Combustion picks up the passed script and executes it

Actual behavior

As stated, some VMware hypervisors provide guestinfo in OVF as a part of an xml, and they leave expected keys (guestinfo.combustion.script specifically, and others) empty. Thus, combustion does not pick up the scripts and skips passed configuration. The xml in question can be reliably acquired with vmware-rpctool "info-get guestinfo.ovfenv" (in fact, that's what ignition and cloud-init do).

Reproduction

On VMware ESXI enroll a VM with terraform and specify guest_params. They will appear as such

Additional information

Here's an example of one such xml:

<?xml version="1.0" encoding="UTF-8"?>
<Environment
     xmlns="http://schemas.dmtf.org/ovf/environment/1"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:oe="http://schemas.dmtf.org/ovf/environment/1"
     xmlns:ve="http://www.vmware.com/schema/ovfenv"
     oe:id=""
     ve:vCenterId="<snip>">
   <PlatformSection>
      <Kind>VMware ESXi</Kind>
      <Version>7.0.3</Version>
      <Vendor>VMware, Inc.</Vendor>
      <Locale>en</Locale>
   </PlatformSection>
   <PropertySection>
         <Property oe:key="guestinfo.combustion.script" oe:value="<snip>"/>
         <Property oe:key="guestinfo.ignition.config.data" oe:value="<snip>"/>
         <Property oe:key="guestinfo.ignition.config.data.encoding" oe:value="gz+base64"/>
         <Property oe:key="vCloud_UseSysPrep" oe:value="None"/>
         <Property oe:key="vCloud_bitMask" oe:value="1"/>
         <Property oe:key="vCloud_bootproto_0" oe:value="dhcp"/>
         <Property oe:key="vCloud_computerName" oe:value="<snip>"/>
         <Property oe:key="vCloud_macaddr_0" oe:value="<snip>"/>
         <Property oe:key="vCloud_markerid" oe:value="<snip>"/>
         <Property oe:key="vCloud_numnics" oe:value="1"/>
         <Property oe:key="vCloud_primaryNic" oe:value="0"/>
         <Property oe:key="vCloud_reconfigToken" oe:value="<snip>"/>
         <Property oe:key="vCloud_resetPassword" oe:value="0"/>
   </PropertySection>
   <ve:EthernetAdapterSection>
      <ve:Adapter ve:mac="<snip>" ve:network="<snip>" ve:unitNumber="7"/>
   </ve:EthernetAdapterSection>
</Environment>

I guess it's important to mention, that I snipped a gzipped and base64 file content right there. Just the way it is currently performed, only in a different place

Honestly, I don't know if trying to parse an xml in pure bash is remotely a good idea. I guess it isn't tough to make and maintain a statically-linked binary xml-parser. Anyway, I'll be glad to assist in any way possible

Vogtinator commented 4 weeks ago

As stated, some VMware hypervisors provide guestinfo in OVF as a part of an xml, and they leave expected keys (guestinfo.combustion.script specifically, and others) empty.

That's strange, why do they use the guestinfo key names in the same format as vmware-rpctool accepts them then? Shouldn't be hard to set them as guestinfo values directly...

Specifically which hypervisors resp. tools do it like this?

I guess it's not that hard to just add support for vmware-rpctool "info-get guestinfo.ovfenv" | xmllint --xpath /... in addition to the direct guestinfo query.

zinstack625 commented 4 weeks ago

That's strange, why do they use the guestinfo key names in the same format as vmware-rpctool accepts them then?

Beats me, but it's pretty easy to work around, as guestinfo.combustion.script key is definitely empty at first boot

Shouldn't be hard to set them as guestinfo values directly...

Well, it's out of my reach to make stuff happen as expected, and considering both ignition and cloud-init have special providers for that specific format, maybe it's more of a commodity than expected

Specifically which hypervisors resp. tools do it like this?

I noticed ESXI does it like this, which should probably include vSphere and the whole family. Honestly, I don't even have access to the hypervisor, and not sure if it's some toggle on the admin side or a deliberate decision from VMware

I guess it's not that hard to just add support for vmware-rpctool "info-get guestinfo.ovfenv" | xmllint --xpath /... in addition to the direct guestinfo query.

It's certainly a way to do it. If it doesn't bring as much megabytes into the initrd, seems like the way to go

zinstack625 commented 3 weeks ago

Looks ugly, but xmllint --xpath "string(/*[local-name()='Environment']/*[local-name()='PropertySection']/*[local-name()='Property' and @*[local-name()='key']='guestinfo.combustion.script']/@*[local-name()='value'])" - seems to do the job