尝试使用橡胶部署jRoR应用程序并获取NoMethodError:nil的未定义方法`authorize_port_range':NilClass

时间:2012-09-20 17:06:54

标签: amazon-ec2 jruby jrubyonrails fog

这是我第一次使用橡胶或部署到Amazon EC2。我正在关注这个Railscast。我已经用Google搜索了,似乎没有其他人遇到这个问题。这是我运行cap rubber:create_staging时的控制台日志:

user529789@user529789-M15x:~/develops/grouper$ cap rubber:create_staging
    triggering load callbacks
  * executing `rubber:init'
  * 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]: 
  * executing `rubber:create'
Excon nonblock is not supported by your OpenSSL::SSL::SSLSocket
Excon nonblock is not supported by your OpenSSL::SSL::SSLSocket
  * Creating new security group: grouper_production_default
  * Creating new rule: {"source_group_name"=>"grouper_production_default", "source_group_account"=>"<account id redacted>"}
[DEPRECATION] authorize_group_and_owner is deprecated, use authorize_port_range with :group option instead
  * Creating new rule: {"protocol"=>"tcp", "from_port"=>"22", "to_port"=>"22", "source_ips"=>["0.0.0.0/0"]}
NoMethodError: undefined method `authorize_port_range' for nil:NilClass
  add_security_group_rule at /home/user529789/.rvm/gems/jruby-1.6.7.2@grouper/gems/rubber-2.1.0/lib/rubber/cloud/fog.rb:182
                     send at org/jruby/RubyKernel.java:2088
           method_missing at /home/user529789/.rvm/gems/jruby-1.6.7.2@grouper/gems/rubber-2.1.0/lib/rubber/thread_safe_proxy.rb:13
     sync_security_groups at /home/user529789/.rvm/gems/jruby-1.6.7.2@grouper/gems/rubber-2.1.0/lib/rubber/recipes/rubber/security_groups.rb:221
                     each at org/jruby/RubyArray.java:1615
     sync_security_groups at /home/user529789/.rvm/gems/jruby-1.6.7.2@grouper/gems/rubber-2.1.0/lib/rubber/recipes/rubber/security_groups.rb:220
                     each at org/jruby/RubyArray.java:1615
     sync_security_groups at /home/user529789/.rvm/gems/jruby-1.6.7.2@grouper/gems/rubber-2.1.0/lib/rubber/recipes/rubber/security_groups.rb:214
                     each at org/jruby/RubyArray.java:1615
     sync_security_groups at /home/user529789/.rvm/gems/jruby-1.6.7.2@grouper/gems/rubber-2.1.0/lib/rubber/recipes/rubber/security_groups.rb:208
    setup_security_groups at /home/user529789/.rvm/gems/jruby-1.6.7.2@grouper/gems/rubber-2.1.0/lib/rubber/recipes/rubber/security_groups.rb:51
          create_instance at /home/user529789/.rvm/gems/jruby-1.6.7.2@grouper/gems/rubber-2.1.0/lib/rubber/recipes/rubber/instances.rb:255
          create_instance at /home/user529789/.rvm/gems/jruby-1.6.7.2@grouper/gems/rubber-2.1.0/lib/rubber/recipes/rubber/instances.rb:254
         create_instances at /home/user529789/.rvm/gems/jruby-1.6.7.2@grouper/gems/rubber-2.1.0/lib/rubber/recipes/rubber/instances.rb:217
                     call at org/jruby/RubyProc.java:270
                     call at org/jruby/RubyProc.java:224

2 个答案:

答案 0 :(得分:0)

我的猜测是它寻找一个范围并且在堆栈跟踪中你给出的范围是从一个端口到同一个端口和ruby,尤其是jruby可能会错误地构造端口范围。

您可以尝试在您的jruby版本上运行irb

(22..22).to_a,看看你得到了什么。在mri你得到[22]但是在jruby中可能存在实现错误。

失败时执行的代码我认为在这里: https://github.com/rubber/rubber/blob/v2.1.0/lib/rubber/cloud/fog.rb#L182

修改

在寻找了几分钟之后,很明显橡胶将参数传递给雾宝石,我很确定即使范围可以解决,雾使用它的方式,也需要一个范围。您可以尝试从21到23或22到23之间的范围,看看是否能让您超越错误。另外,作为注释,您使用的橡胶版本远远落后于主版本。我没有任何参考指出这是否是你想要的,但你应该知道它。祝你好运。

答案 1 :(得分:0)

对我有用的解决方法是去 rubber.yml

并设置与安全组相关的所有选项来自&#39; true&#39;到&#39;假&#39; 根本不确定这种效果,但它似乎已经通过了。