jedi4ever / mccloud

Vagrant for the cloud

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Keypair management does not work?

tknerr opened this issue · comments

Given a Mccloudfile like below I was expecting that

  1. the keypairs defined in config.keystore.define would be created within AWS
  2. within config.vm.define I could simply reference the keypair

Mccloudfile:

Mccloud::Config.run do |config|

  # locate keypair for use with mccloud (must be present or will be created upon `mccloud init`)
  config.keypair.define "my-mccloud-keypair" do |key_config|
    key_config.keypair.public_key_path = "#{File.join(ENV['HOME'],'.ssh','mccloud_rsa.pub')}"
    key_config.keypair.private_key_path = "#{File.join(ENV['HOME'],'.ssh','mccloud_rsa')}"
  end

  # define keypairs to be created within AWS
  config.keystore.define "aws-us-east-key-store" do |keystore_config|
    keystore_config.keystore.provider = "aws-us-east"
    keystore_config.keystore.keypairs = [
      # :name is the name as it will be displayed on amazon
      # :pairname is the named as defined above
      { :name => "my-mccloud-key", :pairname => "my-mccloud-keypair" },
    ]
  end

  config.vm.define "web" do |web_config|
    web_config.vm.provider= "aws-us-east"
    web_config.vm.ami = "ami-3c994355"
    web_config.vm.flavor = "m1.small"
    web_config.vm.zone = "us-east-1a"
    web_config.vm.user="ubuntu"

    web_config.vm.key_name = "my-mccloud-key"

  end
end

However, it seems that both expectations are not met.

When I created the keypair manually via the AWS console, then I run into this error:

W:\tmp\demo>mccloud up web
Loaded providers[1] vms[1] ips[0] lbs[0] stacks[0] templates[1] keypairs[1] keystores[1]
Creating new vm web for provider aws-us-east
[web] - Waiting for the machine to become accessible
.................
[web] - Waiting for ssh port to become available
[web] - Ssh Port is available

Waiting for ssh login on 23.22.123.163 with user ubuntu to sshd on port => 22 to work (Timeout in 6000 seconds)
.Something blew up Mccloud. Time for McGuyver:

