New Question
0

Cloudbase-init localscript exitcode 1003 won't restart when converting to DomainController

asked 2022-05-13 12:49:54 +0200

s-cappa gravatar image

updated 2022-05-17 11:20:32 +0200

I created a powershell script, but when I add "exit 1003" it won't restart the VM automatically. I'm using windows server 2019 with all the latest updates. I run cloudbase-init with service: "NoCloudConfigDriveService".

The problem seems like this: https://ask.cloudbase.it/question/313... but I didn't understand the solution.

I configured cloudbase-init 1.1.3dev with "allow_reboot=true" in both cloudbase-init.conf and cloudbase-init-unattend.conf. I added "cloudbase.plugins.common.locascripts.LocalScriptsPlugin" as plugin in cloudbase-init.conf. Then I executed Sysprep.exe with "/generalize /oobe /shutdown /unattend:Unattend.xml".

When I start the windows server 2019 VM, Cloudbase-init creates users, network config and runs Localscript as expected, but It won't restart ad "exit 1003"

Which are the required config parameters to enable automatic reboot returning 1003 as exit code from a local script?

Thank you.

edit retag flag offensive close merge delete

3 answers

Sort by » oldest newest most voted
0

answered 2022-05-17 11:15:04 +0200

s-cappa gravatar image

updated 2022-09-01 11:24:30 +0200

After some experiments I discovered that this happens in this situation:

  • Windows server 2019 with all updates and "sysprepped" (the VM that I created many months ago works as expected, but not after installing all updates)
  • Powershell localscript is converting the VM to a Domain Controller

These are the commands that I run in my localscript file. First I install same deps and reboot with exit 1003:

 Install-WindowsFeature AD-Domain-Services -IncludeManagementTools
 Install-WindowsFeature RSAT-AD-Tools -IncludeManagementTools
 exit 1003

This part of the script works as expected!

Then I create the forest and reboot again with exit 1003.

 $secureSafeModePassword=(ConvertTo-SecureString "SafePass1!" -AsPlainText -Force)
 Import-Module ADDSDeployment
 Install-ADDSForest `
  -CreateDnsDelegation:$false `
  -DatabasePath "C:\Windows\NTDS" `
  -DomainMode "Win2012R2" `
  -DomainName "testdomain.corp" `
  -DomainNetbiosName "TESTDOMAIN" `
  -ForestMode "Win2012R2" `
  -InstallDns:$true `
  -LogPath "C:\Windows\NTDS" `
  -NoRebootOnCompletion:$true `
  -SysvolPath "C:\Windows\SYSVOL" `
  -SafeModeAdministratorPassword $secureSafeModePassword `
  -Force:$true
  Restart-Computer -Force
  exit 1003

But this time, cloudbase-init returns an error as shown in log file:

INFO cloudbaseinit.init [-] Rebooting
ERROR cloudbaseinit.init [-] reboot failed with error 'Reboot failed: ''Arresto del sistema già pianificato.'': cloudbaseinit.exception.WindowsCloudbaseInitException: Reboot failed: 'Arresto del sistema già pianificato.'
INFO cloudbaseinit.init [-] Process execution ended with exit code: 0

The Italian message says "System shutdown already planned".

Do you have any suggestion? Feel free to ask for more information, because I can reproduce this problem very easily.

Thanks.

edit flag offensive delete link more
0

answered 2022-08-25 13:26:37 +0200

ross89 gravatar image

updated 2022-08-25 13:26:54 +0200

Any update on this? We have the same issue

edit flag offensive delete link more
0

answered 2022-05-19 13:31:54 +0200

avladu gravatar image

Hello,

this looks like a bug in cloudbase-init that needs further investigation. A similar resolution like this one from Ansible might fix this issue though. reboot -> if shutdown in progress -> abort shutdown -> go to reboot.

Practically, if we add here a verification if a shutdown is already in progress and we abort it, it might solve this issue: https://github.com/cloudbase/cloudbas... . The method to be used would be https://docs.microsoft.com/en-us/wind... .

Thank you.

edit flag offensive delete link more

Comments

Hi. Ok, so basically this will require an update of cloudbase-init to fix it. Is there a temporary workaround to cancel a shutdown via powershell/cmd ?

s-cappa gravatar images-cappa ( 2022-05-20 10:08:34 +0200 )edit

Do you have any updates about this? Thank you.

s-cappa gravatar images-cappa ( 2022-06-06 18:10:44 +0200 )edit

@avladu and @ross89 I created an issue on github to discuss the problem in a better way https://github.com/cloudbase/cloudbase-init/issues/100

s-cappa gravatar images-cappa ( 2022-08-30 11:52:14 +0200 )edit

I updated the github issue https://github.com/cloudbase/cloudbase-init/issues/100#issuecomment-1233887470 with a better explanation of what I discovered adding some log messages to the sourcecode of cloudbase-init

s-cappa gravatar images-cappa ( 2022-09-01 11:02:06 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2022-05-13 12:49:54 +0200

Seen: 1,230 times

Last updated: Sep 01 '22