Chef - how to avoid duplicating a recipe -


in our chef cookbooks support multiple versions of same software. we've adopted bad practice. each version we've made copy of recipe , changed it's attributes.

e.g.

remote_file install_file   source node['android']['sdk']['23']['source_url']   not_if     ::file.exists?(extract_dir)   end   notifies :run, "execute[extract-sdk-23]", :immediately end 

becomes

remote_file install_file   source node['android']['sdk']['24']['source_url']   not_if     ::file.exists?(extract_dir)   end   notifies :run, "execute[extract-sdk-24]", :immediately end 

this code duplication. it'd cleaner keep attributes same vary values.

is possible chef?

if matters use chef-client 0 directly. i.e. don't use knife, etc.

as @stephenking mentioned, best bet write custom resource abstracts logic. put different sdks in hash in node attributes , iterate on them in single recipe, going less flexible.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -