简体   繁体   English

在AWS OpsWorks / Chef for Rails中设置配置文件

[英]Setting up config files in AWS OpsWorks/Chef for Rails

I suppose I should start with the caveat that I'm very new to OpsWorks and Chef. 我想我应该从OpsWorks和Chef的新手开始。 I'm trying to setup a RoR app using the provided "Rails App Server" layer. 我正在尝试使用提供的“ Rails App Server”层来设置RoR应用程序。 My application depends on a config.yml file being present in the config/ directory, so I created a really simple recipe that is supposed to create that file for me: 我的应用程序依赖于config /目录中存在的config.yml文件,因此我创建了一个非常简单的配方,该配方应该为我创建该文件:

node[:deploy].each do |application, deploy|

  template "#{deploy[:deploy_to]}/shared/config/config.yml" do
    source "config.yml.erb"
    cookbook 'current_client_spin'
    mode "0660"
    group deploy[:group]
    owner deploy[:user]

    notifies :run, "execute[restart Rails app #{application}]"

    only_if do
      File.directory?("#{deploy[:deploy_to]}/shared/config/")
    end
  end

end

My cookbook structure includes a /templates/default/ directory which contains the correct .erb files. 我的菜谱结构包含一个/ templates / default /目录,其中包含正确的.erb文件。

I added this recipe to the "Deploy" cycle, and through judicious use of logging statements, I can see that the recipe is getting invoked, but the file isn't being created. 我将此食谱添加到“部署”周期中,并且通过谨慎使用日志记录语句,我可以看到该食谱正在被调用,但是未在创建文件。 I investigated a bit further, and it appears that at the point where my recipe is being invoked, the deploy[:deploy_to]/shared/config directory doesn't exist. 我作了进一步调查,似乎在我的菜谱被调用时, deploy[:deploy_to]/shared/config目录不存在。 This is despite the fact that the default Rails recipe apparently places some other files there -- so I'm extremely confused. 尽管事实上默认的Rails配方显然在其中放置了一些其他文件-所以我非常困惑。

Any help would be very appreciated. 任何帮助将不胜感激。

Thanks! 谢谢!

So, turns out this was a bit of a "well duh" moment. 因此,事实证明这是个“好吧”的时刻。 I was putting my recipe in the wrong "slot". 我把食谱放在错误的“插槽”中。 I needed them in the "Setup" slot, not "Deploy" or "Configure". 我需要它们在“安装”插槽中,而不是在“部署”或“配置”中。 Hopefully if anyone else finds themselves with this kind of head-scratcher, this will help them out. 希望如果有人发现这种头疼的人,这将对他们有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM