【问题标题】:Opsworks cookbooks complains of missing methodOpsworks 食谱抱怨缺少方法
【发布时间】:2014-11-25 19:01:31
【问题描述】:

我正在尝试使用从 AWS 获得的 opsworks 配方部署我的 rails 应用程序。我试图通过引用博客here 来设置整个事情。无论他说的是“php”还是“php-app”,我都用“rails”和我的应用程序名称替换。 我的应用角色 JSON 如下所示 -
{ "name": "hercules", "description": "OpsWorks recipe run-list for the rails app layer", "app_type": "rails", "default_attributes": { "max_pool_size": 5 }, "run_list": [ "recipe[opsworks_initial_setup]", "recipe[dependencies]", "recipe[unicorn::rails]", "recipe[rails::configure]", "recipe[deploy::default]", "recipe[deploy::rails]" ], "chef_type": "role", "json_class": "Chef::Role" }

当我尝试部署时,它可以很好地运行其他配方,并卡在 deploy::rails 的此错误上 -

==> app: ================================================================================ ==> app: Recipe Compile Error in /tmp/vagrant-chef-3/chef-solo-1/cookbooks/deploy/recipes/rails.rb ==> app: ================================================================================ ==> app: ==> app: ==> app: NoMethodError ==> app: ------------- ==> app: No resource or method named opsworks_deploy' forChef::Recipe "rails"' ==> app: ==> app: ==> app: Cookbook Trace: ==> app: --------------- ==> app: /tmp/vagrant-chef-3/chef-solo-1/cookbooks/deploy/recipes/rails.rb:20:in block in from_file' ==> app: /tmp/vagrant-chef-3/chef-solo-1/cookbooks/deploy/recipes/rails.rb:2:ineach' ==> app: /tmp/vagrant-chef-3/chef-solo-1/cookbooks/deploy/recipes/rails.rb:2:in `from_file' ==> app:

如果我打开rails.rb:20,那个功能就在那里—— opsworks_deploy do Chef::Log.info("****** hi there *") Chef::Log.info("#{application}") Chef::Log.info(deploy.inspect) app application deploy_data deploy end

我在这里错过了什么非常愚蠢的东西吗?

【问题讨论】:

  • 那条线是什么样子的?另外值得注意的是,大多数 Opsworks 说明书不会在 Opsworks 之外运行,因为它们希望 AWS 填写数据。
  • @coderanger,你问的是哪一行?该文件rails.rb 在那里有行和函数定义。更新了 OP 以反映这一点。

标签: ruby-on-rails amazon-web-services chef-infra aws-opsworks


【解决方案1】:

好的。在这之后花了 2 天时间,在谷歌搜索结果的某个角落,我发现了这个 - https://tickets.opscode.com/browse/CHEF-5011

在下面粘贴一些相关信息 -

Recipe DSL 的更改会导致资源的 do..end 块内发生的任何 NoMethodError 或 NameError 被错误地报告为类似
没有名为 file' forChef::Recipe "default"' 的资源或方法 例如,以下配方代码中的错误显然是文件资源中的no_method_here 位:
file "/tmp/whatever" do no_method_here end

但是,错误被报告为:

================================================ ===================================

/private/tmp/error_message_repro/repro/recipes/default.rb 中的配方编译错误

================================================ ===================================

无方法错误


没有名为file' forChef::Recipe "default"'的资源或方法

食谱追踪:


/private/tmp/error_message_repro/repro/recipes/default.rb:1:infrom_file'`

相关文件内容:


/private/tmp/error_message_repro/repro/recipes/default.rb:

1>> 文件“/tmp/whatever” 2: no_method_here 3:结束 4:

有人放了一个补丁和一个oneliner -

sudo wget https://github.com/opscode/chef/raw/29e732d97ec7e28b2111aca9f93edfd1bc257c2d/lib/chef/dsl/recipe.rb -O /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.0/lib/chef/dsl/recipe.rb --no-check-certificate

(假设您的厨师客户在 /opt/chef 中)

希望这可以帮助经历同样痛苦的人。

【讨论】:

    猜你喜欢
    • 2015-10-31
    • 2018-06-25
    • 1970-01-01
    • 2012-08-12
    • 2016-04-26
    • 1970-01-01
    • 2021-11-30
    • 2015-03-13
    • 1970-01-01
    相关资源
    最近更新 更多