我有两本 cooking 书:elasticsearch 和 curator。
Elasticsearch 说明书安装并配置 Elasticsearch。以下资源(来自 elasticsearch Recipe )必须从 curator Recipe 进行修改:
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
我需要在 curator Cookbook 上修改它并添加一行:
'path.repo' => (["/backups/s3_currently_dev", "/backups/s3_currently", "/backups/s3_daily", "/backups/s3_weekly", "/backups/s3_monthly"])
我怎样才能做到这一点?
最佳答案
我最初打算向您指出 chef-rewind
gem,但这实际上指向 edit_resource
现已内置于 Chef 中的提供程序。一个基本的例子:
# 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
中的实际内容是已编辑资源的内容,修改后的内容!
.
在没有完全测试您的案例的情况下,我假设可以以相同的方式使用提供程序,如下所示:
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
关于resources - Chef : Modify existing resource from another cookbook,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46828306/