我是 Chef 的新手,所以我的问题似乎有些不知情。
我正在运行 Chef 服务器(v11.4)。我的 Chef 工作站正在运行 MRI Ruby 1.9.3 和 gems Knife-ec2 (v0.6.4) 和 Knife-windows (v0.5.12)。
我正在尝试在安装了 Ruby 的 Amazon AWS 上设置 Windows 2008r2 服务器。我可以通过运行(在命令行窗口的 Windows 框中)静默、无人看管地手动执行此操作:
C:\> C:/rubyinstaller-1.9.3-p429.exe /silent /dir='c:\Ruby193' /tasks=’modpath’
我想使用 Chef 来自动执行此操作。
我尝试在以下配方片段中使用 windows_batch:
remote_file File.join("C:","rubyinstaller-1.9.3-p429.exe") do
source "http://mybucketxxx.s3-website-us-east-1.amazonaws.com/rubyinstaller-1.9.3-p429.exe"
not_if {::File.exists?(File.join("c:","rubyinstaller-1.9.3-p429.exe"))}
end
windows_batch "install_ruby" do
cwd "C:/"
code "C:/rubyinstaller-1.9.3-p429.exe /silent /dir=\'c:/Ruby193' /tasks=’modpath’"
only_if {::File.exists?(File.join("c:","rubyinstaller-1.9.3-p429.exe"))}
not_if {::File.exists?(File.join("c:", "Ruby193", "bin", "ruby.exe"))}
end
我将配方上传到 Chef 服务器,然后运行以下命令来触发 Chef 运行:
> knife winrm 'ec2-50-xx-xx-124.amazonaws.com' 'chef-client -c c:/chef/client.rb' -m -x Administrator -P 'password'
在这种情况下,remote_file 工作并下载了 ruby 安装程序。但是,windows_batch 挂起,安装无处可去。我知道这一点,因为当我 RDP 进入 Windows 服务器时,rubyinstaller-1.9.3-p429.exe 文件位于 c: 中。我知道安装程序挂起是因为我在刀工作站上收到一条消息,说 Ruby 安装程序已启动,但最终超时。Windows 服务器上没有安装任何东西。
然后我尝试用 windows_package 替换 windows_batch 片段。
windows_package "rubyinstaller-1.9.3-p429" do
#source "C:/rubyinstaller-1.9.3-p429.exe"
source "http://mybucketxxx.s3-website-us-east-1.amazonaws.com/rubyinstaller-1.9.3-p429.exe"
options "/silent /dir='C:/Ruby193' /tasks='modpath'"
installer_type :inno
action :install
end
我在注释掉本地源选项的情况下尝试了上面的部分,然后在注释掉远程源选项的情况下再次尝试。没有一个工作。Ruby 安装程序挂起。这是最后几行的样子:
ec2-50-xx-xx-124.amazonaws.com [2013-07-05T13:00:21+00:00] INFO: Processing windows_package[rubyinstaller-1.9.3-p429] action install (myrecipe::default line 53)
DEBUG: :relay_output_from_backend => ["ec2-50-xx-xx-124.amazonaws.com", "[2013-07-05T13:00:21+00:00] INFO: Installing windows_package[rubyinstaller-1.9.3-p429] version latest\r\n"]
ec2-50-xx-xx-124.amazonaws.com [2013-07-05T13:00:21+00:00] INFO: Installing windows_package[rubyinstaller-1.9.3-p429] version latest
DEBUG: :relay_output_from_backend => ["ec2-50-xx-xx-124.amazonaws.com", "[2013-07-05T13:00:21+00:00] INFO: Starting installation...this could take awhile.\r\n"]
ec2-50-xx-xx-124.amazonaws.com [2013-07-05T13:00:21+00:00] INFO: Starting installation...this could take awhile.
在请求超时之前一直保持这种状态。没有安装红宝石。
这导致了几个问题:
- 我是否遗漏了 windows_batch 或 windows_package 语法中的某些内容,从而阻止我以静默方式、无人值守和自动使用 Chef 安装 Ruby?
- 有没有办法准确查看命令行上正在运行哪个命令来安装 Ruby?例如日志文件、详细模式等?
- 有没有人使用 Chef 和 rubyinstaller 在 Windows 上安装 Ruby,你能提供一个食谱吗?