Merge branch 'shell-provisioner-remote-script' of https://github.com/fgrehm/vagrant into fgrehm-shell-provisioner-remote-script
Conflicts: CHANGELOG.md
This commit is contained in:
commit
c752c37586
|
@ -37,6 +37,7 @@ FEATURES:
|
|||
- Static IP can now be set on public networks. [GH-1745]
|
||||
- Add `Vagrant.has_plugin?` method for use in Vagrantfile to check
|
||||
if a plugin is installed. [GH-1736]
|
||||
- Support for remote shell provisioning scripts [GH-1787]
|
||||
|
||||
IMPROVEMENTS:
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require 'uri'
|
||||
|
||||
module VagrantPlugins
|
||||
module Shell
|
||||
class Config < Vagrant.plugin("2", :config)
|
||||
|
@ -33,8 +35,8 @@ module VagrantPlugins
|
|||
errors << I18n.t("vagrant.provisioners.shell.no_path_or_inline")
|
||||
end
|
||||
|
||||
# Validate the existence of a script to upload
|
||||
if path
|
||||
# If it is not an URL, we validate the existence of a script to upload
|
||||
if path && ! remote?
|
||||
expanded_path = Pathname.new(path).expand_path(machine.env.root_path)
|
||||
if !expanded_path.file?
|
||||
errors << I18n.t("vagrant.provisioners.shell.path_invalid",
|
||||
|
@ -54,6 +56,10 @@ module VagrantPlugins
|
|||
|
||||
{ "shell provisioner" => errors }
|
||||
end
|
||||
|
||||
def remote?
|
||||
path =~ URI::regexp(["ftp", "http", "https"])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
require "pathname"
|
||||
require "tempfile"
|
||||
|
||||
require "vagrant/util/downloader"
|
||||
|
||||
module VagrantPlugins
|
||||
module Shell
|
||||
class Provisioner < Vagrant.plugin("2", :provisioner)
|
||||
|
@ -52,7 +54,15 @@ module VagrantPlugins
|
|||
def with_script_file
|
||||
script = nil
|
||||
|
||||
if config.path
|
||||
if config.remote?
|
||||
download_path = @machine.env.tmp_path.join("#{@machine.id}-remote-script")
|
||||
download_path.delete if download_path.file?
|
||||
|
||||
Vagrant::Util::Downloader.new(config.path, download_path).download!
|
||||
script = download_path.read
|
||||
|
||||
download_path.delete
|
||||
elsif config.path
|
||||
# Just yield the path to that file...
|
||||
root_path = @machine.env.root_path
|
||||
script = Pathname.new(config.path).expand_path(root_path).read
|
||||
|
|
Loading…
Reference in New Issue