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