can't convert nil into String
W:/tools/vagrant/vagrant/vagrant/embedded/lib/ruby/gems/1.9.1/gems/net-ssh-2.2.2/lib/net/ssh/authentication/key_manager.rb:64:in `expand_path'
W:/tools/vagrant/vagrant/vagrant/embedded/lib/ruby/gems/1.9.1/gems/net-ssh-2.2.2/lib/net/ssh/authentication/key_manager.rb:64:in `add'
W:/tools/vagrant/vagrant/vagrant/embedded/lib/ruby/gems/1.9.1/gems/net-ssh-2.2.2/lib/net/ssh/authentication/session.rb:60:in `block in authenticate'
W:/tools/vagrant/vagrant/vagrant/embedded/lib/ruby/gems/1.9.1/gems/net-ssh-2.2.2/lib/net/ssh/authentication/session.rb:60:in `each'
W:/tools/vagrant/vagrant/vagrant/embedded/lib/ruby/gems/1.9.1/gems/net-ssh-2.2.2/lib/net/ssh/authentication/session.rb:60:in `authenticate'
W:/tools/vagrant/vagrant/vagrant/embedded/lib/ruby/gems/1.9.1/gems/net-ssh-2.2.2/lib/net/ssh.rb:190:in `start'
W:/tools/vagrant/vagrant/vagrant/embedded/lib/ruby/gems/1.9.1/gems/mccloud-0.0.13/lib/mccloud/util/ssh.rb:20:in `block in when_ssh_login_works'
W:/tools/vagrant/vagrant/vagrant/embedded/lib/ruby/1.9.1/timeout.rb:68:in `timeout'
W:/tools/vagrant/vagrant/vagrant/embedded/lib/ruby/gems/1.9.1/gems/mccloud-0.0.13/lib/mccloud/util/ssh.rb:15:in `when_ssh_login_works'
W:/tools/vagrant/vagrant/vagrant/embedded/lib/ruby/gems/1.9.1/gems/mccloud-0.0.13/lib/mccloud/provider/aws/vm/up.rb:95:in `up'
W:/tools/vagrant/vagrant/vagrant/embedded/lib/ruby/gems/1.9.1/gems/mccloud-0.0.13/lib/mccloud/provider/aws/provider.rb:133:in `block in up'
W:/tools/vagrant/vagrant/vagrant/embedded/lib/ruby/gems/1.9.1/gems/mccloud-0.0.13/lib/mccloud/provider/core/provider.rb:53:in `on_selected_components'
W:/tools/vagrant/vagrant/vagrant/embedded/lib/ruby/gems/1.9.1/gems/mccloud-0.0.13/lib/mccloud/provider/aws/provider.rb:132:in `up'
W:/tools/vagrant/vagrant/vagrant/embedded/lib/ruby/gems/1.9.1/gems/mccloud-0.0.13/lib/mccloud/command/up.rb:12:in `block in execute'
W:/tools/vagrant/vagrant/vagrant/embedded/lib/ruby/gems/1.9.1/gems/mccloud-0.0.13/lib/mccloud/command/up.rb:10:in `each'
W:/tools/vagrant/vagrant/vagrant/embedded/lib/ruby/gems/1.9.1/gems/mccloud-0.0.13/lib/mccloud/command/up.rb:10:in `execute'
W:/tools/vagrant/vagrant/vagrant/embedded/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/task.rb:22:in `run'
W:/tools/vagrant/vagrant/vagrant/embedded/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
W:/tools/vagrant/vagrant/vagrant/embedded/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `block in invoke_all'
W:/tools/vagrant/vagrant/vagrant/embedded/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `each'
W:/tools/vagrant/vagrant/vagrant/embedded/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `map'
W:/tools/vagrant/vagrant/vagrant/embedded/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `invoke_all'
W:/tools/vagrant/vagrant/vagrant/embedded/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/group.rb:226:in `dispatch'
W:/tools/vagrant/vagrant/vagrant/embedded/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:109:in `invoke'
W:/tools/vagrant/vagrant/vagrant/embedded/lib/ruby/gems/1.9.1/gems/mccloud-0.0.13/lib/mccloud/cli.rb:45:in `block in register'
W:/tools/vagrant/vagrant/vagrant/embedded/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/task.rb:22:in `run'
W:/tools/vagrant/vagrant/vagrant/embedded/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
W:/tools/vagrant/vagrant/vagrant/embedded/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor.rb:263:in `dispatch'
W:/tools/vagrant/vagrant/vagrant/embedded/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/base.rb:389:in `start'
W:/tools/vagrant/vagrant/vagrant/embedded/lib/ruby/gems/1.9.1/gems/mccloud-0.0.13/bin/mccloud:18:in `<top (required)>'
W:/tools/vagrant/vagrant/vagrant/embedded/bin/mccloud:19:in `load'
W:/tools/vagrant/vagrant/vagrant/embedded/bin/mccloud:19:in `<main>'

In the end I totally discarded the keystore to make it work in the meantime (still with the prerequisite is that keypair was manually imported to AWS):

Mccloud::Config.run do |config|

  config.vm.define "web" do |web_config|
    web_config.vm.provider= "aws-us-east"
    web_config.vm.ami = "ami-3c994355"
    web_config.vm.flavor = "m1.small"
    web_config.vm.zone = "us-east-1a"
    web_config.vm.user="ubuntu"

    web_config.vm.key_name = "my-mccloud-key"

    # this made it work
    web_config.vm.private_key_path="W:/home/.ssh/mccloud_rsa"
    web_config.vm.public_key_path="W:/home/.ssh/mccloud_rsa.pub"

  end
end

Am I doing something wrong here?

Haven't tried this with current master yet. I uploaded the keypair manually via the AWS console and then used the shorter syntax without the keypair and keystore definitions in the Mccloudfile:

   ...
    # this made it work
    web_config.vm.private_key_path="W:/home/.ssh/mccloud_rsa"
    web_config.vm.public_key_path="W:/home/.ssh/mccloud_rsa.pub"
   ...

This works well enough for me now.

Still I don't know how the keypair and keystore are intended to be used.

Same here ,

  • the idea is that you define it in mccloudfile.
  • then do a keystore sync to update the keys if you need them

Ok, haven't noticed there was a separate command keystore and keypair command. I will give it a shot the next time I need it. Thanks!