Linting Chef code with Foodcritic and Puppet code with puppet-lint
Since we're mainly coding in Ruby, we can use common linters such as Rubocop in the Ruby world. However, Rubocop, is targeted at software development by default and is not really optimized for Chef cookbooks development. So, Chef adapted their own version of Rubocop, named Cookstyle. In the meantime, the Foodcritic tool used in conjunction with rules checks our code for a set of commonly accepted good practices by the community. We'll walk through those tools to end up with a much better and cleaner code.
Getting ready
To step through this recipe, you will need the following:
A working Chef DK installation on the workstation
A working Chef client configuration on the remote host
The Chef code from Chapter 6, Fundamentals of Managing Servers with Chef and Puppet, or any custom Chef code.
How to do it…
We'll study and follow suggestions of the two complimentary tools—Cookstyle and Foodcritic. Both give some precious and complementary...