Monday, August 7, 2017

Using Custom knife plugins

Knife comes with a set of commands  out-of-the box.The built-in commands  deal with the elements of Chef-like cookbooks, roles,databags  and so on.How ever, it would be nice  to use  knife for more than just the basic stuff.
Knife comes with a API plugin and there are already a host of useful knife plugins built by the makers of chef and chef community.

Knife-ec2plugin

There are knife plugins for the most of the cloud providers.

which knife plugins are available to manage the AWS instances.

1) list the knife plugins that is shipped as Ruby gems using the chef command-line tool.

local@workstation:~/chef-repo $ chef gem search -r knife-
***REMOTE GEMS ***
...TRUNCATED OUTPUT
knife-azure  (1.6.0)
...TRUNCATED OUTPUT
knife-ec2   (0.13.0)
...TRUNCATED OUTPUT

2) Install the Ec2 plugin to manage servers in the AWS cloud 

local@workstation:~/chef-repo $ chef gem install knife-ec2
Building native extensions,This could take a while
...TRUNCATED OUTPUT
Fetching knife-ec2 plugins ............

6 gems installed


3) List all the available instance types in AWS using the knife ec2 plugin.Please see your own credentials  instead of XXX and YYYYY.


local@workstation:~/chef-repo $ knife ec2 flavour list  --aws-access-key-id XXX  --aws-secret-key-id YYYYY

id                                name                                    Arch     RAM         Disk  cores
c1.medium           HIGH-CPU-MEDIUM         32-bit      1740.8     350GB      5


How it works?

Knife looks for plugins in various places:

First,it looks in to the .chef directory, which is located inside your current chef repository, to find the plugins specific to this repository.

./.chef/knife/plugins/


Then it looks for the plugins in your .chef directory, which is located in your home directory to find plugins that you want to use chef repositories:


~/.chef/knife/plugins/



Finally,it looks for installed gems.Knife  will load all the code from any /chef/knife/ directory found in your installed ruby gems.This is the most common ways of using the plugins developed by chef and chef community.














1 comment:

  1. As i know Japanese product is very famous all of the world because they make their product very carefully. Their product is very flexible, strong, easy to use and also long lasting. Need more info about Japanese knife click here.

    ReplyDelete