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

Flagging problems in your Chef cookbooks with Foodcritic


You might wonder what the proven ways to write cookbooks are. Foodcritic tries to identify possible issues with the logic and style of your cookbooks.

In this section, you'll learn how to use Foodcritic on some existing cookbooks.

Getting ready

Install version 6.0.0 of the mysql cookbook by running the following code:

mma@laptop:~/chef-repo $ knife cookbook site install mysql 6.0.0
Installing mysql to /Users/mma/work/chef-repo/cookbooks
…TRUNCATED OUTPUT…
Cookbook mysql version 6.0.0 successfully installed

How to do it…

Let's see how Foodcritic reports findings:

  1. Run foodcritic on your cookbook:

    mma@laptop:~/chef-repo $ foodcritic ./cookbooks/mysql
    ...TRUNCATED OUTPUT...
    FC001: Use strings in preference to symbols to access node attributes: ./cookbooks/mysql/libraries/helpers.rb:273
    FC005: Avoid repetition of resource declarations: ./cookbooks/mysql/libraries/provider_mysql_service.rb:77
    ...TRUNCATED OUTPUT...
    
  2. Get a detailed list of the...