What is the Cloud-Init equivalent for Windows?

心不动则不痛 提交于 2019-12-10 02:30:34

问题


It seems that the stock bootstrapping process is a bit lacking on Windows.

Linux has cloud-init which will install packages, store files, and run a bash script from user data.

Windows has ec2config but there is currently no support to run a cmd or powershell script when the system is "ready"--meaning that all the initial reboots are completed.

There seem to be third party options. For example RightScale has the RightLink agent which performs this function.

Are there open source options available? Are there any plans to add this feature to Ec2Config? Do I have to build this my self?

Am I missing something?


回答1:


It appears that EC2Config on the Amazon-provided AMIs now supports "User Data Scripts" as of the 11-April-2012 updates.

The documentation has not yet been updated, so it's hard to tell if it supports PowerShell or just cmd.exe scripts. I've posted a question on the AWS forums to try and get some more detail, and will update here when I learn more.

UPDATE: It looks like cmd.exe batch syntax is supported, which can in turn invoke PowerShell. There's a new version of the EC2Config documentation included on the AMI. Quoting from it:

[EC2Config] will read in the user data specified for the instance and then check if it contain the tags <script> and </script>. If it finds both then it will take the information between those two tags and save it to a batch file located in the Settings folder of this application. It will then execute the batch file during the start of an instance.

The batch file will only be created and executed on the first launch of an instance after a sysprep. If you want to have the batch file created and executed again set the Ec2HandleUserdata plugin state to Enabled.

UPDATE 2: My interpretation is confirmed by Shon from the AWS Team

UPDATE 3: And as of the May-2012 AMIs, PowerShell is supported using the <powershell/> tag.




回答2:


I had to build one myself however it was very easy. Just made a service that reads the user-data when starts up and executes the file as a powershell script.

To get around the issue of not knowing when to start the service I just made the service start type as "delayed-auto" and that seemed to fix the problem. Depending on what you need to do to the system that may or may not work for you however in my case that was all I had to do.




回答3:


I added a new codeplex project that already has this tool built for windows. Looking forward to some feedback.

http://cloudinitnet.codeplex.com/




回答4:


Cloudbase.it have opensourced a python windows service they call cloudbase-init which follows the configdrive and HTTP datasources. http://www.cloudbase.it/cloud-init-for-windows-instances/

github here https://github.com/stackforge/cloudbase-init/




回答5:


We had to build it ourselves; we did it with a custom service and built our own AMIs. There's no provision currently within EC2Config to do it.

Even better, there is no easy way to determine when the instance is "ready". We had to do it by tailing the logfile of EC2Config.




回答6:


I've recently found nssm (at nssm.cc) which easily wraps a simple batch file (or pretty much anything else) as a service. You can then us sc config servic1 depend= service0 to force the batch file to be run at a particular point in the service initialization sequence. I am using it in between ex2config and sql express to create a folder on d, for instance. You'll have to use the services tool to make it run as network services and change the AppExit property to Ignore using regedit, but it works once you get it all in place.



来源:https://stackoverflow.com/questions/7677578/what-is-the-cloud-init-equivalent-for-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!