Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. require 'serverspec'
  2. require 'highline/import'
  3. require 'net/ssh'
  4. require 'net/ssh/proxy/command'
  5. require 'pry'
  6.  
  7. def ssh_user
  8. ENV['SSH_USER'] || ask("SSH user name for #{@bastion}: ")
  9. end
  10.  
  11. def ssh_pass
  12. ENV['SSH_PASS'] || ask("SSH password: ") { |q| q.echo = "*" }
  13. end
  14.  
  15. bastion = ENV['BASTION']
  16. target_host = ENV['TARGET_HOST']
  17. user = Net::SSH::Config.for(bastion)[:user] || ssh_user
  18. proxy = Net::SSH::Proxy::Command.new("ssh #{user}@#{bastion} nc %h %p")
  19.  
  20. RSpec.configure do |config|
  21. set :host, target_host
  22. set :ssh_options, :user => user, :proxy => proxy, :forward_agent => true, :paranoid => false
  23.  
  24. set :backend, :ssh
  25. set :disable_sudo, true
  26. set :request_pty, true
  27.  
  28. config.color = true
  29. config.formatter = 'progress'
  30. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement