【问题标题】:How do I run my custom recipes on AWS OpsWorks?如何在 AWS OpsWorks 上运行我的自定义配方?
【发布时间】:2014-06-19 02:30:12
【问题描述】:

我为我的简单自定义配方创建了一个 GitHub 存储库:

laravel/
  |- recipes/
     |  - deploy.rb
  |- templates/
     |- default
        |  - database.php.erb

我已将 repo 添加到 Custom Chef Recipes 中,名称为 https://github.com/minkruben/Laravel-opsworks.git

我已将 laravel::deploy 添加到部署“周期”中。

这是我的 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

当我使用 ubuntu 用户通过 SSH 登录实例时,app/storage 文件夹权限没有改变,app/config/database.php 没有填充数据库详细信息。

我是否在某处遗漏了一些关键步骤?日志中没有错误。 配方被清楚地识别和加载,但似乎没有被执行。

【问题讨论】:

  • 请不要在stackoverflow和serverfault上交叉发帖。
  • 能否提供厨师日志(调试级别)?
  • 这个问题已经出现在Serverfault

标签: amazon-web-services chef-infra chef-recipe aws-opsworks


【解决方案1】:

使用 OpsWorks,您有两种选择:

  1. 使用 Amazon 的内置层之一,在这种情况下,部署配方由 Amazon 提供,您可以使用钩子扩展 Amazon 的逻辑:http://docs.aws.amazon.com/opsworks/latest/userguide/workingcookbook-extend-hooks.html
  2. 使用自定义层,在这种情况下,您负责提供包括部署在内的所有配方:http://docs.aws.amazon.com/opsworks/latest/userguide/create-custom-deploy.html

这里的逻辑看起来更像是一个钩子,而不是一个部署配方。为什么?因为您只是在修改已经部署的应用程序而不是指定部署逻辑本身。这似乎表明您正在使用 Amazon 的内置层之一,并且 Amazon 正在为您提供部署方法。

如果上述假设是正确的,那么您就在路径 #1 上。将您的逻辑重新实现为钩子应该可以解决问题。

【讨论】:

    猜你喜欢
    • 2014-05-11
    • 2017-06-01
    • 2013-11-25
    • 2013-08-07
    • 2016-05-28
    • 2016-04-27
    • 2017-01-16
    • 2014-04-03
    • 2014-04-07
    相关资源
    最近更新 更多