Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Chef Cookbook

You're reading from   Chef Cookbook Achieve powerful IT infrastructure management and automation

Arrow left icon
Product type Paperback
Published in Feb 2017
Publisher Packt
ISBN-13 9781786465351
Length 268 pages
Edition 3rd Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
 Marschall Marschall
Author Profile Icon Marschall
Marschall
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Chef Cookbook - Third Edition
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
1. Chef Infrastructure FREE CHAPTER 2. Evaluating and Troubleshooting Cookbooks and Chef Runs 3. Chef Language and Style 4. Writing Better Cookbooks 5. Working with Files and Packages 6. Users and Applications 7. Servers and Cloud Infrastructure Index

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 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.

Tip

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 with Ohai 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:

    mma@laptop...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images