2017-10-19 155 views
0

我有两本食谱:elasticsearch和curator。厨师:从另一本食谱中修改现有资源

Elasticsearch Cookbook安装并配置elasticsearch。下面的资源(从elasticsearch食谱),必须从馆长食谱修改:

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"]) 

我怎么能这样做?

+0

您是否尝试过使用(https://docs.chef.io [edit_resource!] /dsl_recipe.html#id3)? – vase

+0

我没有!你能提供一个小例子吗? – Lechucico

回答

0

我最初打算指出chef-rewind宝石,但实际上这指的是现在内置于厨师的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 

如果这两个都在厨师run_list,内example.txt的实际内容是,编辑资源,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