Book Image

Mastering Chef Provisioning

By : Earl Waud
Book Image

Mastering Chef Provisioning

By: Earl Waud

Overview of this book

This book will show you the best practices to describe your entire infrastructure as code. With the help of this book you can expand your knowledge of Chef because and implement robust and scalable automation solutions. You can automate and document every aspect of your network, from the hardware to software, middleware, and all your containers. You will become familiar with the Chef’s Chef Provisioning tool. You will be able to make a perfect model system where everything is represented as code beneath your fingertips. Make the best possible use of your resources, and deliver infrastructure as code, making it as versionable, testable and repeatable as application software
Table of Contents (17 chapters)
Mastering Chef Provisioning
Credits
Foreword
About the Author
Acknowledgments
About the Reviewer
www.PacktPub.com
Preface
Index

Making a Custom Resource more reusable


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.

Making a 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...