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

Preface

Today, the DevOps Engineer is responsible for delivering infrastructure that is rock solid and consistently configured every time. What's more, these superheroes need to supply the infrastructure rapidly and at scale, often to the tune of dozens or even hundreds of identically configured systems.

The days of doing this superhero work manually are long gone. Now the only question is "which superpower will best serve our heroes in their time of greatest need?" The answer is the power that can transform their infrastructure into code so that it can be managed the same way as any other source code-based project. Chef is that superpower.

And Mastering Chef Provisioning is your secret decoder ring for learning how to use that power to provision containers, servers, and networking devices across the universe of hosting targets, including your local workstation, the traditional data center, and in the clouds.

In this book, you will learn the secrets of how to automate and document every aspect of your infrastructure. You will find the best practices for describing your infrastructure as code. You will learn to automate the provisioning of everything from the smallest container deployed to your local workstation to the biggest distributed application clusters deployed to the cloud, all in a single bound.

This book will help you, the DevOps superhero, to create a perfect model system where everything is represented as code beneath your fingertips. You will be able to make the best possible use of your resources, avoid redundancy, and always be ready to scale—faster than a speeding bullet. And you don't have to leave your home planet, get bitten by a radioactive spider, or fall in a vat of toxic waste to do it.

But as the great Stan Lee wrote, "With great power …".

What this book covers

Chapter 1, Setting Up a Development Environment on Your Workstation, reviews Chef basics and covers the installation of our Chef workstation and an on-premise Chef Server.

Chapter 2, Knife Tooling and Plugins, shows how to get all the help you need with knife, explores using both common and uncommon knife subcommands, and teaches you how to create your own custom knife plugins.

Chapter 3, Leveraging Roles, Environments, and Policies, examines Chef roles, environments, and organizations, covers the attribute precedence hierarchy, and investigates the exciting new Chef policy feature.

Chapter 4, Custom Resources, introduces the custom resource, explores how the custom resource has improved upon LWRPs and HWRPs, and shows how to create and use your own custom resources.

Chapter 5, Provisioning in the Traditional Data Center, presents provisioning in the traditional data center, covering provisioning to VMware vSphere, OpenStack, VMware's desktop hypervisors, and common network devices, and teaches how to deploy your own development OpenStack environment.

Chapter 6, Provisioning in the Cloud, presents provisioning in the cloud, covering provisioning to Amazon AWS, Microsoft Azure, Google Compute Platform, and Linode, and shows how to provision containers in Docker.

Chapter 7, Test-Driven Development, teaches how to use several of the tools available to implement a test-driven development cycle for infrastructure code development, including RuboCop, Foodcritic, ChefSpec, and Test Kitchen.

Chapter 8, Using Chef Provisioning, reveals how to use the ChefDK feature known as Chef provisioning, providing examples for Vagrant, AWS, and Docker.

What you need for this book

The examples in this book were written with the ChefDK version 0.12.0. Examples were tested primarily on Mac OS X and Ubuntu workstations, although all examples should work equally well on other flavors of Linux as well as on Microsoft Windows.

Who this book is for

This book is for software engineers, system administrators, and DevOps Engineers who need to quickly deliver reliably consistent infrastructure at scale. You are expected to have intermediate experience with Chef and Ruby and will be reading this book to advance your knowledge and take your skillset to the next level.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, and user input are shown as follows: "What this error message is probably indicating is that there is no valid host entry in the /etc/hosts file."

A block of code is set as follows:

# add a rule for ssh
neutron security-group-rule-create $ID \
  --direction ingress --ethertype IPv4 \
  --protocol tcp --port-range-min 22 --port-range-max 22 \
  --remote-ip-prefix 0.0.0.0/0

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

# add a rule for ssh
neutron security-group-rule-create $ID \
  --direction ingress --ethertype IPv4 \
  --protocol tcp --port-range-min 22 --port-range-max 22 \
  --remote-ip-prefix 0.0.0.0/0

Any command-line input or output is written as follows:

$ sudo knife openstack image list
Name                      ID                                    Snapshot
cirros-0.3.4-x86_64-uec   84dff654-7f0d-45c8-a20b-b08c0ef39fd1  no      

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Click on the Continue button to advance the installation."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

  1. Log in or register to our website using your e-mail address and password.

  2. Hover the mouse pointer on the SUPPORT tab at the top.

  3. Click on Code Downloads & Errata.

  4. Enter the name of the book in the Search box.

  5. Select the book for which you're looking to download the code files.

  6. Choose from the drop-down menu where you purchased this book from.

  7. Click on Code Download.

You can also download the code files by clicking on the Code Files button on the book's webpage at the Packt Publishing website. This page can be accessed by entering the book's name in the Search box. Please note that you need to be logged in to your Packt account.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows

  • Zipeg / iZip / UnRarX for Mac

  • 7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Mastering-Chef-Provisioning. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.