Skip to content

Instantly share code, notes, and snippets.

@parasquid
Forked from bjjb/vagrant.rb
Created September 11, 2018 06:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parasquid/1d01ef49f2766c16d93428cd11c3a026 to your computer and use it in GitHub Desktop.
Save parasquid/1d01ef49f2766c16d93428cd11c3a026 to your computer and use it in GitHub Desktop.
A Capistrano 3.x Vagrant stage. Place into config/deploy/vagrant.rb, and deploy to the Vagrant box as if it were a production VM.
# Capistrano 3.x Vagrant stage
# config/deploy/vagrant.rb
set :stage, :vagrant
set :rails_env, "production"
vagrant_ssh_config = `vagrant ssh-config`.split("\n")[1..-1].map(&:strip).inject({}) do |m, s|
k, v = s.split(/\s/, 2).map(&:strip); m[k] = v; m
end
server vagrant_ssh_config['HostName'],
roles: %w{web app db},
primary: true,
user: vagrant_ssh_config['User'],
port: vagrant_ssh_config['Port'],
ssh_options: {
keys: [vagrant_ssh_config['IdentityFile']],
forward_agent: vagrant_ssh_config['ForwardAgent'] == 'yes'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment