cloudbase / cloudbase-init

Cross-platform instance initialization
http://openstack.org
Apache License 2.0
414 stars 150 forks source link

IBM cloud images do not license with cloud-init versions greater than 0.9.11 #49

Closed jeffreyzarend closed 4 years ago

jeffreyzarend commented 4 years ago

Hello.

When creating Windows 2012, Windows 2012R2, Windows 2016, Windows 2019 image templates using cloudbase cloud-init, they do not license correctly when configured to obtain licenses from IBM's KMS servers.

Version 0.9.11 does automatically license with configuration Versions 1.1.0 & 1.1.1 do not license from the IBM KMS servers

Our configuration files Unattend.xml

`Jeffreys-MacBook-Pro:iso_dir jeffreyjzarend$ cat Unattend.xml 
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
        <settings pass="generalize">
                <component name="Microsoft-Windows-PnpSysprep" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" 
                        xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" 
                        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                        <PersistAllDeviceInstalls>false</PersistAllDeviceInstalls>
                </component>
        </settings>
        <settings pass="oobeSystem">
                <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" 
                        xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State">
                        <OOBE>
                                <HideEULAPage>true</HideEULAPage>
                                <NetworkLocation>Work</NetworkLocation>
                                <ProtectYourPC>1</ProtectYourPC>
                                <SkipMachineOOBE>true</SkipMachineOOBE>
                                <SkipUserOOBE>true</SkipUserOOBE>
                        </OOBE>
                </component>
        </settings>
        <settings pass="specialize">
                <component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" 
                        xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" 
                        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                        <RunSynchronous>
                                <RunSynchronousCommand wcm:action="add">
                                        <Order>1</Order>
                                        <Path>cmd.exe /c ""C:\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\Scripts\cloudbase-init.exe" --config-file "C:\Program Files\Cloudbase Solutions\Cloudbase-Init\conf\cloudbase-init-unattend.conf" &amp;&amp; exit 1 || exit 2"</Path>
                                        <Description>Run Cloudbase-Init to set the hostname</Description>
                                        <WillReboot>OnRequest</WillReboot>
                                </RunSynchronousCommand>
                        </RunSynchronous>
                </component>
        </settings>
</unattend>
Jeffreys-MacBook-Pro:iso_dir jeffreyjzarend$
`
`Jeffreys-MacBook-Pro:iso_dir jeffreyjzarend$ cat cloudbase-init-unattend.conf 
[DEFAULT]
#  "cloudbase-init-unattend.conf" is used during the Sysprep phase
username=Administrator
inject_user_password=true 
first_logon_behaviour=no
config_drive_types=vfat
config_drive_locations=hdd
allow_reboot=false
stop_service_on_exit=false
mtu_use_dhcp_config=false
bsdtar_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe
mtools_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\
debug=true
log_dir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\
log_file=cloudbase-init-unattend.log
default_log_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN
local_scripts_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\
metadata_services=cloudbaseinit.metadata.services.configdrive.ConfigDriveService
# enabled plugins - executed in order
plugins=cloudbaseinit.plugins.common.mtu.MTUPlugin,
        cloudbaseinit.plugins.common.sethostname.SetHostNamePlugin,
        cloudbaseinit.plugins.windows.createuser.CreateUserPlugin,
        cloudbaseinit.plugins.windows.extendvolumes.ExtendVolumesPlugin,
        cloudbaseinit.plugins.common.setuserpassword.SetUserPasswordPlugin,
        cloudbaseinit.plugins.common.localscripts.LocalScriptsPluginJeffreys-MacBook-Pro:iso_dir jeffreyjzarend$ 
`

Cloudbase-init.conf

`Jeffreys-MacBook-Pro:iso_dir jeffreyjzarend$ cat cloudbase-init.conf 
[DEFAULT]
#  "cloudbase-init.conf" is used for every boot
config_drive_types=vfat
config_drive_locations=hdd
activate_windows=true
kms_host=kms.adn.networklayer.com:1688
mtu_use_dhcp_config=false
real_time_clock_utc=false
bsdtar_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe
mtools_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\
debug=true
log_dir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\
log_file=cloudbase-init.log
default_log_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN
local_scripts_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\
metadata_services=cloudbaseinit.metadata.services.configdrive.ConfigDriveService
# enabled plugins - executed in order
plugins=cloudbaseinit.plugins.common.mtu.MTUPlugin,
        cloudbaseinit.plugins.windows.ntpclient.NTPClientPlugin,
        cloudbaseinit.plugins.windows.licensing.WindowsLicensingPlugin,
        cloudbaseinit.plugins.windows.extendvolumes.ExtendVolumesPlugin,
        cloudbaseinit.plugins.common.userdata.UserDataPlugin,
        cloudbaseinit.plugins.common.localscripts.LocalScriptsPluginJeffreys-MacBook-Pro:iso_dir jeffreyjzarend$ 
`
jeffreyzarend commented 4 years ago

