Modular Recipes

17 views
Skip to first unread message

Diego Furtado

unread,
May 2, 2015, 9:44:58 PM5/2/15
to learnchef-funda...@googlegroups.com
Hi.
I have a question about good/bad practice working with chef. The examples I saw, everyone uses to put everything in the same file, when installing for cross-platform nodes as scenario 2. Creating the recipes separately and adding just the right recipe to run list is a bad practice?

[Scenario 1]
 - recipes
#default.rb
 empty file e/or common

#debian.rb
package "apache2" do
  action :install
end

#redhat.rb
package "httpd" do
  action :install
end

[Scenario 2]
 - recipes
#default.rb 
if node.platform_family?('debian')
package_name = 'apache2'
else
package_name = 'httpd'
end

package package_name do
  action :install
end


Thanks!
Reply all
Reply to author
Forward
0 new messages