Created
August 25, 2015 13:20
-
-
Save elblivion/d145a04daefe25fec5e6 to your computer and use it in GitHub Desktop.
SSH Tunnels for Vagrant
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://notepad2.blogspot.de/2012/11/run-ssh-tunnel-in-background.html | |
local_http = 10080 | |
local_https = 10443 | |
control = ".ssh_control_file" | |
desc "Set up SSH tunnel" | |
task :ssh_setup do | |
raise "SSH control file #{control} exists, aborting!" if File.exists? control | |
puts "vagrant ssh -- -L #{local_http}:localhost:80 -L #{local_https}:localhost:443 -N -f -M -S #{control}" | |
sh "vagrant ssh -- -L #{local_http}:localhost:80 -L #{local_https}:localhost:443 -N -f -M -S #{control}" | |
end | |
desc "Tear down SSH tunnel" | |
task :ssh_teardown do | |
sh "vagrant ssh -- -S #{control} -O exit" | |
end | |
desc "Run tests" | |
task :test do | |
puts "Running the tests" | |
sh "bats ../tests/nginx.bats" | |
end | |
task :default do | |
Rake::Task['ssh_setup'].invoke | |
Rake::Task['test'].invoke | |
Rake::Task['ssh_teardown'].invoke | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment