简体   繁体   中英

Rubber 2 (fog) and keypair error

Hi I am trying out rubber gem with ec2 but having some issues getting through the quick start section. For some reason Fog under rubber is not finding the keypair. Here is the detail:

in irb (the path here is what is in my rubber.yml key_file property -- gsg-keypair is my private key without the pem extension and it public key is in the same dir):

1.9.3p125 :010 > File.open("#{Dir[(File.expand_path('~') rescue '/root') + '/.ec2/*'].first}")


=> #<File:/home/charlie/.ec2/gsg-keypair> 

But everytime I run: cap rubber:create_staging accepting all defaults I am getting this:

/home/charlie/.rvm/gems/ruby-1.9.3-p125@bag/gems/excon-0.15.4/lib/excon/connection.rb:276:in `request_kernel': The key pair 'gsg-keypair' does not exist (Fog::Compute::AWS::NotFound)
from /home/charlie/.rvm/gems/ruby-1.9.3-p125@bag/gems/excon-0.15.4/lib/excon/connection.rb:105:in `request'
from /home/charlie/.rvm/gems/ruby-1.9.3-p125@bag/gems/fog-1.5.0/lib/fog/core/connection.rb:20:in `request'
from /home/charlie/.rvm/gems/ruby-1.9.3-p125@bag/gems/fog-1.5.0/lib/fog/aws/compute.rb:368:in `request'
from /home/charlie/.rvm/gems/ruby-1.9.3-p125@bag/gems/fog-1.5.0/lib/fog/aws/requests/compute/run_instances.rb:117:in `run_instances'
from /home/charlie/.rvm/gems/ruby-1.9.3-p125@bag/gems/fog-1.5.0/lib/fog/aws/models/compute/server.rb:182:in `save'
from /home/charlie/.rvm/gems/ruby-1.9.3-p125@bag/gems/fog-1.5.0/lib/fog/core/collection.rb:50:in `create'
from /home/charlie/.rvm/gems/ruby-1.9.3-p125@bag/gems/rubber-2.0.5/lib/rubber/cloud/fog.rb:27:in `create_instance'
from /home/charlie/.rvm/gems/ruby-1.9.3-p125@bag/gems/rubber-2.0.5/lib/rubber/thread_safe_proxy.rb:13:in `method_missing'
from /home/charlie/.rvm/gems/ruby-1.9.3-p125@bag/gems/rubber-2.0.5/lib/rubber/recipes/rubber/instances.rb:295:in `create_instance'
from /home/charlie/.rvm/gems/ruby-1.9.3-p125@bag/gems/rubber-2.0.5/lib/rubber/recipes/rubber/instances.rb:215:in `block (2 levels) in create_instances'

any idea why it is happening?

Thanks Charlie

I just experienced this, and this is what was wrong:

In the rubber.yml file I had:
region: us-east-1

However, when I created my key pair in the AWS console, I was in a different region.
You have to create the key pair while in the same region as specified in the rubber.yml file.

在此输入图像描述

Hope this helps!

In the new AWS interface the region is in the upper right hand corner. Pick any region you wish, just ensure that your config/rubber/rubber.yml file is exact:

cloud_providers:
aws:
# REQUIRED The AWS region that you want to use.
# 
# Options include
#us-east-1
# eu-west-1
# ap-northeast-1
# ap-southeast-1
# ap-southeast-2
#
region: us-east-1

My config/rubber/rubber.yml is exactly as above, and it works. Thanks Johnnycakes for solving this!

Sorry for "reviving" old issue but this may be useful for someone.

I had similar issue, except for that my regions was exactly the same. My problem was that i renamed key file, and looks like its should be named exactly as "Key pair name" in AWS/EC2/Keypairs.

I added this line to my rubber/deploy.rb file and it took care of it. This line used to be [default] launch-wizard-1 is the name of my ec2 aws instance. add .. assigned_security_groups: [launch-wizard-1].

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM