[chef] Re: Re: A new kind of Resource: the resource cookbook


Chronological Thread 
  • From: John Keiser < >
  • To:
  • Subject: [chef] Re: Re: A new kind of Resource: the resource cookbook
  • Date: Fri, 20 Feb 2015 09:33:26 -0800

On inspection of ChefSpec's monkeypatches, it looks like everything is compatible.  The resource cookbook is compatible with the Chef::Resource layer, and so is ChefSpec.  One caveat would be that step_into only works with LWRPs in current ChefSpec, so you couldn't use step_into to bring in the "recipe do" if you were building a compound resource.

Caveat and YMMV of course; I've used the cookbook personally and written a lot of tests to validate them, but I haven't exercised all Chef functionality.

On Thu, Feb 19, 2015 at 6:35 PM, Peter Burkholder < " target="_blank"> > wrote:
How does resource play with ChefSpec?

On Thu, Feb 19, 2015 at 6:56 PM, John Keiser < " target="_blank"> > wrote:
Hey all,

Chef Resources are incredibly important to creating good, useful, reusable cookbooks.  Yet people often don't create them because it's harder than it should be.  We need to change that.

The "resource" cookbook, released today, is a big step in that direction, making Chef resources both more powerful and much easier to write, use, and customize.  I'd love your thoughts on this new shape for a resource.

Some of the key ideas:
- Simplify resources to a single file, using "recipe" and removing providers.
- Make primitive resources easy with the "converge" and "load" keywords."
- Make resources readable as well as writeable.
- Make it easy to customize resources in place, adding defaults and tweaks.

To use it,
1. Grab the resource cookbook
2. Add "depends 'resource'" to your cookbook's metadata
3. Write a resource (say, and use it!

  # resources/user_data.rb
  property :path, Path, identity: true, default: '/etc/httpd.conf'
  property :full_name, String
  property :total, Integer
  recipe do
    file path do
      content "FullName '#{full_name}'\nTotal #{total}"
    end
  end

I'd love to get feedback and people trying it out.  This is experimental at this time, though!  There are bugs (though all known bugs are presently fixed).  Things will change.  There is a lot of feedback to gather and that will affect what it does.  On the other hand, this has been through a long revision cycle already in an attempt to produce something close enough to right that I hope it won't change *much,* or in fundamental ways.

For a quickstart and documentation, see the cookbook or the README on the repository.
For a detailed feature list and in-depth comparison between Chef HWRP/LWRPs and the resource cookbook, see the 0.1 release notes.
The rubygems cookbook example is being used to manage gem ownership for Chef gems, and serves as an initial example of an API cookbook.

Join us on gitter if you want to chat, or feel free to file issues for things you'd like, things you don't like that are there, things you'd like to change.

Thanks!

--John Keiser




--

Peter Burkholder — Customer Success Engineer

Availability: no travel/OOO scheduled

301-204-5767 –  " target="_blank">  – my: Linkedin  Twitter  Calendar

CHEF

CHEF.IO

TM

chef.io   Blog   Facebook   Twitter   Youtube  






Archive powered by MHonArc 2.6.16.

§