New Question
0

user-data powershell script fails for unknown reason

asked 2019-01-15 12:44:21 +0300

fblankendaal gravatar image

Hi Guys,

i am running into a situation that my system is trying to run the script which is provided through the user-data field. i can see that the script is in the log file, and that its beeing placed onto the system.

if i run the script ( which i copied from the cloudinit.log ) locally to a file and then run it, all is fine, no problems what so ever (so the script is fine) but when the cloudinit runs it, it fails every time.

i also believe this is due to the fact that cloudinit-unattended is rebooting the system to set the hostname.

Here is a part of the log (verbose and debug are true)

2019-01-15 10:14:59.827 1844 INFO cloudbaseinit.init [-] Executing plugin 'UserDataPlugin'
2019-01-15 10:14:59.827 1844 DEBUG cloudbaseinit.metadata.services.base [-] Getting metadata from: http://ipaddress/latest/user-data _http_request c:\program files\cloudbase solutions\cloudbase-init\python\lib\site-packages\cloudbaseinit\metadata\services\base.py:255
2019-01-15 10:14:59.842 1844 DEBUG cloudbaseinit.plugins.common.userdata [-] User data content length: 3716 execute c:\program files\cloudbase solutions\cloudbase-init\python\lib\site-packages\cloudbaseinit\plugins\common\userdata.py:49
2019-01-15 10:14:59.842 1844 DEBUG cloudbaseinit.plugins.common.userdata [-] Processing userdata _process_user_data c:\program files\cloudbase solutions\cloudbase-init\python\lib\site-packages\cloudbaseinit\plugins\common\userdata.py:108
2019-01-15 10:14:59.842 1844 DEBUG cloudbaseinit.utils.classloader [-] Loading class 'cloudbaseinit.plugins.common.userdataplugins.parthandler.PartHandlerPlugin' load_class c:\program files\cloudbase solutions\cloudbase-init\python\lib\site-packages\cloudbaseinit\utils\classloader.py:27
2019-01-15 10:14:59.842 1844 DEBUG cloudbaseinit.utils.classloader [-] Loading class 'cloudbaseinit.plugins.common.userdataplugins.cloudconfig.CloudConfigPlugin' load_class c:\program files\cloudbase solutions\cloudbase-init\python\lib\site-packages\cloudbaseinit\utils\classloader.py:27
2019-01-15 10:14:59.951 1844 DEBUG cloudbaseinit.utils.classloader [-] Loading class 'cloudbaseinit.plugins.common.userdataplugins.cloudboothook.CloudBootHookPlugin' load_class c:\program files\cloudbase solutions\cloudbase-init\python\lib\site-packages\cloudbaseinit\utils\classloader.py:27
2019-01-15 10:14:59.967 1844 DEBUG cloudbaseinit.utils.classloader [-] Loading class 'cloudbaseinit.plugins.common.userdataplugins.shellscript.ShellScriptPlugin' load_class c:\program files\cloudbase solutions\cloudbase-init\python\lib\site-packages\cloudbaseinit\utils\classloader.py:27
2019-01-15 10:14:59.967 1844 DEBUG cloudbaseinit.utils.classloader [-] Loading class 'cloudbaseinit.plugins.common.userdataplugins.multipartmixed.MultipartMixedPlugin' load_class c:\program files\cloudbase solutions\cloudbase-init\python\lib\site-packages\cloudbaseinit\utils\classloader.py:27
2019-01-15 10:14:59.967 1844 DEBUG cloudbaseinit.utils.classloader [-] Loading class 'cloudbaseinit.plugins.common.userdataplugins.heat.HeatPlugin' load_class c:\program files\cloudbase solutions\cloudbase-init\python\lib\site-packages\cloudbaseinit\utils\classloader.py:27
2019-01-15 10:14:59.967 1844 DEBUG cloudbaseinit.plugins.common.userdata [-] User data content:
Content-Type: multipart/mixed; boundary="MIMEBOUNDARY"
MIME-Version: 1.0

--MIMEBOUNDARY
Content-Disposition: attachment; filename="cloudinit.ps1"
Content-Transfer-Encoding: 7bit
Content-Type: text/x-shellscript
Mime-Version: 1.0

#ps1_sysnative

$chefversion = 'xxx'
$chefenvironment = 'xxx'
$vaulttoken = 'xxx'
$validationcert = 'xxx'
$nodename = ($env:COMPUTERNAME).ToLower()

Start-Transcript -Path $env:SystemRoot\temp\transscript.log
do {
  Write-Host "waiting..."
  sleep 3
} until(Test-NetConnection omnitruck.chef.io -Port 443 | ? { $_.TcpTestSucceeded } )
write-output "ik wil lopen" | out-file "c:\bla.txt ...
(more)
edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted
0

