Fix up the chef solo provisioner to work with new machine abstraction
This commit is contained in:
parent
f193d69fbc
commit
a238e06795
|
@ -20,7 +20,7 @@ module VagrantPlugins
|
|||
def verify_binary(binary)
|
||||
# Checks for the existence of chef binary and error if it
|
||||
# doesn't exist.
|
||||
env[:vm].channel.sudo("which #{binary}",
|
||||
env[:machine].communicate.sudo("which #{binary}",
|
||||
:error_class => ChefError,
|
||||
:error_key => :chef_not_detected,
|
||||
:binary => binary)
|
||||
|
@ -34,8 +34,10 @@ module VagrantPlugins
|
|||
end
|
||||
|
||||
def chown_provisioning_folder
|
||||
env[:vm].channel.sudo("mkdir -p #{config.provisioning_path}")
|
||||
env[:vm].channel.sudo("chown #{env[:vm].config.ssh.username} #{config.provisioning_path}")
|
||||
env[:machine].communicate.tap do |comm|
|
||||
comm.sudo("mkdir -p #{config.provisioning_path}")
|
||||
comm.sudo("chown #{env[:machine].config.ssh.username} #{config.provisioning_path}")
|
||||
end
|
||||
end
|
||||
|
||||
def setup_config(template, filename, template_vars)
|
||||
|
@ -57,8 +59,10 @@ module VagrantPlugins
|
|||
temp.close
|
||||
|
||||
remote_file = File.join(config.provisioning_path, filename)
|
||||
env[:vm].channel.sudo("rm #{remote_file}", :error_check => false)
|
||||
env[:vm].channel.upload(temp.path, remote_file)
|
||||
env[:machine].communicate.tap do |comm|
|
||||
comm.sudo("rm #{remote_file}", :error_check => false)
|
||||
comm.upload(temp.path, remote_file)
|
||||
end
|
||||
end
|
||||
|
||||
def setup_json
|
||||
|
@ -73,7 +77,7 @@ module VagrantPlugins
|
|||
temp.write(json)
|
||||
temp.close
|
||||
|
||||
env[:vm].channel.upload(temp.path, File.join(config.provisioning_path, "dna.json"))
|
||||
env[:machine].communicate.upload(temp.path, File.join(config.provisioning_path, "dna.json"))
|
||||
end
|
||||
|
||||
class ChefError < Vagrant::Errors::VagrantError
|
||||
|
|
|
@ -155,7 +155,8 @@ module VagrantPlugins
|
|||
def share_folders(prefix, folders)
|
||||
folders.each do |type, local_path, remote_path|
|
||||
if type == :host
|
||||
env[:vm].config.vm.share_folder("v-#{prefix}-#{self.class.get_and_update_counter(:shared_folder)}",
|
||||
env[:machine].config.vm.share_folder(
|
||||
"v-#{prefix}-#{self.class.get_and_update_counter(:shared_folder)}",
|
||||
remote_path, local_path, :nfs => config.nfs)
|
||||
end
|
||||
end
|
||||
|
@ -163,7 +164,7 @@ module VagrantPlugins
|
|||
|
||||
def upload_encrypted_data_bag_secret
|
||||
env[:ui].info I18n.t("vagrant.provisioners.chef.upload_encrypted_data_bag_secret_key")
|
||||
env[:vm].channel.upload(encrypted_data_bag_secret_key_path,
|
||||
env[:machine].communicate.upload(encrypted_data_bag_secret_key_path,
|
||||
config.encrypted_data_bag_secret)
|
||||
end
|
||||
|
||||
|
@ -194,7 +195,7 @@ module VagrantPlugins
|
|||
env[:ui].info I18n.t("vagrant.provisioners.chef.running_solo_again")
|
||||
end
|
||||
|
||||
exit_status = env[:vm].channel.sudo(command, :error_check => false) do |type, data|
|
||||
exit_status = env[:machine].communicate.sudo(command, :error_check => false) do |type, data|
|
||||
# Output the data with the proper color based on the stream.
|
||||
color = type == :stdout ? :green : :red
|
||||
|
||||
|
@ -214,7 +215,7 @@ module VagrantPlugins
|
|||
def verify_shared_folders(folders)
|
||||
folders.each do |folder|
|
||||
@logger.debug("Checking for shared folder: #{folder}")
|
||||
if !env[:vm].channel.test("test -d #{folder}")
|
||||
if !env[:machine].communicate.test("test -d #{folder}")
|
||||
raise ChefError, :missing_shared_folders
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue