The Custom Resource we just created, "mywebapp_website", is easily reusable within our mywebapp cookbook and could be used with other cookbooks, but what if we want to expand on its reusability? What if we want to make a cookbook that only has a Custom Resource that we want to use in several cookbooks? The answer is pretty simple. Let's walk through the steps to convert our "website" Custom Resource into a more reusable Custom Resource-only cookbook.
The Custom Resource website.rb
file in the cookbook mywebapp
, which we created in the previous section, is almost all we need to create our more reusable Custom Resource-only cookbook. Let's create a new cookbook named appsite
, which will be our new reusable cookbook:
cd ~/chef-repo/cookbooks chef generate cookbook appsite
Now delete the entire recipe folder. The best practice for reusable Custom Resource cookbooks is that they do not have a recipe folder at all. They...