answered 2019-01-15 15:32:26 +0300

fblankendaal gravatar image

updated 2019-01-15 16:27:59 +0300

Sure, thank you for your response

here is my unattended


[DEFAULT]

logdir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\

logfile=cloudbase-init-unattend.log

verbose=true

debug=true

metadata_services=cloudbaseinit.metadata.services.cloudstack.CloudStack, cloudbaseinit.metadata.services.ec2service.EC2Service plugins=cloudbaseinit.plugins.common.sethostname.SetHostNamePlugin

allow_reboot=false

stopserviceon_exit=false

checklatestversion=false


here is my normal


[DEFAULT]

username=Administrator

injectuserpassword=true

firstlogonbehaviour=no

verbose=true

debug=true

logdir=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\

logfile=cloudbase-init.log

metadata_services=cloudbaseinit.metadata.services.cloudstack.CloudStack, cloudbaseinit.metadata.services.ec2service.EC2Service plugins=cloudbaseinit.plugins.common.setuserpassword.SetUserPasswordPlugin, cloudbaseinit.plugins.common.userdata.UserDataPlugin

allow_reboot=false

stopserviceon_exit=true

checklatestversion=false


i did some more digging in the windows setup logs, and now found indeed the reason, that it fails due to the reboot of the cloudinint sethostname


2019-01-15 14:12:08, Info [SETUPUGC.EXE] SetupUGC launched with command line [specialize] 2019-01-15 14:12:08, Info [SETUPUGC.EXE] SetupUGC running to process unattend settings for pass [specialize] 2019-01-15 14:12:08, Info [SETUPUGC.EXE] Processing any RunSynchronous setting... 2019-01-15 14:12:08, Info [SETUPUGC.EXE] Running commands is not yet in progress 2019-01-15 14:12:08, Info [0x090008] PANTHR CBlackboard::Open: C:\Windows\panther\commandexec\CommandExec succeeded. 2019-01-15 14:12:08, Info [SETUPUGC.EXE] Found run command in registry: description = [Run Cloudbase-Init to set the hostname] 2019-01-15 14:12:08, Info [SETUPUGC.EXE] Found run command in registry: credentials = { domain is not specified, username is not specified, password info not logged } 2019-01-15 14:12:08, Info [SETUPUGC.EXE] Found run command in registry: will observe the exit code's implied request after execution 2019-01-15 14:12:08, Info [SETUPUGC.EXE] Found run command in registry: 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" && exit 1 || exit 2"] 2019-01-15 14:12:08, Info [SETUPUGC.EXE] Found RunSynchronous command: [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" && exit 1 || exit 2"]

2019-01-15 14:12:30, Info [SETUPUGC.EXE] Finished executing [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" && exit 1 || exit 2"] synchronously

2019-01-15 14:12:30, Info [SETUPUGC.EXE] Process returned with exit code 0x1 2019-01-15 14:12:30, Info [SETUPUGC.EXE] Must reboot now. 2019-01-15 14:12:30, Info [0x090009] PANTHR CBlackboard::Close: c:\windows\panther\commandexec\commandexec. 2019-01-15 14:12:30, Info [SETUPUGC.EXE] A processor needs an immediate reboot; requesting a reboot-and-recall for SetupUGC 2019-01-15 14:12:30, Info [SETUPUGC.EXE] SetupUGC returning with exit code [3]


this matches the exact same time as the failure from the cloudinit log.


2019-01-15 14:12:30.717 1848 DEBUG cloudbaseinit.plugins.common.fileexecutils [-] Userdata stdout: b'' execfile c:\program files\cloudbase solutions\cloudbase-init\python\lib ... (more)

edit flag offensive delete link more

Comments

I ended up doing the following. 1. Install the cloudbase-init, and disable the service. 2. adjust the unatteded.xml file, by running cloudbase-init unatteded manually ( like advised ) 3. adjust the unatteded.xml file. by setting the cloudbase-init service to automatic. next time it boots it works.

fblankendaal gravatar imagefblankendaal ( 2019-01-31 23:14:00 +0300 )edit
0

answered 2019-01-15 15:00:32 +0300

avladu gravatar image

updated 2019-01-15 16:42:20 +0300

Hello,

Can you post your cloudbase-init configuration file?

From what I see in the logs, you are running the user-data during unattend run, which is not recommended, as sysprep has not finished at that stage.

Thank you,
Adrian Vladu

edit flag offensive delete link more

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: 2019-01-15 12:44:21 +0300

Seen: 1,589 times

Last updated: Jan 15 '19