2014-11-14 20:51:40 +00:00
|
|
|
---
|
|
|
|
page_title: "Vagrant Push - Local Exec Strategy"
|
|
|
|
sidebar_current: "push-local-exec"
|
|
|
|
description: |-
|
2014-11-14 20:53:47 +00:00
|
|
|
The Vagrant Push Local Exec strategy pushes your application's code using a
|
|
|
|
user-defined script.
|
2014-11-14 20:51:40 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
# Vagrant Push
|
|
|
|
|
|
|
|
## Local Exec Strategy
|
|
|
|
|
|
|
|
The Vagrant Push Local Exec strategy allows the user to invoke an arbitrary
|
|
|
|
shell command or script as part of a push.
|
|
|
|
|
|
|
|
<div class="alert alert-warn">
|
|
|
|
<p>
|
|
|
|
<strong>Warning:</strong> The Vagrant Push Local Exec strategy does not
|
|
|
|
perform any validation on the correctness of the shell script.
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
The Vagrant Push Local Exec strategy supports the following configuration
|
|
|
|
options:
|
|
|
|
|
2014-11-17 18:22:40 +00:00
|
|
|
- `script` - The path to a script on disk (relative to the `Vagrantfile`) to
|
|
|
|
execute. Vagrant will attempt to convert this script to an executable, but an
|
|
|
|
exception will be raised if that fails.
|
|
|
|
- `inline` - The inline script to execute (as a string).
|
2015-12-10 07:58:02 +00:00
|
|
|
- `args` (string or array) - Optional arguments to pass to the shell script when executing it
|
|
|
|
as a single string. These arguments must be written as if they were typed
|
|
|
|
directly 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 this
|
|
|
|
case, Vagrant will handle quoting for you.
|
2014-11-14 20:51:40 +00:00
|
|
|
|
2014-11-17 18:22:40 +00:00
|
|
|
Please note - only one of the `script` and `inline` options may be specified in
|
|
|
|
a single push definition.
|
2014-11-14 20:51:40 +00:00
|
|
|
|
|
|
|
### Usage
|
|
|
|
|
|
|
|
The Vagrant Push Local Exec strategy is defined in the `Vagrantfile` using the
|
|
|
|
`local-exec` key:
|
|
|
|
|
2015-02-12 01:58:04 +00:00
|
|
|
Remote path:
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
config.push.define "local-exec" do |push|
|
|
|
|
push.inline = <<-SCRIPT
|
|
|
|
scp -r . server:/var/www/website
|
|
|
|
SCRIPT
|
|
|
|
end
|
|
|
|
```
|
|
|
|
|
|
|
|
Local path:
|
|
|
|
|
2014-11-14 20:51:40 +00:00
|
|
|
```ruby
|
|
|
|
config.push.define "local-exec" do |push|
|
2014-11-17 18:22:40 +00:00
|
|
|
push.inline = <<-SCRIPT
|
2015-02-12 01:58:04 +00:00
|
|
|
cp -r . /var/www/website
|
2014-11-14 20:51:40 +00:00
|
|
|
SCRIPT
|
|
|
|
end
|
|
|
|
```
|
|
|
|
|
2014-11-14 20:55:14 +00:00
|
|
|
For more complicated scripts, you may store them in a separate file and read
|
|
|
|
them from the `Vagrantfile` like so:
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
config.push.define "local-exec" do |push|
|
2014-11-17 18:22:40 +00:00
|
|
|
push.script = "my-script.sh"
|
2014-11-14 20:55:14 +00:00
|
|
|
end
|
|
|
|
```
|
|
|
|
|
2014-11-14 20:51:40 +00:00
|
|
|
And then invoke the push with Vagrant:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
$ vagrant push
|
|
|
|
```
|
2015-12-10 07:58:02 +00:00
|
|
|
|
|
|
|
### Script Arguments
|
|
|
|
|
|
|
|
Refer to [Shell Provisioner](/v2/provisioning/shell.html).
|