vaguerent/website/source/docs/push/local-exec.html.md
Seth Vargo 5093f3120e Merge docs and www into a single static site
This is a big commit, and I apologize in advance for the future
git-blames all pointing to me. This commit does a few things:

1.  Merges the website/docs and website/www repo into a single website repo
    to be in line with other HashiCorp projects
2.  Updates to use middleman-hashicorp
3.  Converts less to scss to be in line with other projects
4.  Updates page styles to be in line with other projects
5.  Optimizes images
6.  Prepare for S3 + Fastly deployment with scripts, etc.
7.  Removes blog posts (they have been transferred to hashicorp.com with
    redirects in place
8.  Updated sitemap generation script for better SEO
9.  Fixed many broken links
10. Add description to all fields
2016-01-19 14:35:05 -05:00

2.1 KiB

layout page_title sidebar_current description
docs Vagrant Push - Local Exec Strategy push-local-exec The Vagrant Push Local Exec strategy pushes your application's code using a user-defined script.

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.

Warning: The Vagrant Push Local Exec strategy does not perform any validation on the correctness of the shell script.

The Vagrant Push Local Exec strategy supports the following configuration options:

  • 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).
  • 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.

Please note - only one of the script and inline options may be specified in a single push definition.

Usage

The Vagrant Push Local Exec strategy is defined in the Vagrantfile using the local-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 read them 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.