From ed1bc587354c1c8474af521edfcbc5df6aecff50 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 21 Aug 2012 16:57:59 -0700 Subject: [PATCH] Fix shell provisioner to run with new machine abstraction --- plugins/provisioners/shell/provisioner.rb | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/plugins/provisioners/shell/provisioner.rb b/plugins/provisioners/shell/provisioner.rb index f2a234fec..19a4c1096 100644 --- a/plugins/provisioners/shell/provisioner.rb +++ b/plugins/provisioners/shell/provisioner.rb @@ -76,18 +76,20 @@ module VagrantPlugins command = "chmod +x #{config.upload_path} && #{config.upload_path}#{args}" with_script_file do |path| - # Upload the script to the VM - env[:vm].channel.upload(path.to_s, config.upload_path) + # Upload the script to the machine + env[:machine].communicate.tap do |comm| + comm.upload(path.to_s, config.upload_path) - # Execute it with sudo - env[:vm].channel.sudo(command) do |type, data| - if [:stderr, :stdout].include?(type) - # Output the data with the proper color based on the stream. - color = type == :stdout ? :green : :red + # Execute it with sudo + comm.sudo(command) do |type, data| + if [:stderr, :stdout].include?(type) + # Output the data with the proper color based on the stream. + color = type == :stdout ? :green : :red - # Note: Be sure to chomp the data to avoid the newlines that the - # Chef outputs. - env[:ui].info(data.chomp, :color => color, :prefix => false) + # Note: Be sure to chomp the data to avoid the newlines that the + # Chef outputs. + env[:ui].info(data.chomp, :color => color, :prefix => false) + end end end end