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

Unit testing with ChefSpec


Now that we have cookbooks that are adhering to the best practices of both Ruby and Chef, it is time to turn our attention away from static analysis and toward runtime testing. This is where we begin to move from a model of cookbooks-as-code to one of cookbooks-as-artifacts. Unit testing is a kind of middle ground, where we are doing a combination of code testing and artifact testing. This is also the point at which we move into a test-driven development model, where you write the tests before you write the code.

Ruby is a dynamically typed language. Ruby code is not type checked until it is executed. So in order to actually test our cookbooks, they have to be run. Before ChefSpec, this meant that you had to make the code changes to your cookbooks on your workstation, upload your modified cookbooks to your Chef server, then finally converge a node that is assigned that cookbook in order to be able to actually test your changes. This was a work- and time-intensive...