Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

merging hh feature/windows

  • Loading branch information...
commit f45954fb0402d2cdfb44fc0d3cec7c34f3e11591 2 parents 4b2728b + 8ce8f06
@jedi4ever authored
Showing with 1,555 additions and 73 deletions.
  1. +4 −0 Gemfile
  2. +2 −0  lib/veewee/command/vagrant/basebox.rb
  3. +39 −0 lib/veewee/command/vagrant/winrm.rb
  4. +26 −0 lib/veewee/command/vbox.rb
  5. +6 −1 lib/veewee/definition.rb
  6. +3 −0  lib/veewee/error.rb
  7. +8 −0 lib/veewee/provider/core/box.rb
  8. +30 −14 lib/veewee/provider/core/box/build.rb
  9. +17 −0 lib/veewee/provider/core/box/copy.rb
  10. +31 −12 lib/veewee/provider/core/box/exec.rb
  11. +1 −0  lib/veewee/provider/core/box/floppy.rb
  12. +7 −3 lib/veewee/provider/core/box/halt.rb
  13. +15 −0 lib/veewee/provider/core/box/iwinrm.rb
  14. +7 −1 lib/veewee/provider/core/box/validate_tags.rb
  15. +120 −0 lib/veewee/provider/core/box/wincp.rb
  16. +45 −0 lib/veewee/provider/core/box/winrm.rb
  17. +47 −0 lib/veewee/provider/core/helper/comm.rb
  18. +20 −9 lib/veewee/provider/core/helper/web.rb
  19. +165 −0 lib/veewee/provider/core/helper/winrm.rb
  20. +1 −1  lib/veewee/provider/parallels/box/helper/buildinfo.rb
  21. +1 −0  lib/veewee/provider/virtualbox/box.rb
  22. +16 −8 lib/veewee/provider/virtualbox/box/create.rb
  23. +6 −3 lib/veewee/provider/virtualbox/box/helper/buildinfo.rb
  24. +9 −0 lib/veewee/provider/virtualbox/box/helper/create.rb
  25. +31 −0 lib/veewee/provider/virtualbox/box/helper/winrm_options.rb
  26. +33 −12 lib/veewee/provider/virtualbox/box/up.rb
  27. +13 −0 lib/veewee/provider/virtualbox/box/winrm.rb
  28. +1 −1  lib/veewee/provider/vmfusion/box/helper/buildinfo.rb
  29. +6 −6 templates/windows-2008R1-serverstandard-amd64/Autounattend.xml
  30. +1 −1  templates/windows-2008R1-serverweb-amd64/install-winrm.bat
  31. +224 −0 templates/windows-2008R2-serverstandard-amd64-winrm/Autounattend.xml
  32. +87 −0 templates/windows-2008R2-serverstandard-amd64-winrm/README.md
  33. +33 −0 templates/windows-2008R2-serverstandard-amd64-winrm/definition.rb
  34. +2 −0  templates/windows-2008R2-serverstandard-amd64-winrm/install-chef.bat
  35. +4 −0 templates/windows-2008R2-serverstandard-amd64-winrm/install-vbox.bat
  36. BIN  templates/windows-2008R2-serverstandard-amd64-winrm/oracle-cert.cer
  37. +74 −0 templates/windows-2008R2-serverstandard-amd64-winrm/postinstall.sh
  38. +227 −0 templates/windows-7-enterprise-amd64-winrm/Autounattend.xml
  39. +52 −0 templates/windows-7-enterprise-amd64-winrm/README.md
  40. +26 −0 templates/windows-7-enterprise-amd64-winrm/definition.rb
  41. +2 −0  templates/windows-7-enterprise-amd64-winrm/install-chef.bat
  42. +4 −0 templates/windows-7-enterprise-amd64-winrm/install-vbox.bat
  43. BIN  templates/windows-7-enterprise-amd64-winrm/oracle-cert.cer
  44. +74 −0 templates/windows-7-enterprise-amd64-winrm/postinstall.bat
  45. +34 −0 validation/veewee-windows.feature
  46. +1 −1  veewee.gemspec
