Skip to content

Instantly share code, notes, and snippets.

@bjjb
Last active November 1, 2018 16:23
Show Gist options
  • Save bjjb/7926219 to your computer and use it in GitHub Desktop.
Save bjjb/7926219 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