Chef infra 扩展应用程序\u php chef cookbook返回RecipeNotFound错误

Chef infra 扩展应用程序\u php chef cookbook返回RecipeNotFound错误,chef-infra,chef-recipe,Chef Infra,Chef Recipe,我最近一直在和chef一起部署应用程序。 我试图在opscode提供的应用程序和应用程序php烹饪书的基础上进行构建。但我对厨师有点陌生,我真的不知道该怎么做 我为我的应用程序创建了一本食谱。目前的配方是这样的: app = node.run_state[:current_app] secrets = Chef::EncryptedDataBagItem.load("secrets", "my_app") application "my_app" do path "/var/www/si

我最近一直在和chef一起部署应用程序。 我试图在opscode提供的应用程序和应用程序php烹饪书的基础上进行构建。但我对厨师有点陌生,我真的不知道该怎么做

我为我的应用程序创建了一本食谱。目前的配方是这样的:

app = node.run_state[:current_app]

secrets = Chef::EncryptedDataBagItem.load("secrets", "my_app")

application "my_app" do
  path "/var/www/sites/my_app/current"
  owner node['my_app']['owner']
  group node['my_app']['group']
  repository "some repository here"
  if secrets["deploy_key"]
    ruby_block "write_key" do
      block do
        f = ::File.open("#{app['deploy_to']}/id_deploy", "w")
        f.print(secrets["deploy_key"])
        f.close
      end
      not_if do ::File.exists?("#{app['deploy_to']}/id_deploy"); end
    end

    file "#{app['deploy_to']}/id_deploy" do
      owner node['my_app']['owner']
      group node['my_app']['group']
      mode '0600'
    end

    template "#{app['deploy_to']}/deploy-ssh-wrapper" do
      source "deploy-ssh-wrapper.erb"
      owner node['my_app']['owner']
      group node['my_app']['group']
      mode "0755"
      variables app.to_hash
    end
  end
end
角色:my_app.json

{
    "name": "my_app",
    "chef_type": "role",
    "json_class": "Chef::Role",
    "default_attributes": {
    },
    "description": "Install my_app Web Server",
    "run_list": [
        "recipe[apache2]",
        "recipe[php]",
        "recipe[application]",
        "recipe[my_app]"
    ],
    "override_attributes": {
    }
}
但是当我运行刀子引导示例.com-r角色[我的应用程序]时。。。我得到以下错误:

================================================================================
Recipe Compile Error
================================================================================

Chef::Exceptions::RecipeNotFound
--------------------------------
could not find recipe my_app for cookbook application

[2012-11-12T15:22:10+00:00] ERROR: Running exception handlers
[2012-11-12T15:22:10+00:00] FATAL: Saving node information to /var/chef/cache/failed-run-data.json
[2012-11-12T15:22:10+00:00] ERROR: Exception handlers complete
[2012-11-12T15:22:10+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2012-11-12T15:22:10+00:00] FATAL: Chef::Exceptions::RecipeNotFound: could not find recipe my_app for cookbook application
似乎在做正确的事情。
有人知道我应该如何扩展应用程序和应用程序的php食谱吗?

我意识到我做的都是错的,呵呵。似乎我在网上找到的大多数教程都使用了不推荐的方法

应用程序堆栈为您处理所有事情。无需生成部署代码

要使其正常工作,您需要删除运行列表中的应用程序。要使用application和application_php,需要在metadata.rb中定义依赖关系

然后您可以这样创建配方:

secrets = Chef::EncryptedDataBagItem.load("secrets", "my_app")

application "my_app" do
  path "/var/www/my_app"
  repository "repository url"
  revision "master"
  deploy_key secrets["deploy_key"]
end

你找到解决这个问题的办法了吗?回答你自己的问题没关系。请不要忘记将答案标记为正确!:)