cloudbase / cloudbase-init

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

Cannot get hostname set on proxmox 8.2.4 with windows server 2022 #155

Closed stevealexandre closed 2 weeks ago

stevealexandre commented 2 weeks ago

Hello guys, I'm currently trying to automate deployment of vm windows servers with terraform & proxmox using cloud init config. After following some basic howto, I'm able to have the user password modified and ip configured successfully but the hostname is not set to the current vm name. I'm quiet new on cloud init and trying to understand how it work.

After checking logs, I can see some errors about that :

2024-09-25 01:57:06.278 3788 INFO cloudbaseinit.init [-] Executing plugin 'SetHostNamePlugin'
2024-09-25 01:57:06.278 3788 DEBUG cloudbaseinit.utils.classloader [-] Loading class 'cloudbaseinit.osutils.windows.WindowsUtils' load_class C:\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\Lib\site-packages\cloudbaseinit\utils\classloader.py:35
2024-09-25 01:57:06.294 3788 DEBUG cloudbaseinit.metadata.services.base [-] Using cached copy of metadata: 'openstack/latest/meta_data.json' _get_cache_data C:\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\Lib\site-packages\cloudbaseinit\metadata\services\base.py:72
2024-09-25 01:57:06.310 3788 DEBUG cloudbaseinit.plugins.common.sethostname [-] Hostname not found in metadata execute C:\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\Lib\site-packages\cloudbaseinit\plugins\common\sethostname.py:30
2024-09-25 01:57:06.325 3788 INFO cloudbaseinit.init [-] Executing plugin 'CreateUserPlugin'
2024-09-25 01:57:06.325 3788 DEBUG cloudbaseinit.metadata.services.base [-] Using cached copy of metadata: 'openstack/latest/meta_data.json' _get_cache_data C:\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\Lib\site-packages\cloudbaseinit\metadata\services\base.py:72
2024-09-25 01:57:06.341 3788 DEBUG cloudbaseinit.utils.classloader [-] Loading class 'cloudbaseinit.osutils.windows.WindowsUtils' load_class C:\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\Lib\site-packages\cloudbaseinit\utils\classloader.py:35
2024-09-25 01:57:06.357 3788 INFO cloudbaseinit.plugins.common.createuser [-] Setting password for existing user "Administrator"

Here my config files

[DEFAULT]
username=Administrator
groups=Administrators
netbios_host_name_compatibility=true
inject_user_password=true
first_logon_behaviour=no
config_drive_cdrom=true
bsdtar_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe
mtools_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\
metadata_services=cloudbaseinit.metadata.services.configdrive.ConfigDriveService
verbose=true
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
logging_serial_port_settings=COM1,115200,N,8
mtu_use_dhcp_config=true
ntp_use_dhcp_config=true
real_time_clock_utc=true
rdp_set_keepalive=true
enable_automatic_updates=true
local_scripts_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\
check_latest_version=false
plugins=cloudbaseinit.plugins.common.mtu.MTUPlugin, cloudbaseinit.plugins.windows.ntpclient.NTPClientPlugin, cloudbaseinit.plugins.common.sethostname.SetHostNamePlugin, cloudbaseinit.plugins.windows.createuser.CreateUserPlugin, cloudbaseinit.plugins.common.networkconfig.NetworkConfigPlugin, cloudbaseinit.plugins.common.sshpublickeys.SetUserSSHPublicKeysPlugin, cloudbaseinit.plugins.windows.extendvolumes.ExtendVolumesPlugin, cloudbaseinit.plugins.common.setuserpassword.SetUserPasswordPlugin, cloudbaseinit.plugins.common.localscripts.LocalScriptsPlugin
allow_reboot=true
stop_service_on_exit=false

And here the user data generated

#cloud-config
hostname: cloudinit-ws2022
manage_etc_hosts: true
fqdn: cloudinit-ws2022
password: *******
chpasswd:
  expire: False
users:
  - default
package_upgrade: true

It's currently using openstack configuration drive. Am I missing something ? It's the last thing I need before creating my doc howto and later create a public tuto of how I managed to deploy my whole infrastructure because there are a lot of lack of recent ressources on latest proxmox and could help a lot.

Thanks for your help.

stevealexandre commented 2 weeks ago

For anyone, fixed by adding the plugin cloudbaseinit.plugins.common.userdata.UserDataPlugin which was not documented anywhere it was needed. Will create a full how to soon to share how to with proxmox 8.2