lol, same work here in Vietnam. I (personally) usually move to Singapore every month. May i know your company?haha looks like you are doing the same as me from your username you in Vietnam if so we are nearly neighbors as we are in Singapore
Thanks. I finally succeed to setup IP/Hostname/Password with Windows2016/CoudbaseInit through Proxmox/CloudInit.
run_command([['genisoimage','-iso-level', '3', '-R', '-V', $label, $path],
...
+ my $conf = PVE::QemuConfig->load_config($vmid);
+ my $ostype = $conf->{ostype};
if (defined(my $cipassword = $param->{cipassword})) {
# Same logic as in cloud-init (but with the regex fixed...)
+ if (!(PVE::QemuServer::windows_version($ostype))) {
$param->{cipassword} = PVE::Tools::encrypt_pw($cipassword)
if $cipassword !~ /^\$(?:[156]|2[ay])(\$.+){2}/;
+ }
...
...
sub configdrive2_metadata {
my ($uuid) = @_;
+ my ($conf, $vmid, $uuid) = @_;
+ my ($hostname, $fqdn) = get_hostname_fqdn($conf, $vmid);
+ my $password = $conf->{cipassword};
...
"uuid": "$uuid",
+ "hostname": "$hostname",
+ "admin_pass": "$password",
"network_config": { "content_path": "/content/0000" }
...
sub generate_configdrive2 {
...
- my $meta_data = configdrive2_metadata($uuid_str);
+ my $meta_data = configdrive2_metadata($conf, $vmid, $uuid_str);
...
...
password, injected = self._get_password(service, shared_data)
if not password:
return None
# LOG.debug('Generating a random user password')
# maximum_length = osutils.get_maximum_password_length()
# password = osutils.generate_random_password(
# maximum_length)
...
my ($addr, $mask) = split_ip4($net->{ip});
$content .= "iface $id inet static\n";
$content .= " address $addr\n";
$content .= " netmask $mask\n";
$content .= " gateway $net->{gw}\n" if $net->{gw};
$content .= " dns-nameservers $nameservers\n";
#cloud-config
hostname: windows2016-de-image
manage_etc_hosts: true
user: Administrator
password: myPlainTextPassword
chpasswd:
expire: False
users:
- default
package_upgrade: true
[DEFAULT]
username=Admin
groups=Administratoren
inject_user_password=true
bsdtar_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe
mtools_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\
verbose=true
debug=true
logdir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\
logfile=cloudbase-init.log
default_log_levels=comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN
logging_serial_port_settings=
mtu_use_dhcp_config=true
ntp_use_dhcp_config=true
local_scripts_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\
plugins=cloudbaseinit.plugins.common.networkconfig.NetworkConfigPlugin,
cloudbaseinit.plugins.common.setuserpassword.SetUserPasswordPlugin
[config_drive]
raw_hhd=true
cdrom=true
vfat=true
[DEFAULT]
username=Admin
first_logon_behaviour=no
Where exactly I need to place this in the Cloudinit.pm?(2) Change roxmox/CloudInit perl code to save cleartext password for windows type VM:
# vi /usr/share/perl5/PVE/QemuServer/Cloudinit.pm
Code:... + my $conf = PVE::QemuConfig->load_config($vmid); + my $ostype = $conf->{ostype}; if (defined(my $cipassword = $param->{cipassword})) { # Same logic as in cloud-init (but with the regex fixed...) + if (!(PVE::QemuServer::windows_version($ostype))) { $param->{cipassword} = PVE::Tools::encrypt_pw($cipassword) if $cipassword !~ /^\$(?:[156]|2[ay])(\$.+){2}/; + } ...
ahh, wrong file mate.(2) Change roxmox/CloudInit perl code to save cleartext password for windows type VM:
# vi /usr/share/perl5/PVE/QemuServer/Cloudinit.pm
Code:... + my $conf = PVE::QemuConfig->load_config($vmid); + my $ostype = $conf->{ostype}; if (defined(my $cipassword = $param->{cipassword})) { # Same logic as in cloud-init (but with the regex fixed...) + if (!(PVE::QemuServer::windows_version($ostype))) { $param->{cipassword} = PVE::Tools::encrypt_pw($cipassword) if $cipassword !~ /^\$(?:[156]|2[ay])(\$.+){2}/; + } ...
@encore, thanks for the correction, I had updated now.ahh, wrong file mate.
It is /usr/share/perl5/PVE/API2/Qemu.pm
Works fine! Password will be put in plain text into the META_DATA.json from proxmox.
we had it since 2-3 weeks, not months,after we had this solution since few months ago, there is not a plan to be integrated in proxmox by default?
will check that very soon. It is not very professional if a customers sees the mounted cdrom with plain text administrator password indeed.@encore, thanks for the correction, I had updated now.
Btw, I found the way to eject/umount CDROM when Cloudbase-Init completed, please refer here if you are intrested:
https://ask.cloudbase.it/question/2939/how-to-umount-cd-drive-after-cloudbase-init-completed/
plugin 'NetworkConfigPlugin' failed with error '('Cannot set static IP address on network adapter (%d)', 70)'
iface eth0 inet static
address '192.168.92.102'
netmask '255.255.255.0'
gateway '192.168.92.1'
# diff Cloudinit.pm.patched.5.3-11 /usr/share/perl5/PVE/QemuServer/Cloudinit.pm
177,179c177,179
< $content .= " address '$addr'\n";
< $content .= " netmask '$mask'\n";
< $content .= " gateway '$net->{gw}'\n" if $net->{gw};
---
> $content .= " address $addr\n";
> $content .= " netmask $mask\n";
> $content .= " gateway $net->{gw}\n" if $net->{gw};
iface eth0 inet static
address 192.168.92.102
netmask 255.255.255.0
gateway 192.168.92.1