私は最近、アプリケーションをデプロイするためにシェフと遊んでいます。opscodeが提供するapplicationおよびapplication_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": {
}
}
しかし、knife bootstrap example.com -r role [my_app]を実行すると、次のエラーが発生します。
================================================================================
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
何か正しいことをしているようです。applicationとapplication_phpクックブックを拡張する方法を知っている人はいますか?