Screen Shot 2020-06-01 at 9 05 27 AM

The above is from running slmgr /ato manually

jeffreyzarend commented 4 years ago

Contents of logs in \program files\cloudbase\cloud-init\log directory

logs.txt

ader1990 commented 4 years ago

Hello,

can you set set_kms_product_key=True in the cloudbase-init.conf and try again?

ader1990 commented 4 years ago

Hello,

can you set set_kms_product_key=True in the cloudbase-init.conf and try again?

I have created a patch which should fix the issue: https://review.opendev.org/#/c/732497/ . Let me know if this fixes your problem. I can provide you a new installer if you needed to test the fix.

Thank you, Adrian Vladu

jeffreyzarend commented 4 years ago

please, I would like the new installer to test the fix. thank you Jeff Zarend

ader1990 commented 4 years ago

To give some context on this issue: we usually create images with a valid product key (being it a KMS or a MAK) and this situation never appears. In your case, it seems you created the images by manually pressing next during the product key input step in the image creation process. Let me know if my assumptions are correct so that I can rule out other possible issues.

jeffreyzarend commented 4 years ago

hmmm, i dont recall seeing the product key input step. you are correct that when i run cloud-init installer, i just do press "next", "next", "next" and take all the defaults.

we have always relied on our KMS to respond and license during the first boot. I create generic templates with no product keys in them currently.

ader1990 commented 4 years ago

I have built a cloudbase-init installer with the patch using the Github actions. You can find the zipped msi for download at the Artifacts button for this Github actions run: https://github.com/ader1990/cloudbase-init-installer-1/runs/730217531?check_suite_focus=true . You need to be logged in to see it.

jeffreyzarend commented 4 years ago

ty i shall try this

jeffreyzarend commented 4 years ago

fyi, it will be several days before I have an answer for you. working from home means I have very slow upload times. thank you

ader1990 commented 4 years ago

fyi, it will be several days before I have an answer for you. working from home means I have very slow upload times. thank you

Sure, no problem. Will wait for your response before merging.

jeffreyzarend commented 4 years ago

Good morning/afternoon I tried the private build on a windows 2016 VM and it licensed. This change looks good.

thank you very much

ader1990 commented 4 years ago

Glad to hear that, I will keep you posted when the patch goes upstream.

jeffreyzarend commented 4 years ago

again, thank you very very much

ader1990 commented 4 years ago

Hello @jeffreyzarend ,

The change has been merged: https://github.com/cloudbase/cloudbase-init/commit/1582ebec2c6fe1f6d0c2fc83adfbb36dbcd550d2 and the latest installer contains it. Can you please close the issue, if everything works?

Thank you.

jeffreyzarend commented 4 years ago

Thank you VERY much. Jeff

jeffreyzarend commented 4 years ago

ill download it and give it as try as soon as possible. probably within next 7 days

jeffreyzarend commented 4 years ago

Is the fix in the stable branch or the beta branch? it looks like the stable branch is still 1_1_1?

ader1990 commented 4 years ago

Is the fix in the stable branch or the beta branch? it looks like the stable branch is still 1_1_1?

The fix is currently in the beta installer: https://www.cloudbase.it/downloads/CloudbaseInitSetup_x64.msi

jeffreyzarend commented 4 years ago

ty. will test it today

jeffreyzarend commented 4 years ago

Tested with the beta installer and windows licensed fine. C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log>findstr /i version * cloudbase-init-unattend.log:2020-06-13 05:39:52.316 1460 INFO cloudbaseinit.init [-] Cloudbase-Init version: 1.1.2.dev5 cloudbase-init.log:2020-06-13 05:41:22.666 2884 INFO cloudbaseinit.init [-] Cloudbase-Init version: 1.1.2.dev5

C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log>findstr /i license * cloudbase-init.log:2020-06-13 05:41:47.634 2884 INFO cloudbaseinit.plugins.windows.licensing [-] Microsoft Windows license info: cloudbase-init.log:License Status: Licensed

C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log>

Closing issue, and eagerly awaiting fix to merge from beta to upstream.

thank you very much