Book Image

Chef Infrastructure Automation Cookbook

By : Matthias Marschall
Book Image

Chef Infrastructure Automation Cookbook

By: Matthias Marschall

Overview of this book

Table of Contents (14 chapters)
Chef Infrastructure Automation Cookbook Second Edition
About the Author
About the Reviewers

Creating custom Ohai plugins

Ohai is the tool used by a Chef client to find out everything about the node's environment. During a Chef client run, Ohai plugin populates the node object with all the information it found about the node such as its operating system, hardware, and so on.

It is possible to write custom Ohai plugins to query additional properties about a node's environment.


Please note that Ohai data isn't populated until after a successful chef-client run!

In this example, we will see how to query the currently active firewall rules using iptables and make them available as node attributes.

Getting ready

Make sure you have iptables installed on your node. See the Managing firewalls with iptables recipe in Chapter 7, Servers and Cloud Infrastructure.

Make sure you have the chef-client cookbook available:

  1. Add the chef-client cookbook to your Berksfile:

    mma@laptop:~/chef-repo $ subl Berksfile
    cookbook 'chef-client'
  2. Add the chef-client cookbook to your node's run list: