New Question

How to configure Cloudbase-init to run only local scripts (one by one) ?

asked 2021-01-18 19:18:36 +0300

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.


I'm new to using Cloudbase-Init (version: 1.1.2) with Windows Server 2019 (which is an openstack image). And what i should orchestrate with cloudbase-init is only to run some local scripts that are included locally in the image, and I should configure cloudbase-init to run all my local scripts one by one.

But i still did not find the right configuration!

According to the documentation, i saw that in my uses case i should use EmptyMetadataService while i'm going to use only LocalScriptsPlugin.

this is what i have as the cloudbase-init.conf config file:








bsdtar_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\bsdtar.exe

mtools_path=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\bin\



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






localscriptspath=C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\





And like a test, i used my test.ps1 script in C: \ Program Files \ Cloudbase Solutions \ Cloudbase-Init \ LocalScripts \:

my test.ps1 script :


Start-Transcript -path C:\cloudbase-init-firstboot.log -Append -force

write-output "test cloudbase-init local script"


exit 1001


and after restarting the cloudbase-init service it looks like my test.ps1 script was not executed.

Here is what i get in my cloudbase-init log file after reboot:

2021-01-18 17:10:45.021 3444 DEBUG cloudbaseinit.utils.classloader [-] Loading class '' load_class C:\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\lib\site-packages\cloudbaseinit\utils\

2021-01-18 17:10:45.568 3444 DEBUG [-] Checking if service exists: cloudbase-init checkserviceexists C:\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\lib\site-packages\cloudbaseinit\osutils\

2021-01-18 17:10:45.568 3444 DEBUG [-] Getting service username: cloudbase-init getserviceusername C:\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\lib\site-packages\cloudbaseinit\osutils\

2021-01-18 17:10:45.568 3444 DEBUG [-] Resetting password for service user: .\cloudbase-init resetservicepassword C:\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\lib\site-packages\cloudbaseinit\osutils\

2021-01-18 17:10:45.646 3444 DEBUG [-] Setting service credentials: cloudbase-init setservicecredentials C:\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\lib\site-packages\cloudbaseinit\osutils\

2021-01-18 17:10:45.662 3444 INFO cloudbaseinit.init [-] Respawning current process with updated credentials.

2021-01-18 17:10:45.662 3444 DEBUG [-] Creating logon session for user: .\cloudbase-init createuserlogon_session C:\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\lib\site-packages\cloudbaseinit\osutils\

2021-01-18 17:10:45.678 3444 DEBUG [-] Executing process as user, command line: ['C:\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\Scripts\cloudbase-init', '--config-file', 'C:\Program Files\Cloudbase Solutions\Cloudbase-Init\conf ... (more)

edit retag flag offensive close merge delete


i was able to execute my local script by adding to my conf file. but my script still executed on each time i rebooted my server even i'd set up 1001 like exit code in my script

western12 gravatar imagewestern12 ( 2021-01-19 12:53:35 +0300 )edit

2021-01-19 11:47:36.662 4284 INFO cloudbaseinit.plugins.common.fileexecutils [-] Script "C:\Program Files\Cloudbase Solutions\Cloudbase-Init\LocalScripts\test.ps1" ended with exit code: 1001 2021-01-19 11:47:36.662 4284 INFO cloudbaseinit.init [-] Plugins execution done 2021-01-19 11:47:36.662 4284

western12 gravatar imagewestern12 ( 2021-01-19 12:53:52 +0300 )edit

1 answer

Sort by » oldest newest most voted

answered 2021-01-19 15:51:30 +0300

avladu gravatar image


Please check the EmptyMetadataService notes:

If a service returns an empty instance-id (like EmptyMetadataService does), all the plugins will be executed at every cloudbase-init run (reboot, service restart). Plugins that set NTP, MTU, extend volumes are idempotent and can be re-executed with no issues. Make sure that if you configure cloudbase-init to run local scripts, those local scripts are idempotent.

Make sure your scripts are idempotent, meaning that every time the scripts are executed, the result is the same.


if is_unwanted_state():

You can still use the exit reboot codes, but with the above considerations.

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

1 follower


Asked: 2021-01-18 19:18:36 +0300

Seen: 6,930 times

Last updated: Jan 19 '21