» Vagrant Push
» Local Exec Strategy
The Vagrant Push Local Exec strategy allows the user to invoke an arbitraryshell command or script as part of a push.
Warning: The Vagrant Push Local Exec strategy does notperform any validation on the correctness of the shell script.
The Vagrant Push Local Exec strategy supports the following configurationoptions:
script
- The path to a script on disk (relative to theVagrantfile
) toexecute. Vagrant will attempt to convert this script to an executable, but anexception will be raised if that fails.inline
- The inline script to execute (as a string).args
(string or array) - Optional arguments to pass to the shell script when executing itas a single string. These arguments must be written as if they were typeddirectly on the command line, so be sure to escape characters, quote,etc. as needed. You may also pass the arguments in using an array. In thiscase, Vagrant will handle quoting for you.Please note - only one of thescript
andinline
options may be specified ina single push definition.
» Usage
The Vagrant Push Local Exec strategy is defined in the Vagrantfile
using thelocal-exec
key:
Remote path:
config.push.define "local-exec" do |push|
push.inline = <<-SCRIPT
scp -r . server:/var/www/website
SCRIPT
end
Local path:
config.push.define "local-exec" do |push|
push.inline = <<-SCRIPT
cp -r . /var/www/website
SCRIPT
end
For more complicated scripts, you may store them in a separate file and readthem from the Vagrantfile
like so:
config.push.define "local-exec" do |push|
push.script = "my-script.sh"
end
And then invoke the push with Vagrant:
$ vagrant push
» Script Arguments
Refer to Shell Provisioner.
当前内容版权归 vagrantup.com 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 vagrantup.com .