2014-06-18 87 views
0

我創建了一個GitHub庫爲我簡單的定製配方:如何在AWS OpsWorks上運行我的自定義食譜?

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

我已經添加了回購協議自定義廚師食譜爲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 

當我登錄到該實例通過SSH與Ubuntu的用戶,應用程序/存儲文件夾的權限不改變& app/config/database.php不填充數據庫的詳細信息。

我錯過了某個關鍵步驟嗎?日誌中沒有錯誤。 配方清楚地識別和加載,但似乎沒有執行。

+0

請不要在stackoverflow和[serverfault](http://serverfault.com/questions/605977/how-do-i-run-my-custom-recipes-on-aws-opsworks)上交叉發佈。 – StephenKing

+0

你能提供廚師的日誌(調試級別)嗎? –

+0

此問題已經出現在[Serverfault](http://serverfault.com/questions/605977/how-do-i-run-my-custom-recipes-on-aws-opsworks) – sethvargo

回答

2

隨着OpsWorks,你有兩個選擇:中

  1. 使用一個亞馬遜的內置層,在這種情況下部署的配方是由亞馬遜提供的,您可以用鉤子擴展亞馬遜的邏輯: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

你這裏的邏輯看起來更像是一個比掛鉤部署食譜。爲什麼?因爲您只是修改已部署的應用程序與指定部署邏輯本身。這似乎表明您正在使用亞馬遜的內置圖層之一,並且亞馬遜正在爲您提供部署配方。

如果上述假設是正確的,那麼你就在路徑#1上。重新實現你的邏輯作爲一個鉤子應該可以做到。

相關問題