View
4 Gemfile
@@ -10,5 +10,9 @@ source "http://rubygems.org"
group :test do
gem "rake"
+ gem "ruby-libvirt"
+ gem "em-winrm", :git => 'git://github.com/hh/em-winrm.git', :ref => '31745601d3'
+ gem "chef"
+ gem "knife-windows"
end
gemspec
View
2  lib/veewee/command/vagrant/basebox.rb
@@ -8,6 +8,7 @@
require 'veewee/command/vagrant/up'
require 'veewee/command/vagrant/halt'
require 'veewee/command/vagrant/ssh'
+require 'veewee/command/vagrant/winrm'
require 'veewee/command/vagrant/define'
require 'veewee/command/vagrant/undefine'
require 'veewee/command/vagrant/validate'
@@ -33,6 +34,7 @@ def initialize(argv,env)
@subcommands.register(:up) { Veewee::Command::Vagrant::Up }
@subcommands.register(:halt) { Veewee::Command::Vagrant::Halt }
@subcommands.register(:ssh) { Veewee::Command::Vagrant::Ssh }
+ @subcommands.register(:winrm) { Veewee::Command::Vagrant::Winrm }
@subcommands.register(:define) { Veewee::Command::Vagrant::Define }
@subcommands.register(:undefine) { Veewee::Command::Vagrant::Undefine }
@subcommands.register(:export) { Veewee::Command::Vagrant::Export }
View
39 lib/veewee/command/vagrant/winrm.rb
@@ -0,0 +1,39 @@
+require 'optparse'
+
+module Veewee
+ module Command
+ module Vagrant
+ class Winrm < ::Vagrant::Command::Base
+ def execute
+ options = {}
+
+ opts = OptionParser.new do |opts|
+ opts.banner = "Winrm into the basebox"
+ opts.separator ""
+ opts.separator "Usage: vagrant basebox winrm <boxname> <command>"
+
+ opts.on("-d", "--debug", "enable debugging") do |d|
+ options['debug'] = d
+ end
+
+ end
+
+ # Parse the options
+ argv = parse_options(opts)
+ return if !argv
+ raise ::Vagrant::Errors::CLIInvalidUsage, :help => opts.help.chomp if argv.length < 2
+
+ begin
+ venv=Veewee::Environment.new(options)
+ venv.ui=@env.ui
+ venv.providers["virtualbox"].get_box(argv[0]).iwinrm(arg[1])
+ rescue Veewee::Error => ex
+ venv.ui.error ex
+ exit -1
+ end
+
+ end
+ end
+ end
+ end
+end
View
26 lib/veewee/command/vbox.rb
@@ -53,6 +53,32 @@ def ssh(box_name,command=nil)
venv.providers["virtualbox"].get_box(box_name).issh(command)
end
+
+ desc "winrm [BOXNAME] [COMMAND]", "Execute command via winrm"
+ method_option :debug,:type => :boolean , :default => false, :aliases => "-d", :desc => "enable debugging"
+ def winrm(box_name,command=nil)
+ venv=Veewee::Environment.new(options)
+ venv.ui=env.ui
+ venv.providers["virtualbox"].get_box(box_name).winrm(command,{:exitcode => "*"})
+ end
+
+ desc "iwinrm [BOXNAME] [COMMAND]", "Interactive winrm login"
+ method_option :debug,:type => :boolean , :default => false, :aliases => "-d", :desc => "enable debugging"
+ def iwinrm(box_name,command=nil)
+ venv=Veewee::Environment.new(options)
+ venv.ui=env.ui
+ venv.providers["virtualbox"].get_box(box_name).iwinrm(command)
+ end
+
+ desc "copy [BOXNAME] [SRC] [DST]", "Copy a file to the VM"
+ method_option :debug,:type => :boolean , :default => false, :aliases => "-d", :desc => "enable debugging"
+ def copy(box_name,src,dst)
+ venv=Veewee::Environment.new(options)
+ venv.ui=env.ui
+ venv.providers["virtualbox"].get_box(box_name).copy_to_box(src,dst)
+ end
+
+
desc "define [BOXNAME] [TEMPLATE]", "Define a new basebox starting from a template"
method_option :force,:type => :boolean , :default => false, :aliases => "-f", :desc => "overwrite the definition"
method_option :debug,:type => :boolean , :default => false, :aliases => "-d", :desc => "enable debugging"
View
7 lib/veewee/definition.rb
@@ -21,6 +21,8 @@ class Definition
attr_accessor :ssh_login_timeout, :ssh_user , :ssh_password, :ssh_key, :ssh_host_port, :ssh_guest_port
+ attr_accessor :winrm_login_timeout, :winrm_user , :winrm_password, :winrm_host_port, :winrm_guest_port
+
attr_accessor :sudo_cmd
attr_accessor :shutdown_cmd
@@ -84,6 +86,9 @@ def initialize(name,path,env)
# :ssh_host_port => "2222", :ssh_guest_port => "22", :sudo_cmd => "echo '%p'|sudo -S sh '%f'",
# :shutdown_cmd => "shutdown -h now",
# :kickstart_file => nil,
+ @winrm_host_port = "5985"; @winrm_guest_port = "5985"
+ @winrm_login_timeout = "10000"
+ @boot_cmd_sequence = [] # Empty list by default
@virtualbox={:vm_options => {}}
@vmfusion={:vm_options => {}}
@@ -172,7 +177,7 @@ def valid?
# Postinstall files require a valid user and password
unless self.postinstall_files.nil?
- if self.ssh_user.nil? || self.ssh_password.nil?
+ if (self.ssh_user.nil? || self.ssh_password.nil?) && (self.winrm_user.nil? || self.winrm_password.nil?)
return false
end
end
View
3  lib/veewee/error.rb
@@ -17,6 +17,9 @@ class TemplateError < Error
class SshError < Error
end
+
+ class WinrmError < Error
+ end
end
#Usage (from the exceptional ruby book)
View
8 lib/veewee/provider/core/box.rb
@@ -3,15 +3,21 @@
require 'veewee/provider/core/helper/web'
require 'veewee/provider/core/helper/shell'
require 'veewee/provider/core/helper/iso'
+require 'veewee/provider/core/helper/winrm'
+require 'veewee/provider/core/helper/comm'
require 'veewee/provider/core/box/build'
require 'veewee/provider/core/box/scp'
+require 'veewee/provider/core/box/wincp'
+require 'veewee/provider/core/box/copy'
require 'veewee/provider/core/box/exec'
require 'veewee/provider/core/box/poweroff'
require 'veewee/provider/core/box/halt'
require 'veewee/provider/core/box/sudo'
require 'veewee/provider/core/box/ssh'
require 'veewee/provider/core/box/issh'
+require 'veewee/provider/core/box/winrm'
+require 'veewee/provider/core/box/iwinrm'
require 'veewee/provider/core/box/floppy'
require 'veewee/provider/core/box/validate_tags'
@@ -28,6 +34,8 @@ class Box
include ::Veewee::Provider::Core::Helper::Web
include ::Veewee::Provider::Core::Helper::Shell
include ::Veewee::Provider::Core::Helper::Ssh
+ include ::Veewee::Provider::Core::Helper::Winrm
+ include ::Veewee::Provider::Core::Helper::Comm
include ::Veewee::Provider::Core::Helper::Iso
include ::Veewee::Provider::Core::BoxCommand
View
44 lib/veewee/provider/core/box/build.rb
@@ -74,6 +74,7 @@ def build(options={})
sleep 2
end
+
self.transfer_buildinfo(options)
# Filtering post install files based upon --postinstall-include and --postinstall--exclude
@@ -81,9 +82,13 @@ def build(options={})
self.handle_postinstall(options)
- ui.success "The box #{name} was built succesfully!"
+ ui.success "The box #{name} was build succesfully!"
ui.info "You can now login to the box with:"
- ui.info ssh_command_string
+ if (definition.winrm_user && definition.winrm_password)
+ env.ui.info winrm_command_string
+ else
+ env.ui.info ssh_command_string
+ end
return self
end
@@ -165,11 +170,11 @@ def handle_kickstart(options)
kickstartfiles=definition.kickstart_file
if kickstartfiles.nil? || kickstartfiles.length == 0
- ui.info "Skipping webserver as no kickstartfile was specified"
+ env.ui.info "Skipping webserver as no kickstartfile was specified"
+ else
+ env.ui.info "Starting a webserver #{definition.kickstart_ip}:#{definition.kickstart_port}\n"
end
- ui.info "Starting a webserver #{definition.kickstart_ip}:#{definition.kickstart_port}\n"
-
# Check if the kickstart is an array or a single string
if kickstartfiles.is_a?(String)
# Let's turn it into an array
@@ -197,17 +202,23 @@ def handle_postinstall(options)
definition.postinstall_files.each do |postinstall_file|
# Filenames of postinstall_files are relative to their definition
filename=File.join(definition.path,postinstall_file)
- self.scp(filename,File.basename(filename))
- self.exec("chmod +x \"#{File.basename(filename)}\"")
+ self.copy_to_box(filename,File.basename(filename))
+ if not (definition.winrm_user && definition.winrm_password)
+ self.exec("chmod +x \"#{File.basename(filename)}\"")
+ end
end
# Prepare a pre_poinstall file if needed (not nil , or not empty)
unless definition.pre_postinstall_file.to_s.empty?
pre_filename=File.join(definition.path, definition.pre_postinstall_file)
- self.scp(pre_filename,File.basename(pre_filename))
- self.exec("chmod +x \"#{File.basename(pre_filename)}\"")
- # Inject the call to the real script by executing the first argument (it will be the postinstall script file name to be executed)
- self.exec("execute=\"\\n# We must execute the script passed as the first argument\\n\\$1\" && printf \"%b\\n\" \"$execute\" >> #{File.basename(pre_filename)}")
+ self.copy_to_box(filename,File.basename(pre_filename))
+ if (definition.winrm_user && definition.winrm_password)
+ # not implemented on windows yet
+ else
+ self.exec("chmod +x \"#{File.basename(pre_filename)}\"")
+ # Inject the call to the real script by executing the first argument (it will be the postinstall script file name to be executed)
+ self.exec("execute=\"\\n# We must execute the script passed as the first argument\\n\\$1\" && printf \"%b\\n\" \"$execute\" >> #{File.basename(pre_filename)}")
+ end
end
# Now iterate over the postinstall files
@@ -218,14 +229,19 @@ def handle_postinstall(options)
unless File.basename(postinstall_file).start_with?("_")
unless definition.pre_postinstall_file.to_s.empty?
+ raise 'not implemented on windows yet' if (definition.winrm_user && definition.winrm_password)
# Filename of pre_postinstall_file are relative to their definition
pre_filename=File.join(definition.path, definition.pre_postinstall_file)
# Upload the pre postinstall script if not already transfered
command = "./" + File.basename(pre_filename)
command = sudo(command) + " ./"+File.basename(filename)
else
- command = "./"+File.basename(filename)
- command = sudo(command)
+ if (definition.winrm_user && definition.winrm_password)
+ # no sudo on windows, batch files only please?
+ self.exec(File.basename(filename))
+ else
+ self.exec(sudo("./"+File.basename(filename)))
+ end
end
self.exec(command)
@@ -249,7 +265,7 @@ def transfer_buildinfo(options)
infofile.puts "#{info[:content]}"
infofile.rewind
infofile.close
- self.scp(infofile.path,info[:filename])
+ self.copy_to_box(infofile.path,info[:filename])
infofile.delete
rescue RuntimeError => ex
ui.error("Error transfering file #{info[:filename]} failed, possible not enough permissions to write? #{ex}",:prefix => false)
View
17 lib/veewee/provider/core/box/copy.rb
@@ -0,0 +1,17 @@
+module Veewee
+ module Provider
+ module Core
+ module BoxCommand
+
+ def copy_to_box(localfile,remotefile,options={})
+ raise Veewee::Error,"Box is not running" unless self.running?
+ if definition.winrm_user && definition.winrm_password # prefer winrm
+ self.wincp(localfile,remotefile,options)
+ else
+ self.scp(localfile,remotefile,options)
+ end
+ end
+ end # Module
+ end # Module
+ end # Module
+end # Module
View
43 lib/veewee/provider/core/box/exec.rb
@@ -8,25 +8,44 @@ def ssh_command_string
"ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p #{ssh_options[:port]} -l #{definition.ssh_user} #{self.ip_address}"
end
+ def winrm_command_string
+ "knife winrm -m #{self.ip_address} -P #{winrm_options[:port]} -x #{definition.winrm_user}" +
+ " -P #{definition.winrm_password} COMMAND"
+ end
+
def exec(command,options={})
raise Veewee::Error,"Box is not running" unless self.running?
- begin
- new_options=ssh_options.merge(options)
- self.when_ssh_login_works(self.ip_address,new_options) do
- begin
- env.logger.info "About to execute remote command #{command} on box #{name} - #{self.ip_address} - #{new_options}"
- result=self.ssh_execute(self.ip_address,command,new_options)
+ if definition.winrm_user && definition.winrm_password
+ begin
+ new_options=winrm_options.merge(options)
+ self.when_winrm_login_works(self.ip_address,winrm_options.merge(options)) do
+ result = self.winrm_execute(self.ip_address,command,new_options)
return result
- rescue RuntimeError => ex
- error= "Error executing command #{command} : #{ex}"
- error+="\n#{ex.backtrace.join("\n")}" unless ex.backtrace.empty?
- raise Veewee::SshError, error
end
+ rescue RuntimeError => ex
+ env.ui.error "Error executing command #{command} : #{ex}"
+ raise Veewee::WinrmError, ex
+ end
+ else # definition.ssh_user && definition.ssh_password
+ begin
+ new_options=ssh_options.merge(options)
+ self.when_ssh_login_works(self.ip_address,new_options) do
+ begin
+ env.logger.info "About to execute remote command #{command} on box #{name} - #{self.ip_address} - #{new_options}"
+ result=self.ssh_execute(self.ip_address,command,new_options)
+ return result
+ rescue RuntimeError => ex
+ env.ui.error "Error executing command #{command} : #{ex}"
+ raise Veewee::SshError, ex
+ end
+ end
+ rescue Net::SSH::AuthenticationFailed => ex # may want to catch winrm auth fails as well
+ env.ui.error "Authentication failure"
+ raise Veewee::SshError, "Authentication failure\n"+ex
end
- rescue Net::SSH::AuthenticationFailed => ex
- raise Veewee::SshError, "Authentication failure\n"+ex
end
+
end
end # Module
end # Module
View
1  lib/veewee/provider/core/box/floppy.rb
@@ -5,6 +5,7 @@ module BoxCommand
def create_floppy(floppy_filename)
# Todo Check for java
# Todo check output of commands
+ # Todo allow for .erb templates
# Check for floppy
unless definition.floppy_files.nil?
View
10 lib/veewee/provider/core/box/halt.rb
@@ -9,9 +9,13 @@ def halt(options={})
if options["force"]==true
self.poweroff
else
- self.exec("echo '#{definition.shutdown_cmd}' > /tmp/shutdown.sh")
- self.exec("chmod +x /tmp/shutdown.sh")
- self.exec(sudo("/tmp/shutdown.sh"))
+ if definition.winrm_user && definition.winrm_password # prefer winrm
+ self.exec("#{definition.shutdown_cmd}")
+ else
+ self.exec("echo '#{definition.shutdown_cmd}' > /tmp/shutdown.sh")
+ self.exec("chmod +x /tmp/shutdown.sh")
+ self.exec(sudo("/tmp/shutdown.sh"))
+ end
end
else
raise Veewee::Error,"Box is not running"
View
15 lib/veewee/provider/core/box/iwinrm.rb
@@ -0,0 +1,15 @@
+require 'veewee/provider/core/helper/ssh'
+module Veewee
+ module Provider
+ module Core
+ module BoxCommand
+
+ def iwinrm(command=nil,options={})
+ self.winrm(command,options.merge({:interactive => true}))
+ end
+
+ end # Module
+ end # Module
+ end # Module
+end # Module
+
View
8 lib/veewee/provider/core/box/validate_tags.rb
@@ -31,7 +31,13 @@ def validate_tags(tags,options)
ENV['VEEWEE_BOXNAME']=@name
ENV['VEEWEE_PROVIDER']=@provider.name
- feature_path=File.join(File.dirname(__FILE__),"..","..","..","..","..","validation","veewee.feature")
+ if definition.winrm_user && definition.winrm_password # prefer winrm
+ featurefile="veewee-windows.feature"
+ else
+ featurefile="veewee.feature"
+ end
+
+ feature_path=File.join(File.dirname(__FILE__),"..","..","..","..","..","validation",featurefile)
features=Array.new
features[0]=feature_path
View
120 lib/veewee/provider/core/box/wincp.rb
@@ -0,0 +1,120 @@
+require 'veewee/provider/core/helper/winrm'
+module Veewee
+ module Provider
+ module Core
+ module BoxCommand
+
+ def wincp(localfile,remotefile,options={})
+ raise Veewee::Error,"Box is not running" unless self.running?
+
+ # Calculate an available kickstart port which we will use for wincp
+ definition.kickstart_port = "7000" if definition.kickstart_port.nil?
+ guessed_port=guess_free_port(definition.kickstart_port.to_i,7199).to_s
+ if guessed_port.to_s!=definition.kickstart_port
+ env.ui.warn "Changing wincp port from #{definition.kickstart_port} to #{guessed_port}"
+ definition.kickstart_port=guessed_port.to_s
+ end
+
+ if self.exec("cmd.exe /C dir #{wget_vbs_file} > %TEMP%\\null",{:exitcode=>"*"}).status != 0
+ env.ui.warn "Creating wget.vbs"
+ create_wget_vbs_command do |command_chunk, chunk_num|
+ self.exec("cmd.exe /C echo \"Rendering '#{wget_vbs_file}' chunk #{chunk_num}\" && #{command_chunk}")
+ end
+ end
+
+
+ env.ui.warn "Spinning up a wait_for_http_request on http://#{host_ip_as_seen_by_guest}:#{definition.kickstart_port}#{localfile}"
+ webthread=allow_for_http_request(localfile,{
+ :port => definition.kickstart_port,
+ :host => definition.kickstart_ip,
+ :timeout => definition.kickstart_timeout,
+ :web_dir => '/'
+ })
+
+ begin
+ self.when_winrm_login_works(self.ip_address,winrm_options.merge(options)) do
+ env.ui.info "Going to try and copy #{localfile} to #{remotefile.inspect}"
+ self.exec("cmd.exe /C cscript %TEMP%\\wget.vbs /url:http://#{host_ip_as_seen_by_guest}:#{definition.kickstart_port}#{localfile} /path:#{remotefile}")
+ # while true do
+ # sleep 0.1 # used to debug
+ # end
+ end
+ end
+ end
+
+
+ def wget_vbs_file
+ "%TEMP%\\\\wget.vbs"
+ end
+
+ def create_wget_vbs_command(&block)
+ bootstrap_bat = []
+ chunk_num = 0
+ wget_vbs.each_line do |line|
+ # escape WIN BATCH special chars
+ line.gsub!(/[(<|>)^]/).each{|m| "^#{m}"}
+ # windows commands are limited to 2047 characters
+ if((bootstrap_bat + [line]).join(" && ").size > 2047 )
+ yield bootstrap_bat.join(" && "), chunk_num += 1
+ bootstrap_bat = []
+ end
+ bootstrap_bat << ">> #{wget_vbs_file} (echo.#{line.chomp.strip})"
+ end
+ yield bootstrap_bat.join(" && "), chunk_num += 1
+ bootstrap_bat = []
+ end
+
+ def wget_vbs
+ wget_vbs = <<-WGET
+url = WScript.Arguments.Named("url")
+path = WScript.Arguments.Named("path")
+Set objXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP")
+Set wshShell = CreateObject( "WScript.Shell" )
+Set objUserVariables = wshShell.Environment("USER")
+
+'http proxy is optional
+'attempt to read from HTTP_PROXY env var first
+On Error Resume Next
+
+If NOT (objUserVariables("HTTP_PROXY") = "") Then
+objXMLHTTP.setProxy 2, objUserVariables("HTTP_PROXY")
+
+'fall back to named arg
+ElseIf NOT (WScript.Arguments.Named("proxy") = "") Then
+objXMLHTTP.setProxy 2, WScript.Arguments.Named("proxy")
+End If
+
+On Error Goto 0
+
+objXMLHTTP.open "GET", url, false
+objXMLHTTP.send()
+If objXMLHTTP.Status = 200 Then
+Set objADOStream = CreateObject("ADODB.Stream")
+objADOStream.Open
+objADOStream.Type = 1
+objADOStream.Write objXMLHTTP.ResponseBody
+objADOStream.Position = 0
+Set objFSO = Createobject("Scripting.FileSystemObject")
+If objFSO.Fileexists(path) Then objFSO.DeleteFile path
+Set objFSO = Nothing
+objADOStream.SaveToFile path
+objADOStream.Close
+Set objADOStream = Nothing
+End if
+Set objXMLHTTP = Nothing
+WGET
+ #escape_and_echo(win_wget)
+ wget_vbs
+ end
+
+ # escape WIN BATCH special chars
+ # and prefixes each line with an
+ # echo
+ def escape_and_echo(file_contents)
+ file_contents.gsub(/^(.*)$/, 'echo.\1').gsub(/([(<|>)^])/, '^\1')
+ end
+
+ end # Module
+ end # Module
+ end # Module
+end # Module
View
45 lib/veewee/provider/core/box/winrm.rb
@@ -0,0 +1,45 @@
+require 'veewee/provider/core/helper/winrm'
+module Veewee
+ module Provider
+ module Core
+ module BoxCommand
+
+
+ def winrm(command=nil,options={})
+
+ raise Veewee::Error,"Box is not running" unless self.running?
+
+ if (options[:interactive]==true)
+ env.ui.info "WINRM NOT INTERACTIVE YET"
+ end
+ winrm_options={:user => definition.winrm_user,:password => definition.winrm_password, :port => definition.winrm_host_port}
+ winrm_execute(self.ip_address,command,winrm_options.merge(options))
+
+ end
+
+ private
+ def winrm_options(options)
+
+ command_options = [
+ #"-q", #Suppress warning messages
+ # "-T", #Pseudo-terminal will not be allocated because stdin is not a terminal.
+ "-p #{winrm_options[:port]}",
+ "-o UserKnownHostsFile=/dev/null",
+ "-t -o StrictHostKeyChecking=no",
+ "-o IdentitiesOnly=yes",
+ "-o VerifyHostKeyDNS=no"
+ ]
+ if !(definition.winrm_key.nil? || definition.winrm_key.length!="")
+ command_options << "-i #{definition.winrm_key}"
+ end
+ commandline_options="#{command_options.join(" ")} ".strip
+
+ user_option=definition.winrm_user.nil? ? "" : "-l #{definition.winrm_user}"
+
+ return "#{commandline_options} #{user_option}"
+ end
+ end # Module
+ end # Module
+ end # Module
+end # Module
+
View
47 lib/veewee/provider/core/helper/comm.rb
@@ -0,0 +1,47 @@
+module Veewee
+ module Provider
+ module Core
+ module Helper
+
+ module Comm
+
+ def comm_method
+ if (definition.winrm_user && definition.winrm_password)
+ :winrm
+ else
+ :ssh
+ end
+ end
+
+ def when_comm_login_works(ip="127.0.0.1", options = { } , &block)
+ case comm_method
+ when :winrm
+ when_winrm_login_works(ip,options,block)
+ when :ssh
+ when_ssh_login_works(ip,options,block)
+ end
+ end
+
+ def comm_transfer_file(host,filename,destination = '.' , options = {})
+ case comm_method
+ when :winrm
+ winrm_transfer_file(host,filename,destination,options)
+ when :ssh
+ ssh_transfer_file(host,filename,destination,options)
+ end
+ end
+
+ def comm_execute(host,command, options = { :progress => "on"} )
+ case comm_method
+ when :winrm
+ winrm_execute(host,command, options )
+ when :ssh
+ ssh_execute(host,command, options )
+ end
+ end
+
+ end #Class
+ end #Module
+ end #Module
+ end #Module
+end #Module
View
29 lib/veewee/provider/core/helper/web.rb
@@ -9,13 +9,14 @@ module Servlet
class FileServlet < WEBrick::HTTPServlet::AbstractServlet
- attr_reader :ui
+ attr_reader :ui, :threaded
- def initialize(server,localfile,ui)
+ def initialize(server,localfile,ui,threaded)
super(server)
@server=server
@localfile=localfile
@ui=ui
+ @threaded=threaded
end
def do_GET(request,response)
@@ -30,18 +31,27 @@ def do_GET(request,response)
ui.info "Serving file #{@localfile}"
content
end
- #If we shut too fast it might not get the complete file
- sleep 2
- @server.shutdown
+ if not @threaded
+ ui.info "Shutting down for #{@localfile}"
+ @server.shutdown
+ end
end
end
end
module Web
- def wait_for_http_request(filename,options={:timeout => 10, :web_dir => "", :port => 7125})
+ def wait_for_http_request(filename,options) # original blocking
+ s = server_for_http_request(filename,options)
+ s.start
+ end
+ def allow_for_http_request(filename,options) # start in new thread
+ s = server_for_http_request(filename,options.merge({:threaded => true}))
+ Thread.new { s.start }
+ end
+ def server_for_http_request(filename,options={:timeout => 10, :web_dir => "", :port => 7125, :threaded => false})
# Calculate the OS equivalent of /dev/null , on windows this is NUL:
# http://www.ruby-forum.com/topic/115472
fn = test(?e, '/dev/null') ? '/dev/null' : 'NUL:'
@@ -55,14 +65,15 @@ def wait_for_http_request(filename,options={:timeout => 10, :web_dir => "", :por
:Logger => webrick_logger,
:AccessLog => webrick_logger
)
- env.logger.debug("mounting file /#{filename}")
- s.mount("/#{filename}", Veewee::Provider::Core::Helper::Servlet::FileServlet,File.join(web_dir,filename),ui)
+ mount_filename = filename.start_with?('/') ? filename : "/#{filename}"
+ env.logger.debug("mounting file #{mount_filename}")
+ s.mount("#{mount_filename}", Veewee::Provider::Core::Helper::Servlet::FileServlet,File.join(web_dir,filename),ui,options[:threaded])
trap("INT"){
s.shutdown
ui.info "Stopping webserver"
exit
}
- s.start
+ s
end
end #Class
View
165 lib/veewee/provider/core/helper/winrm.rb
@@ -0,0 +1,165 @@
+module Veewee
+ module Provider
+ module Core
+ module Helper
+
+ class WinrmResult
+ attr_accessor :stdout
+ attr_accessor :stderr
+ attr_accessor :status
+
+ def initialize(stdout,stderr,status)
+ @stdout=stdout
+ @stderr=stderr
+ @status=status
+ end
+ end
+
+ module Winrm
+
+ require 'timeout'
+ require 'log4r'
+ require 'em-winrm'
+ require 'highline'
+
+ def winrm_up?(ip,options)
+ if not @winrm_up
+ @httpcli = HTTPClient.new(:agent_name => 'Ruby WinRM Client')
+ @httpcli.receive_timeout = 10
+ @httpcli.set_auth(nil, options[:user], options[:pass])
+ @httpcli.get("http://#{ip}:#{options[:port]}/wsman")
+ @winrm_up = true
+ end
+ rescue HTTPClient::ReceiveTimeoutError
+ @winrm_up = false
+ end
+
+
+ def when_winrm_login_works(ip="127.0.0.1", options = {}, &block)
+
+ #options=winrm_options.merge(options.merge({:operation_timeout => 5}))
+ options=winrm_options.merge(options)
+ @login_works ||= {}
+ begin
+ Timeout::timeout(options[:timeout]) do
+ if @login_works[ip]
+ block.call(ip);
+ else
+ env.ui.info "Waiting for winrm login on #{ip} with user #{options[:user]} to windows on port => #{options[:port]} to work, timeout=#{options[:timeout]} sec"
+ until @connected do
+ begin
+ sleep 1
+ env.ui.info ".",{:new_line => false}
+ next if not winrm_up?(ip, options)
+ winrm_execute(ip,"hostname",options.merge({:progress => nil}))
+ @login_works[ip]=true
+ env.ui.info "\n"
+ block.call(ip);
+ env.ui.info ""
+ sleep 1
+ @connected = true
+ return true
+ rescue Exception => e
+ puts e.inspect
+ puts e.message
+ puts e.backtrace.inspect
+ sleep 5
+ end
+ end
+ end
+ end
+ rescue Timeout::Error
+ env.ui.error "Winrm timeout #{options[:timeout]} sec has been reached."
+ exit -1
+ rescue WinRM::WinRMHTTPTransportError => e
+ if e.message =~ /401/
+ env.ui.error "Unable to authenticate as '#{options[:user]}' with password '#{options[:pass]}'"
+ else
+ raise e
+ end
+ end
+ return false
+ end
+
+
+ def winrm_transfer_file(host,filename,destination = '.' , options = {})
+ options = winrm_options.merge(options.merge({:paranoid => false }))
+ # when_winrm_login_works
+
+ env.ui.info "FIXME: Transferring #{filename} to #{destination} "
+ # print these out while uploading:
+ env.ui.info ".",{:new_line => false}
+ # t::SSH.start( host,options[:user],options )
+ env.ui.info ""
+ end
+
+ def new_session(host,options)
+ opts = winrm_options.merge(options)
+ # create a session
+ begin
+ endpoint = "http://#{host}:#{opts[:port]}/wsman"
+ client = ::WinRM::WinRMWebService.new(endpoint, :plaintext, opts)
+ if opts[:operation_timeout]
+ client.set_timeout(opts[:operation_timeout])
+ end
+ rescue ::WinRM::WinRMAuthorizationError => error
+ raise ::WinRM::WinRMAuthorizationError.new("#{error.message}@#{host}")
+ end
+ client
+ end
+
+ def winrm_execute(host,command, options)
+
+ options = winrm_options.merge( # global default
+ { # function defaults
+ :exitcode => "0",
+ :progress => "on"
+ }.merge(
+ options # calling override
+ ))
+ stdout=""
+ stderr=""
+ status=-99999
+
+ @session ||= new_session(host, options)
+
+ env.ui.info "Executing winrm command: #{command}" if options[:progress]
+
+ @remote_id ||= @session.open_shell
+ command_id = @session.run_command(@remote_id, command)
+ output = @session.get_command_output(@remote_id, command_id) do |out,error|
+ if out
+ stdout += out
+ env.ui.info out,{:new_line => false} if options[:progress]
+ end
+ if error
+ stderr += error
+ env.ui.info error,{:new_line => false} if options[:progress]
+ end
+ end
+ status = output[:exitcode]
+ @session.close_shell(@remote_id)
+ @remote_id = nil
+ # env.ui.info "EXITCODE: #{status}" if status > 0
+ # @session.unbind
+ # FIXME: May want to look for a list of possible exitcodes
+ if (status.to_s != options[:exitcode] )
+ if (options[:exitcode]=="*")
+ #its a test so we don't need to worry
+ else
+ raise "Exitcode was not what we expected"
+ end
+
+ end
+
+ return Veewee::Provider::Core::Helper::WinrmResult.new(stdout,stderr,status)
+
+ end
+
+
+
+ end #Class
+ end #Module
+ end #Module
+ end #Module
+end #Module
View
2  lib/veewee/provider/parallels/box/helper/buildinfo.rb
@@ -36,7 +36,7 @@ def transfer_buildinfo(options)
ui.info "About to transfer parallels tools iso buildinfo to the box #{name} - #{ip_address} - #{ssh_options}"
iso_image=guest_iso_path
- self.scp(iso_image,File.basename(iso_image))
+ self.copy_to_box(iso_image,File.basename(iso_image))
end
end
View
1  lib/veewee/provider/virtualbox/box.rb
@@ -14,6 +14,7 @@
require 'veewee/provider/virtualbox/box/helper/forwarding'
require 'veewee/provider/virtualbox/box/helper/natinterface'
require 'veewee/provider/virtualbox/box/helper/ssh_options'
+require 'veewee/provider/virtualbox/box/helper/winrm_options'
require 'veewee/provider/virtualbox/box/helper/guest_additions'
require 'veewee/provider/virtualbox/box/helper/status'
require 'veewee/provider/virtualbox/box/helper/version'
View
24 lib/veewee/provider/virtualbox/box/create.rb
@@ -12,13 +12,6 @@ def create(options={})
raise Veewee::Error,"To create the vm '#{name}' the directory '#{box_directory}' needs to be empty. \nThis could be caused by an badly closed vm.\nRemove it manually before you proceed."
end
- guessed_port=guess_free_port(definition.ssh_host_port.to_i,definition.ssh_host_port.to_i+40).to_s
- if guessed_port.to_s!=definition.ssh_host_port
- env.ui.warn "Changing ssh port from #{definition.ssh_host_port} to #{guessed_port}"
- definition.ssh_host_port=guessed_port.to_s
- end
-
-
# Suppress those annoying virtualbox messages
self.suppress_messages
@@ -60,7 +53,22 @@ def create(options={})
self.add_floppy_controller
self.attach_floppy
- self.add_ssh_nat_mapping
+ if definition.winrm_user && definition.winrm_password # prefer winrm
+ env.ui.warn "Using winrm because winrm_user and winrm_password are both set"
+ guessed_port=guess_free_port(definition.winrm_host_port.to_i,definition.winrm_host_port.to_i+40).to_s
+ if guessed_port.to_s!=definition.winrm_host_port
+ env.ui.warn "Changing winrm port from #{definition.winrm_host_port} to #{guessed_port}"
+ definition.winrm_host_port=guessed_port.to_s
+ end
+ self.add_winrm_nat_mapping
+ else
+ guessed_port=guess_free_port(definition.ssh_host_port.to_i,definition.ssh_host_port.to_i+40).to_s
+ if guessed_port.to_s!=definition.ssh_host_port
+ env.ui.warn "Changing ssh port from #{definition.ssh_host_port} to #{guessed_port}"
+ definition.ssh_host_port=guessed_port.to_s
+ end
+ self.add_ssh_nat_mapping
+ end
end
View
9 lib/veewee/provider/virtualbox/box/helper/buildinfo.rb
@@ -14,9 +14,12 @@ def build_info
#
def transfer_buildinfo(options)
super(options)
- iso_image="VBoxGuestAdditions_#{self.vboxga_version}.iso"
- env.logger.info "About to transfer virtualbox guest additions iso to the box #{name} - #{ip_address} - #{ssh_options}"
- self.scp("#{File.join(env.config.veewee.iso_dir,iso_image)}",File.basename(iso_image))
+ # with windows, we just use the mounted volume
+ if not (definition.winrm_user && definition.winrm_password)
+ iso_image="VBoxGuestAdditions_#{self.vboxga_version}.iso"
+ env.logger.info "About to transfer virtualbox guest additions iso to the box #{name} - #{ip_address} - #{ssh_options}"
+ self.copy_to_box("#{File.join(env.config.veewee.iso_dir,iso_image)}",File.basename(iso_image))
+ end
end
end
View
9 lib/veewee/provider/virtualbox/box/helper/create.rb
@@ -31,6 +31,15 @@ def add_ssh_nat_mapping
end
end
+ def add_winrm_nat_mapping
+
+ unless definition.nil?
+ #Map SSH Ports
+ command="#{@vboxcmd} modifyvm '#{name}' --natpf1 'guestwinrm,tcp,,#{definition.winrm_host_port},,#{definition.winrm_guest_port}'"
+ shell_exec("#{command}")
+ end
+ end
+
def add_shared_folder
command="#{@vboxcmd} sharedfolder add \"#{name}\" --name \"veewee-validation\" --hostpath \"#{File.expand_path(env.validation_dir)}\" --automount"
shell_exec("#{command}")
View
31 lib/veewee/provider/virtualbox/box/helper/winrm_options.rb
@@ -0,0 +1,31 @@
+module Veewee
+ module Provider
+ module Virtualbox
+ module BoxCommand
+
+ def winrm_options
+ port=definition.winrm_host_port
+ if self.exists?
+ forward=self.forwarding("guestwinrm")
+ unless forward.nil?
+ port=forward[:host_port]
+ end
+ end
+
+ winrm_options={
+ :user => definition.winrm_user,
+ :pass => definition.winrm_password,
+ :port => port,
+# :port => (port.to_i+1).to_s, # debug, by running charles with a reverse proxy
+ :basic_auth_only => true,
+ :timeout => definition.winrm_login_timeout.to_i,
+ :operation_timeout => 600 # ten minutes
+ }
+ return winrm_options
+
+ end
+
+ end
+ end
+ end
+end
View
45 lib/veewee/provider/virtualbox/box/up.rb
@@ -13,20 +13,41 @@ def up(options={})
raise Veewee::Error,"Box is already running" if self.running?
- # Before we start,correct the ssh port if needed
- forward=self.forwarding("guestssh")
- guessed_port=guess_free_port(definition.ssh_host_port.to_i,definition.ssh_host_port.to_i+40).to_s
- definition.ssh_host_port=guessed_port.to_s
-
- unless forward.nil?
- if guessed_port!=forward[:guest_port]
- # Remove the existing one
- self.delete_forwarding("guestssh")
- ui.warn "Changing ssh port from #{forward[:guest_port]} to #{guessed_port}"
- self.add_ssh_nat_mapping
+ if definition.winrm_user && definition.winrm_password # prefer winrm
+ # Before we start,correct the ssh/winrm port if needed
+ forward=self.forwarding("guestwinrm")
+ guessed_port=guess_free_port(definition.winrm_host_port.to_i,definition.winrm_host_port.to_i+40).to_s
+ definition.winrm_host_port=guessed_port.to_s
+
+ unless forward.nil?
+ if guessed_port!=forward[:guest_port]
+ # Remove the existing one
+ self.delete_forwarding("guestwinrm")
+ env.ui.warn "Changing winrm port on UP from #{forward[:guest_port]} to #{guessed_port}"
+ self.add_winrm_nat_mapping
+ end
+ else
+ self.add_winrm_nat_mapping
end
+
else
- self.add_ssh_nat_mapping
+
+ # Before we start,correct the ssh port if needed
+ forward=self.forwarding("guestssh")
+ guessed_port=guess_free_port(definition.ssh_host_port.to_i,definition.ssh_host_port.to_i+40).to_s
+ definition.ssh_host_port=guessed_port.to_s
+
+ unless forward.nil?
+ if guessed_port!=forward[:guest_port]
+ # Remove the existing one
+ self.delete_forwarding("guestssh")
+ env.ui.warn "Changing ssh port from #{forward[:guest_port]} to #{guessed_port}"
+ self.add_ssh_nat_mapping
+ end
+ else
+ self.add_ssh_nat_mapping
+ end
+
end
self.suppress_messages
View
13 lib/veewee/provider/virtualbox/box/winrm.rb
@@ -0,0 +1,13 @@
+module Veewee
+ module Provider
+ module Virtualbox
+ module BoxCommand
+
+ def winrm(command,options={})
+ super(command,options)
+ end
+
+ end
+ end
+ end
+end
View
2  lib/veewee/provider/vmfusion/box/helper/buildinfo.rb
@@ -43,7 +43,7 @@ def transfer_buildinfo(options)
env.logger.info "About to transfer vmware tools iso buildinfo to the box #{name} - #{ip_address} - #{ssh_options}"
iso_image=guest_iso_path
if File.exists?(iso_image)
- self.scp(iso_image,File.basename(iso_image))
+ self.copy_to_box(iso_image,File.basename(iso_image))
else
raise Veewee::Error, "We could not find the file #{iso_image}. In newer versions of Fusion, you might have to download the Guest Additions yourself. You can do this by first manually creating a vm and than 'installing the guest additions'"
end
View
12 templates/windows-2008R1-serverstandard-amd64/Autounattend.xml
@@ -107,11 +107,11 @@
<!-- <Description>Install Chef Client</Description> -->
<!-- <Order>2</Order> -->
<!-- </SynchronousCommand> -->
- <SynchronousCommand wcm:action="add">
- <CommandLine>cmd.exe /c a:install-cygwin-sshd.bat</CommandLine>
- <Description>Install Cygwin SSHD</Description>
- <Order>2</Order>
- </SynchronousCommand>
+ <!-- <SynchronousCommand wcm:action="add"> -->
+ <!-- <CommandLine>cmd.exe /c a:install-cygwin-sshd.bat</CommandLine> -->
+ <!-- <Description>Install Cygwin SSHD</Description> -->
+ <!-- <Order>2</Order> -->
+ <!-- </SynchronousCommand> -->
<!-- needed wget -->
<!-- <SynchronousCommand wcm:action="add"> -->
<!-- <CommandLine>cmd.exe /c a:install-guest-additions.bat</CommandLine> -->
@@ -128,7 +128,7 @@
<HelpCustomized>false</HelpCustomized>
</OEMInformation>
<!-- Rename computer here. -->
- <ComputerName>vagrant-2008R1-serverstandard</ComputerName>
+ <ComputerName>vagrant-2008R1</ComputerName>
<TimeZone>New Zealand Standard Time</TimeZone>
<RegisteredOwner></RegisteredOwner>
</component>
View
2  templates/windows-2008R1-serverweb-amd64/install-winrm.bat
@@ -1,5 +1,5 @@
cmd /c winrm quickconfig -q
-cmd /c winrm quickconfig -transport:http # needs to be auto no questions asked
+cmd /c winrm quickconfig -transport:http
cmd /c winrm set winrm/config @{MaxTimeoutms="1800000"}
cmd /c winrm set winrm/config/winrs @{MaxMemoryPerShellMB="300"}
cmd /c winrm set winrm/config/service @{AllowUnencrypted="true"}
View
224 templates/windows-2008R2-serverstandard-amd64-winrm/Autounattend.xml
@@ -0,0 +1,224 @@
+<?xml version="1.0" encoding="utf-8"?>
+<unattend xmlns="urn:schemas-microsoft-com:unattend">
+ <servicing></servicing>
+
+ <settings pass="windowsPE">
+
+ <component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+ <DiskConfiguration>
+ <Disk wcm:action="add">
+
+ <CreatePartitions>
+ <CreatePartition wcm:action="add">
+ <Order>1</Order>
+ <Type>Primary</Type>
+ <Size>20000</Size>
+ </CreatePartition>
+ </CreatePartitions>
+
+ <ModifyPartitions>
+ <ModifyPartition wcm:action="add">
+ <Extend>false</Extend>
+ <Format>NTFS</Format>
+ <Letter>C</Letter>
+ <Order>1</Order>
+ <PartitionID>1</PartitionID>
+ <Label>Windows 2008R2</Label>
+ </ModifyPartition>
+ </ModifyPartitions>
+
+ <DiskID>0</DiskID>
+ <WillWipeDisk>true</WillWipeDisk>
+
+ </Disk>
+ <WillShowUI>OnError</WillShowUI>
+ </DiskConfiguration>
+
+ <UserData>
+ <!-- Product Key from http://technet.microsoft.com/en-us/library/ff793406.aspx -->
+ <ProductKey>YC6KT-GKW9T-YTKYR-T4X34-R7VHC
+ <WillShowUI>Never</WillShowUI>
+ </ProductKey>
+
+ <AcceptEula>true</AcceptEula>
+ <FullName>Vagrant Fullname</FullName>
+ <Organization>Vagrant Inc</Organization>
+ </UserData>
+
+ <ImageInstall>
+ <OSImage>
+ <InstallTo>
+ <DiskID>0</DiskID>
+ <PartitionID>1</PartitionID>
+ </InstallTo>
+ <WillShowUI>OnError</WillShowUI>
+ <InstallToAvailablePartition>false</InstallToAvailablePartition>
+ <InstallFrom>
+ <MetaData wcm:action="add">
+ <Key>/IMAGE/NAME</Key>
+ <Value>Windows Server 2008 R2 SERVERSTANDARD</Value>
+ </MetaData>
+ </InstallFrom>
+ </OSImage>
+ </ImageInstall>
+
+ </component>
+
+ <component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <SetupUILanguage>
+ <UILanguage>en-US</UILanguage>
+ </SetupUILanguage>
+ <InputLocale>en-US</InputLocale>
+ <SystemLocale>en-US</SystemLocale>
+ <UILanguage>en-US</UILanguage>
+ <UILanguageFallback>en-US</UILanguageFallback>
+ <UserLocale>en-US</UserLocale>
+ </component>
+ </settings>
+
+
+ <settings pass="oobeSystem">
+ <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <UserAccounts>
+ <AdministratorPassword>
+ <Value>dgBhAGcAcgBhAG4AdABBAGQAbQBpAG4AaQBzAHQAcgBhAHQAbwByAFAAYQBzAHMAdwBvAHIAZAA=</Value>
+ <PlainText>false</PlainText>
+ </AdministratorPassword>
+ <LocalAccounts>
+ <LocalAccount wcm:action="add">
+ <Password>
+ <Value>dgBhAGcAcgBhAG4AdABQAGEAcwBzAHcAbwByAGQA</Value>
+ <PlainText>false</PlainText>
+ </Password>
+ <Description>Vagrant User</Description>
+ <DisplayName>vagrant</DisplayName>
+ <Group>administrators</Group>
+ <Name>vagrant</Name>
+ </LocalAccount>
+ </LocalAccounts>
+ </UserAccounts>
+ <OOBE>
+ <HideEULAPage>true</HideEULAPage>
+ <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
+ <NetworkLocation>Home</NetworkLocation>
+ </OOBE>
+ <AutoLogon>
+ <Password>
+ <Value>dgBhAGcAcgBhAG4AdABQAGEAcwBzAHcAbwByAGQA</Value>
+ <PlainText>false</PlainText>
+ </Password>
+ <Username>administrator</Username>
+ <Enabled>true</Enabled>
+ </AutoLogon>
+ <FirstLogonCommands>
+ <!-- <SynchronousCommand wcm:action="add"> -->
+ <!-- <CommandLine>cmd.exe /c a:install-cygwin-sshd.bat</CommandLine> -->
+ <!-- <Description>Install Cygwin SSH</Description> -->
+ <!-- <Order>1</Order> -->
+ <!-- <RequiresUserInput>true</RequiresUserInput> -->
+ <!-- </SynchronousCommand> -->
+ <!-- <SynchronousCommand wcm:action="add"> -->
+ <!-- <CommandLine>cmd.exe /c a:install-winrm.bat</CommandLine> -->
+ <!-- <Description>Install Win RM</Description> -->
+ <!-- <Order>2</Order> -->
+ <!-- <RequiresUserInput>true</RequiresUserInput> -->
+ <!-- </SynchronousCommand> -->
+ <SynchronousCommand wcm:action="add">
+ <CommandLine>cmd.exe /c winrm quickconfig -q</CommandLine>
+ <Description>winrm quickconfig -q</Description>
+ <Order>1</Order>
+ <RequiresUserInput>true</RequiresUserInput>
+ </SynchronousCommand>
+ <SynchronousCommand wcm:action="add">
+ <CommandLine>cmd.exe /c winrm quickconfig -transport:http</CommandLine>
+ <Description>winrm quickconfig -transport:http</Description>
+ <Order>2</Order>
+ <RequiresUserInput>true</RequiresUserInput>
+ </SynchronousCommand>
+ <SynchronousCommand wcm:action="add">
+ <CommandLine>cmd.exe /c winrm set winrm/config @{MaxTimeoutms="1800000"}</CommandLine>
+ <Description>Win RM MaxTimoutms</Description>
+ <Order>3</Order>
+ <RequiresUserInput>true</RequiresUserInput>
+ </SynchronousCommand>
+ <SynchronousCommand wcm:action="add">
+ <CommandLine>cmd.exe /c winrm set winrm/config/winrs @{MaxMemoryPerShellMB="300"}</CommandLine>
+ <Description>Win RM MaxMemoryPerShellMB</Description>
+ <Order>4</Order>
+ <RequiresUserInput>true</RequiresUserInput>
+ </SynchronousCommand>
+ <SynchronousCommand wcm:action="add">
+ <CommandLine>cmd.exe /c winrm set winrm/config/service @{AllowUnencrypted="true"}</CommandLine>
+ <Description>Win RM AllowUnencrypted</Description>
+ <Order>5</Order>
+ <RequiresUserInput>true</RequiresUserInput>
+ </SynchronousCommand>
+ <SynchronousCommand wcm:action="add">
+ <CommandLine>cmd.exe /c winrm set winrm/config/service/auth @{Basic="true"}</CommandLine>
+ <Description>Win RM auth Basic</Description>
+ <Order>6</Order>
+ <RequiresUserInput>true</RequiresUserInput>
+ </SynchronousCommand>
+ <SynchronousCommand wcm:action="add">
+ <CommandLine>cmd.exe /c winrm set winrm/config/listener?Address=*+Transport=HTTP @{Port="5985"} </CommandLine>
+ <Description>Win RM listener Address/Port</Description>
+ <Order>7</Order>
+ <RequiresUserInput>true</RequiresUserInput>
+ </SynchronousCommand>
+ <SynchronousCommand wcm:action="add">
+ <CommandLine>cmd.exe /c netsh advfirewall firewall set rule group="remote administration" new enable=yes </CommandLine>
+ <Description>Win RM adv firewall enable</Description>
+ <Order>8</Order>
+ <RequiresUserInput>true</RequiresUserInput>
+ </SynchronousCommand>
+ <SynchronousCommand wcm:action="add">
+ <CommandLine>cmd.exe /c netsh firewall add portopening TCP 5985 "Port 5985" </CommandLine>
+ <Description>Win RM port open</Description>
+ <Order>9</Order>
+ <RequiresUserInput>true</RequiresUserInput>
+ </SynchronousCommand>
+ <SynchronousCommand wcm:action="add">
+ <CommandLine>cmd.exe /c net stop winrm </CommandLine>
+ <Description>Stop Win RM Service </Description>
+ <Order>10</Order>
+ <RequiresUserInput>true</RequiresUserInput>
+ </SynchronousCommand>
+ <SynchronousCommand wcm:action="add">
+ <CommandLine>cmd.exe /c sc config winrm start= auto</CommandLine>
+ <Description>Win RM Autostart</Description>
+ <Order>11</Order>
+ <RequiresUserInput>true</RequiresUserInput>
+ </SynchronousCommand>
+ <SynchronousCommand wcm:action="add">
+ <CommandLine>cmd.exe /c net start winrm </CommandLine>
+ <Description>Start Win RM Service</Description>
+ <Order>12</Order>
+ <RequiresUserInput>true</RequiresUserInput>
+ </SynchronousCommand>
+ <SynchronousCommand wcm:action="add">
+ <CommandLine>powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"</CommandLine>
+ <Description>Start Win RM Service</Description>
+ <Order>13</Order>
+ <RequiresUserInput>true</RequiresUserInput>
+ </SynchronousCommand>
+ </FirstLogonCommands>
+ <ShowWindowsLive>false</ShowWindowsLive>
+ </component>
+ </settings>
+ <settings pass="specialize">
+ <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" >
+ <OEMInformation>
+ <HelpCustomized>false</HelpCustomized>
+ </OEMInformation>
+ <!-- Rename computer here. -->
+ <ComputerName>vagrant-2008R2</ComputerName>
+ <TimeZone>Pacific Standard Time</TimeZone>
+ <RegisteredOwner></RegisteredOwner>
+ </component>
+ <component name="Microsoft-Windows-Security-SPP-UX" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <SkipAutoActivation>true</SkipAutoActivation>
+ </component>
+ </settings>
+ <cpi:offlineImage cpi:source="catalog:d:/sources/install_windows server 2008 r2 serverdatacenter.clg" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
+</unattend>
View
87 templates/windows-2008R2-serverstandard-amd64-winrm/README.md
@@ -0,0 +1,87 @@
+You can download a free trial of Windows Server 2008 R2 with Service Pack 1 from two different locations manually:
+
+* url: http://technet.microsoft.com/en-us/evalcenter/dd459137.aspx
+* url: http://msdn.microsoft.com/en-us/evalcenter/ee175713.aspx
+
+But they seem to always generate the same url of http://care.dlservice.microsoft.com//dl/download/7/5/E/75EC4E54-5B02-42D6-8879-D8D3A25FBEF7/7601.17514.101119-1850_x64fre_server_eval_en-us-GRMSXEVAL_EN_DVD.iso
+
+* 64bit
+* filename: 7601.17514.101119-1850_x64fre_server_eval_en-us-GRMSXEVAL_EN_DVD.iso
+* md5sum: 4263be2cf3c59177c45085c0a7bc6ca5
+
+
+The installation uses the Standard Windows Unattended installation. The XML file was created using the Windows AIK kit, but the file can also be edited by hand.
+
+To edit the Autounattend.xml and validate it you can download The Windows® Automated Installation Kit (AIK) for Windows® 7:
+
+* url: http://www.microsoft.com/download/en/details.aspx?id=5753
+* file: KB3AIK_EN.iso
+* md5sum: 1e73b24a89eceab9d50585b92db5482f
+
+AIK also includes dism, which will allow you to choose a specific version:
+
+If you want to install a different version, edit Autoattended.xml and replace the /IMAGE/NAME value with
+one of the names listed in the 2008r2 install.wim on the install DVD .iso
+
+
+```xml
+<InstallFrom>
+ <MetaData wcm:action="add">
+ <Key>/IMAGE/NAME</Key>
+ <Value>Windows Server 2008 R2 SERVERSTANDARD</Value>
+ </MetaData>
+</InstallFrom>
+```
+
+
+```
+PS C:\Users\Administrator> Dism /Get-WIMInfo /WimFile:d:\sources\install.wim
+
+Deployment Image Servicing and Management tool
+Version: 6.1.7600.16385
+
+Details for image : d:\sources\install.wim
+
+Index : 1
+Name : Windows Server 2008 R2 SERVERSTANDARD
+Description : Windows Server 2008 R2 SERVERSTANDARD
+Size : 10,510,643,622 bytes
+
+Index : 2
+Name : Windows Server 2008 R2 SERVERSTANDARDCORE
+Description : Windows Server 2008 R2 SERVERSTANDARDCORE
+Size : 3,564,132,307 bytes
+
+Index : 3
+Name : Windows Server 2008 R2 SERVERENTERPRISE
+Description : Windows Server 2008 R2 SERVERENTERPRISE
+Size : 10,511,024,733 bytes
+
+Index : 4
+Name : Windows Server 2008 R2 SERVERENTERPRISECORE
+Description : Windows Server 2008 R2 SERVERENTERPRISECORE
+Size : 3,564,106,331 bytes
+
+Index : 5
+Name : Windows Server 2008 R2 SERVERDATACENTER
+Description : Windows Server 2008 R2 SERVERDATACENTER
+Size : 10,511,131,897 bytes
+
+Index : 6
+Name : Windows Server 2008 R2 SERVERDATACENTERCORE
+Description : Windows Server 2008 R2 SERVERDATACENTERCORE
+Size : 3,564,144,547 bytes
+
+Index : 7
+Name : Windows Server 2008 R2 SERVERWEB
+Description : Windows Server 2008 R2 SERVERWEB
+Size : 10,520,222,743 bytes
+
+Index : 8
+Name : Windows Server 2008 R2 SERVERWEBCORE
+Description : Windows Server 2008 R2 SERVERWEBCORE
+Size : 3,562,750,400 bytes
+
+The operation completed successfully.
+```
+
View
33 templates/windows-2008R2-serverstandard-amd64-winrm/definition.rb
@@ -0,0 +1,33 @@
+# -*- coding: utf-8 -*-
+Veewee::Session.declare({
+ :os_type_id => 'Windows2008_64',
+ # http://technet.microsoft.com/en-us/evalcenter/dd459137.aspx
+ # Download and install full featured software for 180-day trial
+ :iso_file => "7601.17514.101119-1850_x64fre_server_eval_en-us-GRMSXEVAL_EN_DVD.iso",
+ :iso_md5 => "4263be2cf3c59177c45085c0a7bc6ca5",
+ :iso_src => "http://care.dlservice.microsoft.com//dl/download/7/5/E/75EC4E54-5B02-42D6-8879-D8D3A25FBEF7/7601.17514.101119-1850_x64fre_server_eval_en-us-GRMSXEVAL_EN_DVD.iso",
+ :iso_download_timeout => "1000",
+ :cpu_count => '1',
+ :memory_size=> '384',
+ :disk_size => '20280', :disk_format => 'VDI', :hostiocache => 'off',
+
+ :floppy_files => [
+ "Autounattend.xml",
+ "oracle-cert.cer"
+ ],
+
+ :boot_wait => "1",
+ :boot_cmd_sequence => [''],
+ :winrm_user => "vagrant", :winrm_password => "vagrant",
+ :kickstart_port => "7100",
+ :postinstall_timeout => "10000",
+ :postinstall_files => [
+ "install-chef.bat",
+ "install-vbox.bat"
+ ],
+ :sudo_cmd => "%f",
+ :shutdown_cmd => "shutdown /s /t 10 /f /d p:4:1 /c \"Vagrant Shutdown\"" ,
+ # :shutdown_cmd => "shutdown /s /t 60 /d p:4:1 /c \"Vagrant Shutdown\"",
+})
+
+
View
2  templates/windows-2008R2-serverstandard-amd64-winrm/install-chef.bat
@@ -0,0 +1,2 @@
+cmd /C cscript %TEMP%\wget.vbs /url:http://www.opscode.com/chef/install.msi /path:%TEMP%\chef-client.msi
+cmd /C msiexec /qn /i %TEMP%\chef-client.msi
View
4 templates/windows-2008R2-serverstandard-amd64-winrm/install-vbox.bat
@@ -0,0 +1,4 @@
+# with this, we can open the iso, and extract the VBoxWindowsAdditions.exe!
+# http://downloads.sourceforge.net/sevenzip/7z920.exe
+cmd /c certutil -addstore -f "TrustedPublisher" a:oracle-cert.cer
+cmd /c e:\VBoxWindowsAdditions-amd64.exe /S
View
BIN  templates/windows-2008R2-serverstandard-amd64-winrm/oracle-cert.cer
Binary file not shown
View
74 templates/windows-2008R2-serverstandard-amd64-winrm/postinstall.sh
@@ -0,0 +1,74 @@
+set -x
+
+# Create the home directory
+mkdir -p /home/vagrant
+chown vagrant /home/vagrant
+cd /home/vagrant
+
+# Install ssh certificates
+mkdir /home/vagrant/.ssh
+chmod 700 /home/vagrant/.ssh
+cd /home/vagrant/.ssh
+wget --no-check-certificate 'https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub' -O authorized_keys
+chown -R vagrant /home/vagrant/.ssh
+cd ..
+
+# Install rpm,apt-get like code for cygwin
+# http://superuser.com/questions/40545/upgrading-and-installing-packages-through-the-cygwin-command-line
+wget http://apt-cyg.googlecode.com/svn/trunk/apt-cyg
+chmod +x apt-cyg
+mv apt-cyg /usr/local/bin/
+
+# 7zip will allow us to extract a file from an ISO
+wget http://downloads.sourceforge.net/sevenzip/7z920-x64.msi
+msiexec /qb /i 7z920-x64.msi
+
+# Download Virtualbox Additions
+VBOX_VERSION="4.1.8" #"4.0.8"
+wget http://download.virtualbox.org/virtualbox/$VBOX_VERSION/VBoxGuestAdditions_$VBOX_VERSION.iso
+
+# Extract the installer from the ISO (WHY WHY WHY isn't this available not bundled within an ISO)
+/cygdrive/c/Program\ Files/7-Zip/7z.exe x VBoxGuestAdditions_$VBOX_VERSION.iso VBoxWindowsAdditions-amd64.exe
+
+# Mark Oracle as a trusted installer
+#http://blogs.msdn.com/b/steverac/archive/2009/07/09/adding-certificates-to-the-local-certificates-store-and-setting-local-policy-using-a-command-line-system-center-updates-publisher-example.aspx
+
+certutil -addstore -f "TrustedPublisher" a:oracle-cert.cer
+
+# Install the Virtualbox Additions
+./VBoxWindowsAdditions-amd64.exe /S
+
+
+#Rather than do the manual install of ruby and chef, just use the opscode msi
+curl -L http://www.opscode.com/chef/install.msi -o chef-client-latest.msi
+msiexec /qb /i chef-client-latest.msi
+
+
+#http://www.msfn.org/board/topic/105277-howto-create-a-fully-up-to-date-xp-x64-dvd/
+
+#Making aliases
+cat <<EOF > /home/vagrant/.bash_profile
+alias chef-client="chef-client.bat"
+alias gem="gem.bat"
+alias ruby="ruby.exe"
+alias puppet="puppet.bat"
+alias ohai="ohai.bat"
+alias irb="irb.bat"
+alias facter="facter.bat"
+EOF
+
+
+cat <<'EOF' > /bin/sudo
+#!/usr/bin/bash
+exec "$@"
+EOF
+chmod 755 /bin/sudo
+
+# Mounting a directory
+net.exe use '\\vboxsvr\veewee-validation'
+
+
+# Reboot
+# http://www.techrepublic.com/blog/datacenter/restart-windows-server-2003-from-the-command-line/245
+shutdown.exe /r /t 0 /d p:2:4 /c "Vagrant initial reboot"
+
View
227 templates/windows-7-enterprise-amd64-winrm/Autounattend.xml
@@ -0,0 +1,227 @@
+<?xml version="1.0" encoding="utf-8"?>
+<unattend xmlns="urn:schemas-microsoft-com:unattend">
+ <servicing></servicing>
+ <settings pass="windowsPE">
+ <component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <DiskConfiguration>
+ <Disk wcm:action="add">
+ <CreatePartitions>
+ <CreatePartition wcm:action="add">
+ <Order>1</Order>
+ <Type>Primary</Type>
+ <Size>20000</Size>
+ </CreatePartition>
+ </CreatePartitions>
+ <ModifyPartitions>
+ <ModifyPartition wcm:action="add">
+ <Extend>false</Extend>
+ <Format>NTFS</Format>
+ <Letter>C</Letter>
+ <Order>1</Order>
+ <PartitionID>1</PartitionID>
+ <Label>Windows 7 Enterprise</Label>
+ </ModifyPartition>
+ </ModifyPartitions>
+ <DiskID>0</DiskID>
+ <WillWipeDisk>true</WillWipeDisk>
+ </Disk>
+ <WillShowUI>OnError</WillShowUI>
+ </DiskConfiguration>
+ <UserData>
+ <ProductKey>
+ <WillShowUI>Never</WillShowUI>
+ </ProductKey>
+ <AcceptEula>true</AcceptEula>
+ <FullName>Vagrant Fullname</FullName>
+ <Organization>Vagrant Inc</Organization>
+ </UserData>
+ <ImageInstall>
+ <OSImage>
+ <InstallTo>
+ <DiskID>0</DiskID>
+ <PartitionID>1</PartitionID>
+ </InstallTo>
+ <WillShowUI>OnError</WillShowUI>
+ <InstallToAvailablePartition>false</InstallToAvailablePartition>
+ <InstallFrom>
+ <MetaData wcm:action="add">
+ <Key>/IMAGE/NAME</Key>
+ <Value>Windows 7 ENTERPRISE</Value>
+ </MetaData>
+ </InstallFrom>
+ </OSImage>
+ </ImageInstall>
+ </component>
+ <component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <SetupUILanguage>
+ <UILanguage>en-US</UILanguage>
+ </SetupUILanguage>
+ <InputLocale>en-US</InputLocale>
+ <SystemLocale>en-US</SystemLocale>
+ <UILanguage>en-US</UILanguage>
+ <UILanguageFallback>en-US</UILanguageFallback>
+ <UserLocale>en-US</UserLocale>
+ </component>
+ </settings>
+ <settings pass="oobeSystem">
+ <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <UserAccounts>
+ <AdministratorPassword>
+ <Value>ZABnAEIAaABBAEcAYwBBAGMAZwBCAGgAQQBHADQAQQBkAEEAQgBRAEEARwBFAEEAYwB3AEIAegBBAEgAYwBBAGIAdwBCAHkAQQBHAFEAQQBBAGQAbQBpAG4AaQBzAHQAcgBhAHQAbwByAFAAYQBzAHMAdwBvAHIAZAA=</Value>
+ <PlainText>false</PlainText>
+ </AdministratorPassword>
+ <LocalAccounts>
+ <LocalAccount wcm:action="add">
+ <Password>
+ <Value>dgBhAGcAcgBhAG4AdABQAGEAcwBzAHcAbwByAGQA</Value>
+ <PlainText>false</PlainText>
+ </Password>
+ <Description>Vagrant User</Description>
+ <DisplayName>vagrant</DisplayName>
+ <Group>administrators</Group>
+ <Name>vagrant</Name>
+ </LocalAccount>
+ </LocalAccounts>
+ </UserAccounts>
+ <OOBE>
+ <HideEULAPage>true</HideEULAPage>
+ <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
+ <NetworkLocation>Work</NetworkLocation>
+ <ProtectYourPC>3</ProtectYourPC>
+ </OOBE>
+ <AutoLogon>
+ <Password>
+ <Value>dgBhAGcAcgBhAG4AdABQAGEAcwBzAHcAbwByAGQA</Value>
+ <PlainText>false</PlainText>
+ </Password>
+ <Username>vagrant</Username>
+ <Enabled>true</Enabled>
+ </AutoLogon>
+ <FirstLogonCommands>
+ <!-- <SynchronousCommand wcm:action="add"> -->
+ <!-- <CommandLine>cmd.exe /c a:install-cygwin-sshd.bat</CommandLine> -->
+ <!-- <Description>Install Cygwin SSH</Description> -->
+ <!-- <Order>1</Order> -->
+ <!-- <RequiresUserInput>true</RequiresUserInput> -->
+ <!-- </SynchronousCommand> -->
+ <!-- <SynchronousCommand wcm:action="add"> -->
+ <!-- <CommandLine>cmd.exe /c a:install-vbox-guest.bat</CommandLine> -->
+ <!-- <Description>Install Win RM</Description> -->
+ <!-- <Order>1</Order> -->
+ <!-- <RequiresUserInput>true</RequiresUserInput> -->
+ <!-- </SynchronousCommand> -->
+ <SynchronousCommand wcm:action="add">
+ <CommandLine>cmd.exe /c winrm quickconfig -q</CommandLine>
+ <Description>winrm quickconfig -q</Description>
+ <Order>1</Order>
+ <RequiresUserInput>true</RequiresUserInput>
+ </SynchronousCommand>
+ <SynchronousCommand wcm:action="add">
+ <CommandLine>cmd.exe /c winrm quickconfig -transport:http</CommandLine>
+ <Description>winrm quickconfig -transport:http</Description>
+ <Order>2</Order>
+ <RequiresUserInput>true</RequiresUserInput>
+ </SynchronousCommand>
+ <SynchronousCommand wcm:action="add">
+ <CommandLine>cmd.exe /c winrm set winrm/config @{MaxTimeoutms="1800000"}</CommandLine>
+ <Description>Win RM MaxTimoutms</Description>
+ <Order>3</Order>
+ <RequiresUserInput>true</RequiresUserInput>
+ </SynchronousCommand>
+ <SynchronousCommand wcm:action="add">
+ <CommandLine>cmd.exe /c winrm set winrm/config/winrs @{MaxMemoryPerShellMB="300"}</CommandLine>
+ <Description>Win RM MaxMemoryPerShellMB</Description>
+ <Order>4</Order>
+ <RequiresUserInput>true</RequiresUserInput>
+ </SynchronousCommand>
+ <SynchronousCommand wcm:action="add">
+ <CommandLine>cmd.exe /c winrm set winrm/config/service @{AllowUnencrypted="true"}</CommandLine>
+ <Description>Win RM AllowUnencrypted</Description>
+ <Order>5</Order>
+ <RequiresUserInput>true</RequiresUserInput>
+ </SynchronousCommand>
+ <SynchronousCommand wcm:action="add">
+ <CommandLine>cmd.exe /c winrm set winrm/config/service/auth @{Basic="true"}</CommandLine>
+ <Description>Win RM auth Basic</Description>
+ <Order>6</Order>
+ <RequiresUserInput>true</RequiresUserInput>
+ </SynchronousCommand>
+ <SynchronousCommand wcm:action="add">
+ <CommandLine>cmd.exe /c winrm set winrm/config/listener?Address=*+Transport=HTTP @{Port="5985"} </CommandLine>
+ <Description>Win RM listener Address/Port</Description>
+ <Order>7</Order>
+ <RequiresUserInput>true</RequiresUserInput>
+ </SynchronousCommand>
+ <SynchronousCommand wcm:action="add">
+ <CommandLine>cmd.exe /c netsh advfirewall firewall set rule group="remote administration" new enable=yes </CommandLine>
+ <Description>Win RM adv firewall enable</Description>
+ <Order>8</Order>
+ <RequiresUserInput>true</RequiresUserInput>
+ </SynchronousCommand>
+ <SynchronousCommand wcm:action="add">
+ <CommandLine>cmd.exe /c netsh firewall add portopening TCP 5985 "Port 5985" </CommandLine>
+ <Description>Win RM port open</Description>
+ <Order>9</Order>
+ <RequiresUserInput>true</RequiresUserInput>
+ </SynchronousCommand>
+ <SynchronousCommand wcm:action="add">
+ <CommandLine>cmd.exe /c net stop winrm </CommandLine>
+ <Description>Stop Win RM Service </Description>
+ <Order>10</Order>
+ <RequiresUserInput>true</RequiresUserInput>
+ </SynchronousCommand>
+ <SynchronousCommand wcm:action="add">
+ <CommandLine>cmd.exe /c sc config winrm start= auto</CommandLine>
+ <Description>Win RM Autostart</Description>
+ <Order>11</Order>
+ <RequiresUserInput>true</RequiresUserInput>
+ </SynchronousCommand>
+ <SynchronousCommand wcm:action="add">
+ <CommandLine>cmd.exe /c net start winrm </CommandLine>
+ <Description>Start Win RM Service</Description>
+ <Order>12</Order>
+ <RequiresUserInput>true</RequiresUserInput>
+ </SynchronousCommand>
+ <SynchronousCommand wcm:action="add">
+ <CommandLine>powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"</CommandLine>
+ <Description>Start Win RM Service</Description>
+ <Order>13</Order>
+ <RequiresUserInput>true</RequiresUserInput>
+ </SynchronousCommand>
+ </FirstLogonCommands>
+ <ShowWindowsLive>false</ShowWindowsLive>
+ </component>
+ </settings>
+ <settings pass="specialize">
+ <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
+ <OEMInformation>
+ <HelpCustomized>false</HelpCustomized>
+ </OEMInformation>
+ <!-- Rename computer here. -->
+ <ComputerName>vagrant-win7ent</ComputerName>
+ <TimeZone>Pacific Standard Time</TimeZone>
+ <RegisteredOwner>Vagrant</RegisteredOwner>
+ <ShowWindowsLive>false</ShowWindowsLive>
+ </component>
+ <component name="Microsoft-Windows-Security-SPP-UX" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <SkipAutoActivation>true</SkipAutoActivation>
+ </component>
+ <component name="Security-Malware-Windows-Defender" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <DisableAntiSpyware>true</DisableAntiSpyware>
+ </component>
+ <component name="Microsoft-Windows-SystemRestore-Main" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <DisableSR>1</DisableSR>
+ </component>
+ </settings>
+ <settings pass="generalize">
+ <component name="Microsoft-Windows-Security-SPP" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <SkipRearm>1</SkipRearm>
+ </component>
+ </settings>
+ <settings pass="offlineServicing">
+ <component name="Microsoft-Windows-LUA-Settings" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <EnableLUA>false</EnableLUA>
+ </component>
+ </settings>
+ <cpi:offlineImage cpi:source="catalog:d:/sources/install_windows 7 enterprise.clg" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
+</unattend>
View
52 templates/windows-7-enterprise-amd64-winrm/README.md
@@ -0,0 +1,52 @@
+You can download a free trial of Windows 7 Enterprise 90-day Trial
+
+url: http://technet.microsoft.com/en-us/evalcenter/cc442495.aspx
+file: 7600.16385.090713-1255_x64fre_enterprise_en-us_EVAL_Eval_Enterprise-GRMCENXEVAL_EN_DVD.iso
+md5sum: 1d0d239a252cb53e466d39e752b17c28
+
+'''
+PS C:\Users\Administrator> Dism /Get-WIMInfo /WimFile:d:\sources\install.wim
+
+Deployment Image Servicing and Management tool
+Version: 6.1.7600.16385
+
+Details for image : d:\sources\install.wim
+
+Index : 1
+Name : Windows 7 ENTERPRISE
+Description : Windows 7 ENTERPRISE
+Size : 11,913,037,777 bytes
+
+The operation completed successfully.
+'''
+
+- place it in a directory called iso
+
+The installation uses the Standard way for Windows Unattended installation.
+The XML file was created using the Windows AIK kit, but the file can also be edited by hand.
+
+To edit the Autounattend.xml and validate it:
+
+You can download The Windows® Automated Installation Kit (AIK) for Windows® 7:
+url: http://www.microsoft.com/download/en/details.aspx?id=5753
+file: KB3AIK_EN.iso
+md5sum: 1e73b24a89eceab9d50585b92db5482f
+
+- Building the machine creates a floppy that contains:
+ - AutoUnattend.xml (that will configure the windows)
+ - winrm-install.bat (activates the http and https listener + punches the firewall hole)
+
+AIK also includes dism, which will allow you to choose a specific version:
+
+If you want to install a different version, edit Autoattended.xml and replace the /IMAGE/NAME value with
+one of the names listed in the sources/install.wim on the install DVD .iso
+
+
+
+# Use the Name : from 'Dism.exe /Get-WIMInfo /WimFile:d:\sources\install.wim'
+# <InstallFrom>
+# <MetaData wcm:action="add">
+# <Key>/IMAGE/NAME</Key>
+# <Value>Windows 7 ENTERPRISE</Value>
+# </MetaData>
+# </InstallFrom>
View
26 templates/windows-7-enterprise-amd64-winrm/definition.rb
@@ -0,0 +1,26 @@
+# -*- coding: utf-8 -*-
+#video memory size should be at least 32meg for windows 7 to do full screen on my desktop
+# I'm not sure how to set that with veewee::session yet
+Veewee::Session.declare({
+ :os_type_id => 'Windows7_64',
+ # Windows 7 Enterprise 90-day Trial
+ # http://technet.microsoft.com/en-us/evalcenter/cc442495.aspx
+ :iso_file => "7600.16385.090713-1255_x64fre_enterprise_en-us_EVAL_Eval_Enterprise-GRMCENXEVAL_EN_DVD.iso",
+ :iso_src => "http://wb.dlservice.microsoft.com/dl/download/release/Win7/3/b/a/3bac7d87-8ad2-4b7a-87b3-def36aee35fa/7600.16385.090713-1255_x64fre_enterprise_en-us_EVAL_Eval_Enterprise-GRMCENXEVAL_EN_DVD.iso",
+ :iso_md5 => "1d0d239a252cb53e466d39e752b17c28",
+ :iso_download_timeout => "100000",
+ :cpu_count => '1',
+ :memory_size=> '512',
+ :disk_size => '20280', :disk_format => 'VDI', :hostiocache => 'off',
+ :floppy_files => [
+ "Autounattend.xml",
+ "oracle-cert.cer"
+ ],
+ :winrm_user => "vagrant", :winrm_password => "vagrant",
+ :postinstall_timeout => "10000",
+ :postinstall_files => [
+ "install-chef.bat",
+ "install-vbox.bat"
+ ],
+ :shutdown_cmd => "shutdown /s /t 10 /c \"Vagrant Shutdown\" /f /d p:4:1",
+ })
View
2  templates/windows-7-enterprise-amd64-winrm/install-chef.bat
@@ -0,0 +1,2 @@
+cmd /C cscript %TEMP%\wget.vbs /url:http://www.opscode.com/chef/install.msi /path:%TEMP%\chef-client.msi
+cmd /C msiexec /qn /i %TEMP%\chef-client.msi
View
4 templates/windows-7-enterprise-amd64-winrm/install-vbox.bat
@@ -0,0 +1,4 @@
+# with this, we can open the iso, and extract the VBoxWindowsAdditions.exe!
+# http://downloads.sourceforge.net/sevenzip/7z920.exe
+cmd /c certutil -addstore -f "TrustedPublisher" a:oracle-cert.cer
+cmd /c e:\VBoxWindowsAdditions-amd64.exe /S
View
BIN  templates/windows-7-enterprise-amd64-winrm/oracle-cert.cer
Binary file not shown
View
74 templates/windows-7-enterprise-amd64-winrm/postinstall.bat
@@ -0,0 +1,74 @@
+REM set -x
+
+REM # Create the home directory
+REM mkdir -p /home/vagrant
+REM chown vagrant /home/vagrant
+REM cd /home/vagrant
+
+REM # Install ssh certificates
+REM mkdir /home/vagrant/.ssh
+REM chmod 700 /home/vagrant/.ssh
+REM cd /home/vagrant/.ssh
+REM wget --no-check-certificate 'https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub' -O authorized_keys
+REM chown -R vagrant /home/vagrant/.ssh
+REM cd ..
+
+REM # Install rpm,apt-get like code for cygwin
+REM # http://superuser.com/questions/40545/upgrading-and-installing-packages-through-the-cygwin-command-line
+REM wget http://apt-cyg.googlecode.com/svn/trunk/apt-cyg
+REM chmod +x apt-cyg
+REM mv apt-cyg /usr/local/bin/
+
+REM # 7zip will allow us to extract a file from an ISO
+REM wget http://downloads.sourceforge.net/sevenzip/7z922-x64.msi
+REM msiexec /qb /i 7z922-x64.msi
+
+REM # Download Virtualbox Additions
+REM VBOX_VERSION="4.1.8" #"4.0.8"
+REM wget http://download.virtualbox.org/virtualbox/$VBOX_VERSION/VBoxGuestAdditions_$VBOX_VERSION.iso
+
+REM # Extract the installer from the ISO (WHY WHY WHY isn't this available not bundled within an ISO)
+REM /cygdrive/c/Program\ Files/7-Zip/7z.exe x VBoxGuestAdditions_$VBOX_VERSION.iso VBoxWindowsAdditions-amd64.exe
+
+REM # Mark Oracle as a trusted installer
+REM #http://blogs.msdn.com/b/steverac/archive/2009/07/09/adding-certificates-to-the-local-certificates-store-and-setting-local-policy-using-a-command-line-system-center-updates-publisher-example.aspx
+
+REM certutil -addstore -f "TrustedPublisher" a:oracle-cert.cer
+
+REM # Install the Virtualbox Additions
+REM ./VBoxWindowsAdditions-amd64.exe /S
+
+
+REM #Rather than do the manual install of ruby and chef, just use the opscode msi
+cmd /C cscript %TEMP%\wget.vbs /url:http://www.opscode.com/chef/install.msi /path:%TEMP%\chef-client.msi
+msiexec /qb /i %TEMP%\chef-client-latest.msi
+
+
+REM #http://www.msfn.org/board/topic/105277-howto-create-a-fully-up-to-date-xp-x64-dvd/
+
+REM #Making aliases
+REM cat <<EOF > /home/vagrant/.bash_profile
+REM alias chef-client="chef-client.bat"
+REM alias gem="gem.bat"
+REM alias ruby="ruby.exe"
+REM alias puppet="puppet.bat"
+REM alias ohai="ohai.bat"
+REM alias irb="irb.bat"
+REM alias facter="facter.bat"
+REM EOF
+
+
+REM cat <<'EOF' > /bin/sudo
+REM #!/usr/bin/bash
+REM exec "$@"
+REM EOF
+REM chmod 755 /bin/sudo
+
+REM # Mounting a directory
+REM net.exe use '\\vboxsvr\veewee-validation'
+
+
+REM # Reboot
+REM # http://www.techrepublic.com/blog/datacenter/restart-windows-server-2003-from-the-command-line/245
+REM shutdown.exe /s /t 0 /d p:2:4 /c "Vagrant initial reboot"
+
View
34 validation/veewee-windows.feature
@@ -0,0 +1,34 @@
+Feature: veewee box validation
+ As a valid veewee box
+ I need to comply to a set of rules
+ In order to make sure it works on Windows with Winrm
+
+ @vmfusion @virtualbox @kvm
+ Scenario: Valid definition
+ Given a veeweebox was build
+ And I run "whoami" over ssh
+ Then I should see the provided username in the output
+
+ @vmfusion @virtualbox @kvm
+ Scenario: Checking ruby
+ Given a veeweebox was build
+ And I run "ruby --version > %TEMP%\devnull && echo %ERRORLEVEL%" over ssh
+ Then I should see "0" in the output
+
+ @vmfusion @virtualbox @kvm
+ Scenario: Checking gem
+ Given a veeweebox was build
+ And I run "gem --version > %TEMP%\devnull && echo %ERRORLEVEL%" over ssh
+ Then I should see "0" in the output
+
+ @vmfusion @virtualbox @kvm
+ Scenario: Checking chef
+ Given a veeweebox was build
+ And I run "chef-client --version > %TEMP%\devnull && echo %ERRORLEVEL%" over ssh
+ Then I should see "0" in the output
+
+ @vagrant
+ Scenario: Checking shared folders
+ Given a veeweebox was build
+ And I run "net use|grep veewee-validation" over ssh
+ Then I should see "veewee-validation" in the output
View
2  veewee.gemspec
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
s.add_dependency "net-ssh", "~> 2.2.0"
s.add_dependency "popen4", "~> 0.1.2"
- s.add_dependency "thor", "> 0.14"
+ s.add_dependency "thor", "~> 0.15"
s.add_dependency "highline"
s.add_dependency "progressbar"
s.add_dependency "i18n"
Please sign in to comment.
<