A new kind of Resource: the resource cookbook


#1

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 https://supermarket.chef.io/cookbooks/resource,
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
https://github.com/chef-cookbooks/resource/blob/master/README.md 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
https://github.com/chef-cookbooks/resource/blob/master/docs/0.1-release.md
.
The rubygems cookbook example
https://github.com/chef-cookbooks/resource/tree/master/chef/cookbooks/rubygems
is being used to manage gem ownership for Chef gems, and serves as an
initial example of an API cookbook.

Join us on gitter https://gitter.im/chef-cookbooks/resource 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
jkeiser@chef.io


#2

How does resource play with ChefSpec?

On Thu, Feb 19, 2015 at 6:56 PM, John Keiser jkeiser@chef.io 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 https://supermarket.chef.io/cookbooks/resource,
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
https://github.com/chef-cookbooks/resource/blob/master/README.md 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
https://github.com/chef-cookbooks/resource/blob/master/docs/0.1-release.md
.
The rubygems cookbook example
https://github.com/chef-cookbooks/resource/tree/master/chef/cookbooks/rubygems
is being used to manage gem ownership for Chef gems, and serves as an
initial example of an API cookbook.

Join us on gitter https://gitter.im/chef-cookbooks/resource 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
jkeiser@chef.io

Peter Burkholder — Customer Success Engineer

Availability: no travel/OOO scheduled

301-204-5767 – pburkholder@chef.io – *my: *Linkedin
http://www.linkedin.com/in/pburkholder Twitter
http://www.twitter.com/pburkholder Cal
https://www.google.com/calendar/embed?src=pburkholder%40chef.io&mode=WEEK
endar

CHEF

CHEF.IO http://www.chef.io/

TM

chef.io http://www.chef.io/ Blog http://www.chef.io/blog/ Facebook
https://www.facebook.com/getchefdotcom Twitter
https://twitter.com/chef Youtube https://www.youtube.com/getchef


#3

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 pburkholder@chef.io
wrote:

How does resource play with ChefSpec?

On Thu, Feb 19, 2015 at 6:56 PM, John Keiser jkeiser@chef.io 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 https://supermarket.chef.io/cookbooks/resource,
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
https://github.com/chef-cookbooks/resource/blob/master/README.md 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
https://github.com/chef-cookbooks/resource/blob/master/docs/0.1-release.md
.
The rubygems cookbook example
https://github.com/chef-cookbooks/resource/tree/master/chef/cookbooks/rubygems
is being used to manage gem ownership for Chef gems, and serves as an
initial example of an API cookbook.

Join us on gitter https://gitter.im/chef-cookbooks/resource 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
jkeiser@chef.io

Peter Burkholder — Customer Success Engineer

Availability: no travel/OOO scheduled

301-204-5767 – pburkholder@chef.io – *my: *Linkedin
http://www.linkedin.com/in/pburkholder Twitter
http://www.twitter.com/pburkholder Cal
https://www.google.com/calendar/embed?src=pburkholder%40chef.io&mode=WEEK
endar

CHEF

CHEF.IO http://www.chef.io/

TM

chef.io http://www.chef.io/ Blog http://www.chef.io/blog/
Facebook https://www.facebook.com/getchefdotcom Twitter
https://twitter.com/chef Youtube https://www.youtube.com/getchef


#4

This is a big deal.
This is going to change the way people write Chef.

+1000

-s

On Thu, Feb 19, 2015 at 3:56 PM, John Keiser jkeiser@chef.io 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
jkeiser@chef.io


#5

I forgot to add my many +++++s on my earlier question. This looks really
compelling.

Thanks John!

On Fri, Feb 20, 2015 at 2:26 PM, Sean OMeara someara@chef.io wrote:

This is a big deal.
This is going to change the way people write Chef.

+1000

-s

On Thu, Feb 19, 2015 at 3:56 PM, John Keiser jkeiser@chef.io 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
jkeiser@chef.io

Peter Burkholder — Customer Success Engineer

Availability: no travel/OOO scheduled

301-204-5767 – pburkholder@chef.io – *my: *Linkedin
http://www.linkedin.com/in/pburkholder Twitter
http://www.twitter.com/pburkholder Cal
https://www.google.com/calendar/embed?src=pburkholder%40chef.io&mode=WEEK
endar

CHEF

CHEF.IO http://www.chef.io/

TM

chef.io http://www.chef.io/ Blog http://www.chef.io/blog/ Facebook
https://www.facebook.com/getchefdotcom Twitter
https://twitter.com/chef Youtube https://www.youtube.com/getchef