我一直试图在厨师文档和谷歌中找到答案,但我无法想出任何东西.我还不是一个红宝石家伙,所以这个问题的答案可能源于我接近"厨师足够红宝石"的问题.这就是我想要做的事情:在我的deploy资源中,在before_migrate属性中,我想在我当前的食谱中执行资源.我目前正在做的是将资源填充到块本身,但我知道必须有更好的方法来实现它.
before_migrate do
template "#{app_root}/#{applet_name}/local_settings.py" do
source "local_settings.py.erb"
owner app_config['user']
group app_config['group']
variables(
:database_name => app_config['postgresql']['database_name'],
:user => app_config['postgresql']['user'],
:password => app_config['postgresql']['password']
)
action :create
end
end
Run Code Online (Sandbox Code Playgroud)
我的目标是什么
before_migrate do
"template #{app_root}/#{applet_name}/local_settings.py".execute
end
Run Code Online (Sandbox Code Playgroud)
所以我可以重复使用该模板代码.谢谢!
感谢#chef IRC 频道中的各位大佬,我解决了我的问题。需要直接访问通知资源,使用
Chef::Resource::Notification.new("template[#{app_root}/#{applet_name}/local_settings.py", :create)
这将通知template资源运行该:create操作。
| 归档时间: |
|
| 查看次数: |
7948 次 |
| 最近记录: |