Closed j4m3s closed 8 years ago
I'm not a ruby man so have resorted to hacking the serverspec.rb
file in my .gem directory. I've inserted the following before line 376:
ENV['KITCHEN_' + key.to_s.upcase] = value.to_s
info("Environment variable #{'KITCHEN_' + key.to_s.upcase} value #{value}")
Now, back in my kitchen folder I can set my spec/spec_helper.rb
to contain:
set :host, ENV['KITCHEN_HOSTNAME']
# ssh options at http://net-ssh.github.io/ssh/v1/chapter-2.html
# ssh via ssh key
set :ssh_options, :user => ENV['KITCHEN_USERNAME'], :port => ENV['KITCHEN_PORT'], :paranoid => false, :verbose => :error, :host_key => 'ssh-rsa', :keys => [ ENV['KITCHEN_SSH_KEY'] ]
and everything works dynamically :)
I'm sure there's a neater way but it works!
(NB: I think the README needs updating to show the :port
being set in spec/spec_helper.rb
?)
that's a good idea i will add it and update the readme.
fixed in 0.5.0
I'm using option 3: 'Locally on your workstation running serverspec in ssh mode'
At the start of a 'kitchen verify' run, test-kitchen knows the details of the instance it is testing, and outputs them to the terminal, e.g.
Can those connection details not be automatically be picked-up and used for the test suite, rather than having to hard-code them into the .kitchen.yml file as described in the README?: