2017-10-19 196 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