Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have 3 different ways to install said package, and I prefer option #1 the most, but I wanted to see if there was a reason to use option #2 or 3 or any other options? (My goal of this question is to get feedback of different ways to do this; and not install at compile time if possible... in this case)


p = package "snmp" do
  package_name value_for_platform(
    [ "centos", "redhat", "suse" ] => { "default" => "net-snmp" },
    "default" => "snmpd"
  action :install


packages = case node[:platform]
  when "centos","redhat","fedora"

packages.each do |pkg|
  package pkg


package "snmpd" do
  action :install
  only_if do platform?("ubuntu", "debian") end
share|improve this question

I typically don't support too many distros in my own recipes, but when reading other recipes (such as from Opscode) I generally appreciate approaches similar to your second, above, the main difference is that I would tend to explicitly invoke the resource directly, rather than compile an array.

case node[:platform]
when "centos","redhat","fedora"
  package 'net-snmp'
  package 'snmpd'

However, there are a number of pros and cons for each case, depending on what exactly you're trying to express.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.