lib/chef/provisioning/convergence_strategy/install_msi.rb in chef-provisioning-1.3.0 vs lib/chef/provisioning/convergence_strategy/install_msi.rb in chef-provisioning-1.4.0

- old
+ new

@@ -18,14 +18,15 @@ attr_reader :install_msi_url attr_reader :install_msi_path def setup_convergence(action_handler, machine) if !convergence_options.has_key?(:client_rb_path) || !convergence_options.has_key?(:client_pem_path) - system_drive = machine.execute_always('$env:SystemDrive').stdout.strip + system_drive = machine.system_drive @convergence_options = Cheffish::MergedConfig.new(convergence_options, { :client_rb_path => "#{system_drive}\\chef\\client.rb", - :client_pem_path => "#{system_drive}\\chef\\client.pem" + :client_pem_path => "#{system_drive}\\chef\\client.pem", + :install_script_path => "#{system_drive}\\chef\\\install.ps1" }) end opts = {"prerelease" => prerelease} if convergence_options[:bootstrap_proxy] @@ -34,20 +35,30 @@ end opts["install_msi_url"] = convergence_options[:install_msi_url] if convergence_options[:install_msi_url] super install_command = Mixlib::Install.new(chef_version, true, opts).install_command - machine.execute(action_handler, install_command) + machine.write_file(action_handler, convergence_options[:install_script_path], install_command) + + action_handler.open_stream(machine.node['name']) do |stdout| + action_handler.open_stream(machine.node['name']) do |stderr| + machine.execute(action_handler, "powershell.exe -ExecutionPolicy Unrestricted -NoProfile \"& \"\"#{convergence_options[:install_script_path]}\"\"\"", + :raw => true, + :stream_stdout => stdout, + :stream_stderr => stderr) + end + end end def converge(action_handler, machine) super action_handler.open_stream(machine.node['name']) do |stdout| action_handler.open_stream(machine.node['name']) do |stderr| command_line = "chef-client" command_line << " -l #{config[:log_level].to_s}" if config[:log_level] machine.execute(action_handler, command_line, + :raw => true, :stream_stdout => stdout, :stream_stderr => stderr, :timeout => @chef_client_timeout) end end