Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

Select Badges

Select Supported Platforms

Select Status

The materialize cookbook has been deprecated

Author provided reason for deprecation:

The materialize cookbook has been deprecated and is no longer being maintained by its authors. Use of the materialize cookbook is no longer recommended.


materialize (1) Versions 1.0.0

Implements a materialized view pattern for searches

cookbook 'materialize', '~> 1.0.0', :supermarket
cookbook 'materialize', '~> 1.0.0'
knife supermarket install materialize
knife supermarket download materialize
Quality 71%


Build Status

This cookbook provides a way to materialize a data-structure into a Chef databag, and then easily retrieve it on another node. This can be useful if, for example, you want to amortize the cost of a large search one time, rather than repeat it on a thousand nodes.



  • Any platform supported by Chef


  • Chef 12.1+


  • none


  1. Make this cookbook a dependency of the cookbook that will use either the read or write functions.
  2. Call the functions.
  3. There is no step three.


Lets say you have a cookbook with a big search, to build something like ssh_known_hosts. In a typical Chef cookbook, you might write the following:

data = []
search(:node, 'fqdn:* AND ipaddress:* AND keys_ssh_host_rsa_public:* AND host_dsa_public:*') do |n|
  data << "#{n['fqdn']},#{n['ipaddress']} #{n['keys']['ssh']['host_rsa_public']}"
  data << "#{n['fqdn']},#{n['ipaddress']} #{n['keys']['ssh']['host_dsa_public']}"
data = data.sort

To build up your data for the ssh_known_hosts file. This woudl result in a global search across every node in your infrastructure on every convergence, which, as you get larger, will be pretty brutal.

With this cookbook, you would do the following instead:

materialize('ssh_known_hosts') do
  data = []
  search(:node, 'fqdn:* AND ipaddress:* AND keys_ssh_host_rsa_public:* AND host_dsa_public:*') do |n|
    data << "#{n['fqdn']},#{n['ipaddress']} #{n['keys']['ssh']['host_rsa_public']}"
    data << "#{n['fqdn']},#{n['ipaddress']} #{n['keys']['ssh']['host_dsa_public']}"

This would take the output of your search query and store it in a data bag called 'materialize', with the key of 'ssh_known_hosts'. You want to make sure this happens on one node only, rather than on every node. (For example, move it to another recipe, or have a node attribute, or check on node name - whatever. Just don't run it every time.)


To get your value back out, you would do something like this:

  ssh_known_hosts_content = retrieve('ssh_known_hosts').join("\n")
  # Protect against empty cache
  ssh_known_hosts_content ='/etc/ssh/ssh_known_hosts')

file "/etc/ssh/ssh_known_hosts" do
  owner "root"
  mode "0644"
  content ssh_known_hosts_content


This cookbook comes with unit tests!

$ bundle install
$ bundle exec rspec

And with functional tests!

$ kitchen test default

License & Authors

Author: Cookbook Engineering Team (

Copyright: 2011-2016, Chef Software, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.

Dependent cookbooks

This cookbook has no specified dependencies.

Contingent cookbooks

There are no cookbooks that are contingent upon this one.

materialize Cookbook CHANGELOG

This file is used to list changes made in each version of the materialize cookbook.

v1.0.0 (2016-09-16)

  • Require Chef 12.1
  • Add unit / linting testing in Travis CI
  • Improve kitchen config
  • Add contributing and testing docs
  • Remove Guardfile
  • Add maintainers docs
  • Add Rakefile for testing
  • Add source_url, issues_url, and chef_version to metadata

Collaborator Number Metric

1.0.0 failed this metric

Failure: Cookbook has 1 collaborators. A cookbook must have at least 2 collaborators to pass this metric.

Contributing File Metric

1.0.0 passed this metric

Foodcritic Metric

1.0.0 passed this metric

No Binaries Metric

1.0.0 passed this metric

Supported Platforms Metric

1.0.0 failed this metric

materialize should declare what platform(s) it supports.

Testing File Metric

1.0.0 passed this metric

Version Tag Metric

1.0.0 passed this metric