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

Creating new Knife plugins


Sometimes, you will be dealing with unique situations and need to create your own knife plugin. In this section, we will review how that is accomplished.

The basic plugin file format

A custom knife plugin begins by creating a new plugin ruby file. The plugin file has to have a specific format. That format, in its simplest form, looks like this:

require 'chef/knife'

module ModuleName
  class SubclassName < Chef::Knife

  deps do
    require 'chef/dependency'
  end

  banner 'knife subcommand argument VALUE (options)'

  option :name_of_option,
    :short => "-l VALUE",
    :long => "--long-option-name VALUE",
    :description => "The description for the option.",
    :proc => Proc.new { code_to_run }
    :boolean => true | false
    :default => default_value

  def run
  end
end

The essential sections of this file are:

  • The required chef/knife directive provides the calls all knife plugins inherit from

  • ModuleName is the name space for our plugin

  • ...