[英]How do I run my custom recipes on AWS OpsWorks?
I've created a GitHub repo for my simple custom recipe: 我已经为我的简单自定义食谱创建了GitHub存储库:
laravel/
|- recipes/
| - deploy.rb
|- templates/
|- default
| - database.php.erb
I've added the repo to Custom Chef Recipes as https://github.com/minkruben/Laravel-opsworks.git 我已将仓库添加到自定义厨师食谱中, 网址为https://github.com/minkruben/Laravel-opsworks.git
I've added laravel::deploy
to the deploy "cycle". 我在部署“周期”中添加了laravel::deploy
。
This is my deploy.rb: 这是我的deploy.rb:
node[:deploy].each do |app_name, deploy|
if deploy[:application] == "platform"
script "set_permissions" do
interpreter "bash"
user "root"
cwd "#{deploy[:deploy_to]}/current/app"
code <<-EOH
chmod -R 777 storage
EOH
end
template "#{deploy[:deploy_to]}/current/app/config/database.php" do
source "database.php.erb"
mode 0660
group deploy[:group]
if platform?("ubuntu")
owner "www-data"
elsif platform?("amazon")
owner "apache"
end
variables(
:host => (deploy[:database][:host] rescue nil),
:user => (deploy[:database][:username] rescue nil),
:password => (deploy[:database][:password] rescue nil),
:db => (deploy[:database][:database] rescue nil)
)
only_if do
File.directory?("#{deploy[:deploy_to]}/current")
end
end
end
end
When I log into the instance by SSH with the ubuntu user, app/storage folder permission isn't changed & app/config/database.php
is not populated with database details. 当我使用ubuntu用户通过SSH登录该实例时,app / storage文件夹权限未更改,并且app/config/database.php
未填充数据库详细信息。
Am I missing some critical step somewhere? 我是否在某个地方错过了一些关键步骤? there are no errors in the log. 日志中没有错误。 The recipe is clearly recognized and loaded, but doesn't seem to be executed. 可以清楚地识别并加载该配方,但是似乎没有执行该配方。
With OpsWorks, you have 2 options: 使用OpsWorks,您有两种选择:
The logic you have here looks more like a hook than a deployment recipe. 这里的逻辑看起来更像是一个挂钩,而不是部署配方。 Why? 为什么? Because you are simply modifying an already-deployed app vs. specifying the deployment logic itself. 因为您只是在修改已部署的应用程序,而不是指定部署逻辑本身。 This seems to suggest you are using one of Amazon's built-in layers and that Amazon is providing the deployment recipe for you. 这似乎表明您正在使用Amazon的内置层之一,并且Amazon正在为您提供部署方法。
If the above assumption is correct, then you are on path #1. 如果上述假设正确,那么您就在路径#1上。 Re-implementing your logic as a hook should do the trick. 将您的逻辑重新实现为钩子应该可以解决问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.