Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Chef Provisioning

You're reading from   Mastering Chef Provisioning Render your entire infrastructure as code with Chef

Arrow left icon
Product type Paperback
Published in Jun 2016
Publisher Packt
ISBN-13 9781785888915
Length 262 pages
Edition 1st Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
Earl Waud Earl Waud
Author Profile Icon Earl Waud
Earl Waud
Arrow right icon
View More author details
Toc

Table of Contents (10) Chapters Close

Preface 1. Setting Up a Development Environment on Your Workstation FREE CHAPTER 2. Knife Tooling and Plugins 3. Leveraging Roles, Environments, and Policies 4. Custom Resources 5. Provisioning in the Traditional Data Center 6. Provisioning in the Cloud 7. Test-Driven Development 8. Using Chef Provisioning Index

Creating and using a Custom Resource

Now that we have our use case defined and a working solution created, we want to introduce updates to the cookbook to turn what we have into a better solution that uses Custom Resources. Specifically, we are going to create a "website" Custom Resource.

What makes up a Custom Resource?

Custom Resources are created by making a Ruby file in the cookbook's resources folder. The resource name will be the name of the file created. For example, if we want to create a "website" Custom Resource, we would create a new Ruby file named website.rb, as follows:

mkdir –p ~/chef-repo/cookbooks/mywebapp/resources
touch ~/chef-repo/cookbooks/mywebapp/resources/website.rb

This will create a new folder named resources and create an empty file named website.rb in that folder.

Tip

Creating a default.rb resource file: If you create a resource file named default.rb, the resource will have the same name as the cookbook.

A cookbook can have multiple...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image