Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Chef Cookbook - Third Edition

You're reading from  Chef Cookbook - Third Edition

Product type Book
Published in Feb 2017
Publisher Packt
ISBN-13 9781786465351
Pages 268 pages
Edition 3rd Edition
Languages
Author (1):
Matthias Marschall Matthias Marschall
Profile icon Matthias Marschall

Table of Contents (15) Chapters

Chef Cookbook - Third Edition
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
1. Chef Infrastructure 2. Evaluating and Troubleshooting Cookbooks and Chef Runs 3. Chef Language and Style 4. Writing Better Cookbooks 5. Working with Files and Packages 6. Users and Applications 7. Servers and Cloud Infrastructure Index

Making recipes idempotent by using conditional execution


Chef manages the configuration of your nodes. It is not simply an installer for new software but you will run the Chef client on the existing nodes, as well as new ones.

To speed up your Chef client runs on the existing nodes, you should make sure that your recipes do not try to re-execute resources that have already reached the desired state.

Running resources repeatedly will be a performance issue at best and will break your servers at worst. Chef offers a way to tell resources not to run or only to run if a certain condition is met. Let's look at how conditional execution of resources works.

Getting ready

Make sure you have a cookbook called my_cookbook and that the run_list of your node includes my_cookbook, as described in the Creating and using cookbooks recipe in Chapter 1, Chef Infrastructure.

How to do it…

Let's see how to use conditional execution in our cookbooks:

  1. Edit your default recipe to trigger a callback only if you have...

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 $15.99/month. Cancel anytime}