Windows 的 Cloud-Init 等效项是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7677578/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the Cloud-Init equivalent for Windows?
提问by Peter Stephens
It seems that the stock bootstrapping process is a bit lacking on Windows.
似乎 Windows 上的股票引导过程有点缺乏。
Linux has cloud-init which will install packages, store files, and run a bash script from user data.
Linux 具有 cloud-init,它将安装包、存储文件并从用户数据运行 bash 脚本。
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.
Windows 有 ec2config,但目前不支持在系统“准备好”时运行 cmd 或 powershell 脚本——这意味着所有初始重新启动都已完成。
There seem to be third party options. For example RightScale has the RightLink agent which performs this function.
似乎有第三方选项。例如,RightScale 具有执行此功能的 RightLink 代理。
Are there open source options available? Are there any plans to add this feature to Ec2Config? Do I have to build this my self?
是否有可用的开源选项?是否有计划将此功能添加到 Ec2Config?我必须自己建立这个吗?
Am I missing something?
我错过了什么吗?
回答by David Rubin
It appears that EC2Config on the Amazon-provided AMIs now supports "User Data Scripts" as of the 11-April-2012 updates.
从2012 年 4 月 11 日更新开始,Amazon 提供的 AMI 上的 EC2Config 现在似乎支持“用户数据脚本” 。
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 forumsto try and get some more detail, and will update here when I learn more.
该文档尚未更新,因此很难判断它是支持 PowerShell 还是仅支持 cmd.exe 脚本。我已在 AWS 论坛上发布了一个问题以尝试获取更多详细信息,当我了解更多信息时将在此处更新。
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:
更新:看起来支持 cmd.exe 批处理语法,它可以反过来调用 PowerShell。AMI 中包含新版本的 EC2Config 文档。引用它:
[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.
[EC2Config] 将读入为实例指定的用户数据,然后检查它是否包含标签
<script>
和</script>
. 如果两者都找到,那么它将获取这两个标签之间的信息并将其保存到位于此应用程序设置文件夹中的批处理文件中。然后它将在实例启动期间执行批处理文件。批处理文件只会在 sysprep 之后第一次启动实例时创建和执行。如果要再次创建和执行批处理文件,请将 Ec2HandleUserdata 插件状态设置为已启用。
UPDATE 2:My interpretation is confirmedby Shon from the AWS Team
更新2:我的理解是确认通过与Shon从AWS团队
UPDATE 3:And as of the May-2012 AMIs, PowerShell is supported using the <powershell/>
tag.
更新 3:从 2012 年 5 月 AMI 开始,PowerShell 支持使用<powershell/>
标签。
回答by Brian
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.
我必须自己建造一个,但这很容易。刚刚创建了一个服务,该服务在启动时读取用户数据并将文件作为 powershell 脚本执行。
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.
为了解决不知道何时启动服务的问题,我将服务启动类型设为“延迟自动”,这似乎解决了问题。取决于您需要对系统执行的操作,该系统可能适合您,也可能不适合您,但是在我的情况下,这就是我所要做的。
回答by bwight
I added a new codeplex project that already has this tool built for windows. Looking forward to some feedback.
我添加了一个新的 codeplex 项目,该项目已经为 Windows 构建了这个工具。期待一些反馈。
回答by Bob Blanchett
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/
Cloudbase.it 开源了一个 Python Windows 服务,他们称之为 cloudbase-init,它遵循 configdrive 和 HTTP 数据源。 http://www.cloudbase.it/cloud-init-for-windows-instances/
github here https://github.com/stackforge/cloudbase-init/
回答by swn1
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.
我最近发现了 nssm(位于 nssm.cc),它可以轻松地将一个简单的批处理文件(或几乎任何其他文件)包装为服务。然后,您可以使用 sc config servic1 Depend= service0 强制批处理文件在服务初始化序列中的特定点运行。例如,我在 ex2config 和 sql express 之间使用它在 d 上创建一个文件夹。您必须使用服务工具使其作为网络服务运行,并使用 regedit 将 AppExit 属性更改为 Ignore,但一旦您将其全部就位,它就会起作用。
回答by Joe
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.
我们必须自己建造它;我们通过定制服务完成了这项工作,并构建了我们自己的 AMI。目前 EC2Config 中没有任何规定可以做到这一点。
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.
更好的是,没有简单的方法可以确定实例何时“准备好”。我们不得不通过拖尾 EC2Config 的日志文件来做到这一点。