[英]Chef: Modify existing resource from another cookbook
我有兩本食譜:elasticsearch 和 curator。
Elasticsearch Cookbook 安裝並配置一個 elasticsearch。 以下資源(來自 elasticsearch 食譜)必須從 curator 食譜修改:
elasticsearch_configure 'elasticsearch' do
configuration ({
'http.port' => port,
'cluster.name' => cluster_name,
'node.name' => node_name,
'bootstrap.memory_lock' => false,
'discovery.zen.minimum_master_nodes' => 1,
'xpack.monitoring.enabled' => true,
'xpack.graph.enabled' => false,
'xpack.watcher.enabled' => true
})
end
我需要在策展人食譜上修改它並添加一行:
'path.repo' => (["/backups/s3_currently_dev", "/backups/s3_currently", "/backups/s3_daily", "/backups/s3_weekly", "/backups/s3_monthly"])
我怎么能做到這一點?
我最初打算將您指向chef-rewind
gem,但這實際上指向現在內置在Chef 中的edit_resource
提供程序。 一個基本的例子:
# cookbook_a/recipes/default.rb
file 'example.txt' do
content 'this is the initial content'
end
.
# cookbook_b/recipes/default.rb
edit_resource! :file, 'example.txt' do
content 'modified content!'
end
如果這兩個都在 Chef run_list
,則example.txt
的實際內容是已編輯資源的modified content!
,即modified content!
.
如果沒有完全測試您的案例,我假設可以以相同的方式使用提供程序,如下所示:
edit_resource! :elasticsearch_configure, 'elasticsearch' do
configuration ({
'http.port' => port,
'cluster.name' => cluster_name,
'node.name' => node_name,
'bootstrap.memory_lock' => false,
'discovery.zen.minimum_master_nodes' => 1,
'xpack.monitoring.enabled' => true,
'xpack.graph.enabled' => false,
'xpack.watcher.enabled' => true,
'path.repo' => ["/backups/s3_currently_dev", "/backups/s3_currently", "/backups/s3_daily", "/backups/s3_weekly", "/backups/s3_monthly"]
})
end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.