cloudbase / cloudbase-init

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

Cloudbase-init on Windows stops service which causes an event on Windows Systems #35

Open Doni7722 opened 4 years ago

Doni7722 commented 4 years ago

(sorry for opening an issue as I didn't find a mailing list for cloudbase-init) Cloudbase-init runs the service with startup type Automatic. After a successful run of cloudbase-init the service gets stopped. This causes an alert on Windows Systems as the service has startup type automatic but is no longer running.

Here my question:

Regards

ader1990 commented 4 years ago

Hello @Doni7722 ,

First, some background information on how Cloudbase-Init runs and what is the implication of the chosen method to run it.

Cloudbase-Init needs to run at every boot to bootstrap / provision the Windows machine. The reasons for running at each boot are:

To run at each boot, a Windows program can be configured in multiple ways:

If you use the installer, Cloudbase-Init service is installed and configured to automatic start. If you use the installer and choose to sysprep, Cloudbase-Init service will be set to disabled. It will run as a Synchronous Command during the Specialize step to set the MTU, extend disks and set the hostname. At the subsequent reboot, the service is set to automatic and started by the SetupComplete.cmd (which is automatically triggered at the end of the Sysprep). This choice was selected because of the advantage of not rebooting one extra time (for setting the hostname, as hostname should have been set during Specialize stage).

If you do not prefer to run it as a service, you can configure Cloudbase-Init to run as a scheduled task at each reboot. There is another way of achieving this, by using the so-called Windows start hooks: https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/dn789190(v%3Dws.11).

Now, to answer your questions:

(sorry for opening an issue as I didn't find a mailing list for cloudbase-init) Cloudbase-init runs the service with startup type Automatic. After a successful run of cloudbase-init the service gets stopped. This causes an alert on Windows Systems as the service has startup type automatic but is no longer running.

Here my question:

  • Can the service be setup as manual?
  • why does the config stop_service_on_exit=false not take effect?

Regards

The service cannot be set to manual, because if you set it to manual, it will not run unless some entity starts it.

The flag stop_service_on_exit is used to not try to perform the service shutdown when it does not run as a service (during the specialize stage of sysprep).

Thank you, Adrian Vladu