Add a file provisioner
Add a provisioner which will upload host files and directories to the guest via the scp channel. This is useful for populating user specific files into the guest. This is a rename from scpupload to file and updated against master. [GH-1357]
This commit is contained in:
parent
be25238381
commit
c158b4aff4
|
@ -0,0 +1,29 @@
|
||||||
|
require "vagrant"
|
||||||
|
|
||||||
|
module VagrantPlugins
|
||||||
|
module FileUpload
|
||||||
|
class Config < Vagrant.plugin("2", :config)
|
||||||
|
attr_accessor :source
|
||||||
|
attr_accessor :destination
|
||||||
|
|
||||||
|
def validate(machine)
|
||||||
|
errors = []
|
||||||
|
if !source
|
||||||
|
errors << I18n.t("vagrant.provisioners.file.no_source_file")
|
||||||
|
end
|
||||||
|
if !destination
|
||||||
|
errors << I18n.t("vagrant.provisioners.file.no_dest_file")
|
||||||
|
end
|
||||||
|
if source
|
||||||
|
s = File.expand_path(source)
|
||||||
|
if ! File.exist?(s)
|
||||||
|
errors << I18n.t("vagrant.provisioners.file.path_invalid",
|
||||||
|
:path => s)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
{ "File provisioner" => errors }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,23 @@
|
||||||
|
require "vagrant"
|
||||||
|
|
||||||
|
module VagrantPlugins
|
||||||
|
module FileUpload
|
||||||
|
class Plugin < Vagrant.plugin("2")
|
||||||
|
name "file"
|
||||||
|
description <<-DESC
|
||||||
|
Provides support for provisioning your virtual machines with
|
||||||
|
uploaded files.
|
||||||
|
DESC
|
||||||
|
|
||||||
|
config(:file, :provisioner) do
|
||||||
|
require File.expand_path("../config", __FILE__)
|
||||||
|
Config
|
||||||
|
end
|
||||||
|
|
||||||
|
provisioner(:file) do
|
||||||
|
require File.expand_path("../provisioner", __FILE__)
|
||||||
|
Provisioner
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,16 @@
|
||||||
|
module VagrantPlugins
|
||||||
|
module FileUpload
|
||||||
|
class Provisioner < Vagrant.plugin("2", :provisioner)
|
||||||
|
def provision
|
||||||
|
@machine.communicate.tap do |comm|
|
||||||
|
# Make sure the remote path exists
|
||||||
|
command = "mkdir -p %s" % File.dirname(config.destination)
|
||||||
|
comm.execute(command)
|
||||||
|
|
||||||
|
# now upload the file
|
||||||
|
comm.upload(File.expand_path(config.source), config.destination)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1194,6 +1194,11 @@ en:
|
||||||
file needs to exist so it can be uploaded to the virtual machine.
|
file needs to exist so it can be uploaded to the virtual machine.
|
||||||
deleting_from_server: "Deleting %{deletable} \"%{name}\" from Chef server..."
|
deleting_from_server: "Deleting %{deletable} \"%{name}\" from Chef server..."
|
||||||
|
|
||||||
|
file:
|
||||||
|
no_dest_file: "File destination must be specified."
|
||||||
|
no_source_file: "File source must be specified."
|
||||||
|
path_invalid: "File upload source file %{path} must exist"
|
||||||
|
|
||||||
puppet:
|
puppet:
|
||||||
not_detected: |-
|
not_detected: |-
|
||||||
The `%{binary}` binary appears to not be in the PATH of the guest. This
|
The `%{binary}` binary appears to not be in the PATH of the guest. This
|
||||||
|
|
Loading…
Reference in New Issue