I'm new to Chef, so my question may seem somewhat uninformed.
I'm running a Chef server (v11.4). My Chef workstation is running MRI Ruby 1.9.3 and gems knife-ec2 (v0.6.4) and knife-windows (v0.5.12).
I'm trying to set up a Windows 2008r2 server on Amazon AWS with Ruby installed. I'm able to do this silently, unattended, and manually by running (on the Windows box in a command line window):
C:\> C:/rubyinstaller-1.9.3-p429.exe /silent /dir='c:\Ruby193' /tasks=’modpath’
I would like to use Chef to automate this.
I have tried using windows_batch in the following recipe fragment:
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
I uploaded the recipe to the Chef server, and then ran the following to trigger a Chef run:
> knife winrm 'ec2-50-xx-xx-124.amazonaws.com' 'chef-client -c c:/chef/client.rb' -m -x Administrator -P 'password'
In this situation, the remote_file works and the ruby installer is downloaded. However, the windows_batch hangs and the installation goes nowhere. I know this because when I RDP'ed into the Windows server, the rubyinstaller-1.9.3-p429.exe file was sitting there in c:. And I knew that the installer hung because I got a message on the knife workstation saying that the Ruby installer had started, but it eventually timed out. And nothing was installed on the Windows server.
I then tried replacing the windows_batch fragment with windows_package.
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
I tried the part above with the local source option commented out, and then tried it again with the remote source option commented out. Neither one worked. The Ruby installer hung. This is what the last few lines looked like:
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.
It stays like this until the request times out. Ruby is not installed.
This leads to a few questions:
This problem was solved with two very subtle tweaks:
Therefore, this is what the working Chef resource/provider code, which silently installs Ruby using the Ruby installer, looks like:
windows_package "Ruby 1.9.3-p448" do
source File.join("C:", "rubyinstaller-1.9.3-p448.exe")
options '/dir="C:/Ruby193" /tasks="modpath"'
installer_type :inno
action :install
end
Many thanks to Isa Farnik from Opscode for help on this one.