Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I install the knife-ec2 plugin?

OSX, 10.9.2:

$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [universal.x86_64-darwin13]
$ knife -v
Chef: 11.10.4

When I run:

$ knife ec2 server list

I get:

FATAL: Cannot find sub command for: 'ec2 server list'
The ec2 commands were moved to plugins in Chef 0.10
You can install the plugin with `(sudo) gem install knife-ec2

I have the gem installed:

sudo gem install knife-ec2

runs without error. And gem list shows that it is installed:

$ sudo gem list|grep knife-ec2 
knife-ec2 (0.8.0)

The gem appears to be correctly installed here:

ls /Library/Ruby/Gems/2.0.0/gems/knife-ec2-0.8.0/
...

/usr/bin/knife on its own runs fine. Its quite likely it has something to do with where knife is looking for plugins, but what to do about it is unclear.

like image 805
thisjustin Avatar asked Mar 24 '14 21:03

thisjustin


3 Answers

I had this or a similar problem when I installed the chefdk after I'd already had chef/knife/knife-ec2 installed via gems (in an attempt to get vagrant-berkshelf working, if you're wondering).

What I found is that when installing the chefdk the embedded chef ruby is used by the knife binary in your path, instead of the system ruby, so you have to install your gems to the chef embedded ruby.

On OSX I did it like this:

/opt/chefdk/embedded/bin/gem install knife-ec2

Edit: Looks like there's a chef command to do this already:

chef gem install knife-ec2
like image 106
yoshiwaan Avatar answered Nov 15 '22 11:11

yoshiwaan


What's the output when you try running gem install knife? gem uses different paths when you run it with sudo

You can either run knife with sudo:

sudo knife ec2 server list

Or install gem as current user:

gem install knife-ec2

If the latter doesn't work, use RVM:

\curl -sSL https://get.rvm.io | bash
rvm install 2.0.0p247
gem install knife-ec2
like image 20
makhan Avatar answered Nov 15 '22 13:11

makhan


You are installing things into your system ruby (which is ill-advised). You need to use sudo before your knife command in this instance.

like image 1
sethvargo Avatar answered Nov 15 '22 12:11

sethvargo