Skip to content

Instantly share code, notes, and snippets.

@dpetzel
Last active December 19, 2015 02:49
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 dpetzel/5885644 to your computer and use it in GitHub Desktop.
Save dpetzel/5885644 to your computer and use it in GitHub Desktop.
153: def ssh(ssh_args, cmd)
=> 154: binding.pry
155: env = "env"
156: if config[:http_proxy]
157: env << " http_proxy=#{config[:http_proxy]}"
158: end
159: if config[:https_proxy]
160: env << " https_proxy=#{config[:https_proxy]}"
161: end
162: if env != "env"
163: cmd = "#{env} #{cmd}"
164: end
165:
166: debug("[SSH] #{ssh_args[1]}@#{ssh_args[0]} (#{cmd})")
167: Net::SSH.start(*ssh_args) do |ssh|
168: exit_code = ssh_exec_with_exit!(ssh, cmd)
169:
170: if exit_code != 0
171: shorter_cmd = cmd.squeeze(" ").strip
172: raise ActionFailed,
173: "SSH exited (#{exit_code}) for command: [#{shorter_cmd}]"
174: end
175: end
176: rescue Net::SSH::Exception => ex
177: raise ActionFailed, ex.message
178: end
[1] pry(#<Kitchen::Driver::Vagrant>)> config
=> {:box=>"box_name",
:provider=>"myprovider",
:kitchen_root=>"C:/my/root",
:sudo=>true,
:port=>22,
:customize=>{:memory=>"256"},
:synced_folders=>{}}
@dpetzel
Copy link
Author

dpetzel commented Jun 28, 2013

.kitchen.yml has:

driver_plugin: vagrant
require_chef_omnibus: "10.26.0"
sudo: false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment