How do I install the knife-ec2 plugin?

扶醉桌前 提交于 2019-12-10 13:11:33

问题


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.


回答1:


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



回答2:


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



回答3:


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




回答4:


Yes, This is tricky... Reason: You have 2 GEM binaries in your system. One by "rubygems in /bin/gem" and another by chef in "/opt/chef/embedded/bin/gem"

Knife makes use of the gem binary in the chef installation.

Solution: So you should have the plugins installed as /opt/chef/embedded/bin/gem install knife-ec2 /opt/chef/embedded/bin/gem install

Enjoy :)...



来源:https://stackoverflow.com/questions/22620745/how-do-i-install-the-knife-ec2-plugin

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!