Book Image

Chef Cookbook - Third Edition

By : Matthias Marschall
Book Image

Chef Cookbook - Third Edition

By: Matthias Marschall

Overview of this book

Chef is a configuration management tool that lets you automate your more cumbersome IT infrastructure processes and control a large network of computers (and virtual machines) from one master server. This book will help you solve everyday problems with your IT infrastructure with Chef. It will start with recipes that show you how to effectively manage your infrastructure and solve problems with users, applications, and automation. You will then come across a new testing framework, InSpec, to test any node in your infrastructure. Further on, you will learn to customize plugins and write cross-platform cookbooks depending on the platform. You will also install packages from a third-party repository and learn how to manage users and applications. Toward the end, you will build high-availability services and explore what Habitat is and how you can implement it.
Table of Contents (15 chapters)
Chef Cookbook - Third Edition
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
Index

Using data bags


There are situations where you have data that you neither want to hardcode in your recipes nor store as attributes in your cookbooks. Users, external servers, or database connections are examples of such data. Chef offers so-called data bags to manage arbitrary collections of data, which you can use with your cookbooks.

Let's see how we can create and use a data bag and its items.

Getting ready

In the following example, we want to illustrate the usage of data bags by sending HTTP requests to a configurable HTTP endpoint. We don't want to hardcode the HTTP endpoint in our recipe. That's why we store it as a data bag item in a data bag.

To be able to follow along with the example, you'll need an HTTP endpoint.

One way to establish an HTTP endpoint is to just run sudo nc –l 80 on any server that is accessible by your node and use its IP address below.

Another way to establish an HTTP endpoint, which shows us the requests we make, is a free service called RequestBin. To use it, follow...