simonmorley
simonmorley

Reputation: 2804

Using Knife From Rails Application

We're using Amazon's SNS to notify our application of changes to our autoscaling groups. In the event a server's terminated, we want to delete the node.

The notifications are working fine, as are the auto scaling groups. The only problem I have is that I cannot run the knife command from within my Rails App, I guess because it's calling the wrong Ruby version and trying to use the Application's gems. We're using RVM installed ruby-2.0.0-p195 and I don't want to bundle Chef.

The error therefore when I try and execute knife is:

system "cd /chefroot/ && /usr/bin/knife"

/Users/SM/.rvm/gems/ruby-2.0.0-p195@global/gems/bundler-1.3.5/lib/bundler/rubygems_integration.rb:214:in `block in replace_gem': chef is not part of the bundle. Add it to Gemfile. (Gem::LoadError)

I can see knife's calling chef, but needs to do so as a system gem. In knife.rb:

load Gem.bin_path('chef', 'knife', version)

Have also seen this SO post but I don't want to use the rvm-with gem.

I looked at the Opscode API instead but that's not really working for us. Is there a better, more sophisticated way to do this?

Upvotes: 1

Views: 840

Answers (1)

Mark O'Connor
Mark O'Connor

Reputation: 77941

I would consider using ridley gem: https://github.com/RiotGames/ridley

Upvotes: 2

Related Questions