简体   繁体   中英

Failing to connect to ec2 using Rubber

I'm trying to upload my rails app to amazon ec2 using the Rubber gem (I'm following a Railscasts tutorial ). Every time I run cap rubber:create_staging I'm unable to connect to the server. I've been trying everything possible to get this working but after a full day of trying I thought I'd post whats happening here.

Andrews-MacBook-Pro:blog andrew$ cap rubber:create_staging
Respawning with 'bundle exec'
    triggering load callbacks
  * 2013-01-03 17:27:20 executing `rubber:init'
  * 2013-01-03 17:27:23 executing `rubber:create_staging'
Hostname to use for staging instance [production]: 
Roles to use for staging instance [apache,app,collectd,common,db:primary=true,elasticsearch,examples,graphite_server,graphite_web,graylog_elasticsearch,graylog_mongodb,graylog_server,graylog_web,haproxy,mongodb,monit,passenger,postgresql,postgresql_master,web,web_tools]: 
  * 2013-01-03 17:27:26 executing `rubber:create'
  * Security Group already in cloud, syncing rules: blog_production_production
  * Security Group already in cloud, syncing rules: blog_production_graylog_mongodb
  * Security Group already in cloud, syncing rules: blog_production_mongodb
  * Security Group already in cloud, syncing rules: blog_production_postgresql
  * Security Group already in cloud, syncing rules: blog_production_postgresql_master
  * Security Group already in cloud, syncing rules: blog_production_db
  * Security Group already in cloud, syncing rules: blog_production_app
  * Security Group already in cloud, syncing rules: blog_production_web
  * Security Group already in cloud, syncing rules: blog_production_haproxy
  * Security Group already in cloud, syncing rules: blog_production_elasticsearch
  * Security Group already in cloud, syncing rules: blog_production_monit
  * Security Group already in cloud, syncing rules: blog_production_common
  * Security Group already in cloud, syncing rules: blog_production_default
  * Security Group already in cloud, syncing rules: blog_production_graylog_elasticsearch
  * Security Group already in cloud, syncing rules: blog_production_apache
  * Security Group already in cloud, syncing rules: blog_production_passenger
  * Security Group already in cloud, syncing rules: blog_production_examples
  * Security Group already in cloud, syncing rules: blog_production_graphite_web
  * Security Group already in cloud, syncing rules: blog_production_graphite_server
  * Security Group already in cloud, syncing rules: blog_production_graylog_server
  * Security Group already in cloud, syncing rules: blog_production_collectd
  * Security Group already in cloud, syncing rules: blog_production_graylog_web
  * Security Group already in cloud, syncing rules: blog_production_web_tools
 ** Creating instance ami-eafa5883/m1.small/blog_production_default,blog_production_web,blog_production_web_tools,blog_production_production,blog_production_apache,blog_production_app,blog_production_passenger,blog_production_collectd,blog_production_common,blog_production_monit,blog_production_db,blog_production_postgresql,blog_production_postgresql_master,blog_production_elasticsearch,blog_production_examples,blog_production_graphite_server,blog_production_graphite_web,blog_production_graylog_elasticsearch,blog_production_graylog_mongodb,blog_production_mongodb,blog_production_graylog_server,blog_production_graylog_web,blog_production_haproxy/Default
 ** Instance production created: i-7b4f840a
Waiting for instances to start..........................
 ** Instance running, fetching hostname/ip data
  * 2013-01-03 17:28:37 executing `rubber:_allow_root_ssh'
  * executing "sudo -p 'sudo password: '  bash -l -c 'cp /home/ubuntu/.ssh/authorized_keys /root/.ssh/'"
    servers: ["23.20.130.97"]
.... ** Failed to connect to 23.20.130.97, retrying
  * 2013-01-03 17:28:44 executing `rubber:_allow_root_ssh'
  * executing "sudo -p 'sudo password: '  bash -l -c 'cp /home/ubuntu/.ssh/authorized_keys /root/.ssh/'"
    servers: ["23.20.130.97"]
. ** Failed to connect to 23.20.130.97, retrying
  * 2013-01-03 17:28:46 executing `rubber:_allow_root_ssh'
  * executing "sudo -p 'sudo password: '  bash -l -c 'cp /home/ubuntu/.ssh/authorized_keys /root/.ssh/'"
    servers: ["23.20.130.97"]
. ** Failed to connect to 23.20.130.97, retrying
  * 2013-01-03 17:28:49 executing `rubber:_allow_root_ssh'
  * executing "sudo -p 'sudo password: '  bash -l -c 'cp /home/ubuntu/.ssh/authorized_keys /root/.ssh/'"
    servers: ["23.20.130.97"]

etc

and then it seems to go into an infinite loop and trying to connect to the server like above every few minutes.

EDIT: I finally fixed this issue by reinstalling ruby + gems on my local machine. Still not sure what caused this.

This is actually because when you create an instance on EC2, even though the instance is created (and you can see the green light on AWS management console), it still takes some times to propagate the IP address to be accessible from your deployment machine.

The solution really is to wait a few minutes as it will eventually connect.

I was getting a similar error, but fixed it by renaming my private key so it DOES NOT have a .pem extension. The Rubber FAQ makes some reference to this.

https://github.com/rubber/rubber/wiki/FAQ

After I made this change, it worked.

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