Add support for remote shell provisioner script
This commit is contained in:
parent
c38fadfd2f
commit
47594036b4
|
@ -22,6 +22,7 @@ FEATURES:
|
||||||
`knife` if configured to do so.
|
`knife` if configured to do so.
|
||||||
- `vagrant up` has a `--no-destroy-on-error` flag that will not destroy
|
- `vagrant up` has a `--no-destroy-on-error` flag that will not destroy
|
||||||
the VM if a fatal error occurs. [GH-2011]
|
the VM if a fatal error occurs. [GH-2011]
|
||||||
|
- Support for remote shell provisioning scripts [GH-1787]
|
||||||
|
|
||||||
IMPROVEMENTS:
|
IMPROVEMENTS:
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
require 'uri'
|
||||||
|
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module Shell
|
module Shell
|
||||||
class Config < Vagrant.plugin("2", :config)
|
class Config < Vagrant.plugin("2", :config)
|
||||||
|
@ -33,8 +35,8 @@ module VagrantPlugins
|
||||||
errors << I18n.t("vagrant.provisioners.shell.no_path_or_inline")
|
errors << I18n.t("vagrant.provisioners.shell.no_path_or_inline")
|
||||||
end
|
end
|
||||||
|
|
||||||
# Validate the existence of a script to upload
|
# If it is not an URL, we validate the existence of a script to upload
|
||||||
if path
|
if path && ! remote?
|
||||||
expanded_path = Pathname.new(path).expand_path(machine.env.root_path)
|
expanded_path = Pathname.new(path).expand_path(machine.env.root_path)
|
||||||
if !expanded_path.file?
|
if !expanded_path.file?
|
||||||
errors << I18n.t("vagrant.provisioners.shell.path_invalid",
|
errors << I18n.t("vagrant.provisioners.shell.path_invalid",
|
||||||
|
@ -54,6 +56,10 @@ module VagrantPlugins
|
||||||
|
|
||||||
{ "shell provisioner" => errors }
|
{ "shell provisioner" => errors }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def remote?
|
||||||
|
path =~ URI::regexp(["ftp", "http", "https"])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
require "pathname"
|
require "pathname"
|
||||||
require "tempfile"
|
require "tempfile"
|
||||||
|
|
||||||
|
require "vagrant/util/downloader"
|
||||||
|
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module Shell
|
module Shell
|
||||||
class Provisioner < Vagrant.plugin("2", :provisioner)
|
class Provisioner < Vagrant.plugin("2", :provisioner)
|
||||||
|
@ -52,7 +54,15 @@ module VagrantPlugins
|
||||||
def with_script_file
|
def with_script_file
|
||||||
script = nil
|
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...
|
# Just yield the path to that file...
|
||||||
root_path = @machine.env.root_path
|
root_path = @machine.env.root_path
|
||||||
script = Pathname.new(config.path).expand_path(root_path).read
|
script = Pathname.new(config.path).expand_path(root_path).read
|
||||||
|
|
Loading…
Reference in New Issue