简体   繁体   中英

Amazon OpsWorks custom cookbook RVM

I'm trying to install RVM with Amazon OpsWorks using the following cookbook https://github.com/fnichol/chef-rvm . I want rvm to run under the user tomcat6, so I included the recipe rvm::user with the correct attributes.

The error I'm getting is:

Wed, 06 Mar 2013 20:05:05 +0000 ERROR: Running exception handlers Wed, 06 Mar 2013 20:05:05 +0000 ERROR: Exception handlers complete Wed, 06 Mar 2013 20:05:05 +0000 DEBUG: Re-raising exception: LoadError - no such file to load -- rvm /opt/aws/opsworks/current/site-cookbooks/rvm/recipes/default.rb:29:in require' /opt/aws/opsworks/current/site-cookbooks/rvm/recipes/default.rb:29:in from_file'

And the piece of code raising the exception is:

chef_gem 'rvm' do
action :install
version '>= 1.11.3.6'
end

ruby_block "require rvm" do
    block do
        require 'rvm'
        create_rvm_shell_chef_wrapper
        create_rvm_chef_user_environment
     end
     action :create
end

After getting the error I logged in the instance with ssh and checked whether or not the rvm gem was installed. I could not see rvm listed under * LOCAL GEMS * .

Then I replaced the method chef_gem with gem_package and still got the same error. But this time when I checked gem list rvm was listed.

Any help? Thanks in advance.

The problem is highlighted here: https://forums.aws.amazon.com/thread.jspa?threadID=118646

OpsWorks' chef implementation is pretty restricted by Amazon. When chef is run on the node, it is actually run via a bundle. Since the rvm cookbook is installing a new gem (rvm) into the system and is attempting to make use of it, it fails since the rvm gem is not already part of the bundle (listed in the Gemfile).

The current workaround as of this writing is that opsworks has implemented a method to support the usage of custom gems.

I've been able to update the lines you mentioned with:

if defined?(OpsWorks) && defined?(OpsWorks::InternalGems)
  OpsWorks::InternalGems.internal_gem_package('rvm', :version => node['rvm']['chef_internal_rvm_gem_version'])
else
  chef_gem 'rvm' do
    action :install
    version '>= 1.11.3.6'
  end
end

Let me know if this works for you!

Are you sure you used the most recent rvm cookbook? Look at recipes/default.rb that gave you an error - contents of this file is different from what you posted in your description.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM