jtimberman's Code Blog

Chef, Ops, Ruby, Linux/Unix. Opinions are mine, not my employer's (CHEF).

Some Knife Plugins

I’ve shared my ~/.chef/plugins/knife directory as a Git repository on GitHub. There’s only a few, but I hope you find them useful. They are licensed under the Apache 2.0 software license, but please only use them for awesome.

gem

This plugin will install a gem into the Ruby environment that knife is executing in. This is handy if you want to install knife plugins that are gems.

If you have Ruby and Chef/Knife installed in an area where your user can write:

1
knife gem install knife-config

If you’re using an Omnibus package install of Chef, or otherwise require root access to install:

1
knife gem install knife-config

Note If you’re trying to install a gem for Chef to use, you should put it in a chef_gem resource in a recipe.

metadata

This plugin prints out information from a cookbook’s metadata. It currently only works with metadata.rb files, and not metadata.json files.

In a cookbook’s directory, display the cookbook’s dependencies:

1
knife metadata dependencies

Show the dependencies and supported platforms:

1
knife metadata dependencies platforms

Use the -P option to pass a path to a cookbook.

1
knife metadata name dependencies -P ~/.berkshelf/cookbooks/rabbitmq-1.6.4

nukular

I wrote on this blog about this plugin awhile ago.

This plugin cleans up after running chef-client on a VMware Fusion machine.

1
knife nukular guineapig base guineapig.int.example.com

plugin_create

This creates a plugin scaffolding in ~/.chef/plugins/knife. It will join underscored words as CamelCaseClasses.

For example,

1
knife plugin create awesometown

Creates a plugin that is class Awesometown that can be executed with:

1
knife awesometown

Whereas this,

1
knife plugin create awesome_town

Creates a plugin that is class AwesomeTown that can be executed with:

1
knife plugin awesome town

Comments