[chef] Re: Installing large numbers of packages


Chronological Thread 
  • From: Charles Duffy < >
  • To:
  • Subject: [chef] Re: Installing large numbers of packages
  • Date: Wed, 31 Aug 2011 20:27:54 -0500

If you want a one-liner...

%w{ foo bar baz }.each do |pkg| { package pkg }

install is the default action; no need to explicitly declare it.

On Wed, Aug 31, 2011 at 6:53 PM, Matt Palmer < "> > wrote:
I'm getting my first chef recipe in order, a simple one to prep a
workstation -- which is mostly "install this giant list of packages".

I was surprised to find that the simple, obvious way to do this:

   package %w{foo bar baz} do
       action :install
   end

Didn't work.  Resources don't accept an array as the namevar to do the
obvious thing.  Instead, I've got to do either:

   package "foo" do
       action :install
   end

   package "bar" do
       action :install
   end

   package "baz" do
       action :install
   end

Which is ridiculously verbose, or else:

   %w{foo bar baz}.each do |pkg|
       package pkg do
           action :install
       end
   end

Which doesn't do anything for my "but you don't need to learn *much*
Ruby" claims to the rest of the team, and still isn't as compact and
clean as it could be.

Am I missing something obvious, or is one of the above options really
the recommended way to create big lists of resources?

Thanks,
- Matt




Archive powered by MHonArc 2.6.16.

§