Rbenv setup for system wide


#1

Thanks to your suggestions, I am going to use rbenv to manage my servers
system wide ruby and gems setup.

From the readme it seems to alude to using rbenv as dependancy to a
cookbook, but I want to setup a system wide (default) ruby and rubygems.

Does this mean I have to put this in my role_name.rb file? (I’m using
chef-solo).

My current base.rb is:

name 'base’
description 'base role that all nodes will have’
run_list “recipe[build-essential]”, “recipe[ohai]”, “recipe[runit]”,
“recipe[yum]”, “recipe[openssl]”, “recipe[git]”, “recipe[apt]”,
“recipe[java]”

So do I put rbenv related code in here like:

depends 'rbenv'

include_recipe "rbenv::default"
include_recipe "rbenv::ruby_build"

rbenv_ruby "1.9.3-p194"

rbenv_gem "bundler" do
  ruby_version "1.9.3-p194"
end

How can I create a list of gems I want pre-installed for default ruby to be
able to access?


#2

Create a cookbook “myorg_system_wide_ruby” and add the rbenv ‘related
code’ you mentioned in there.

depends goes into metadata.rb, the rest in a recipe

Cheers,

AJ

On 19 February 2013 10:11, S Ahmed sahmed1020@gmail.com wrote:

Thanks to your suggestions, I am going to use rbenv to manage my servers
system wide ruby and gems setup.

From the readme it seems to alude to using rbenv as dependancy to a
cookbook, but I want to setup a system wide (default) ruby and rubygems.

Does this mean I have to put this in my role_name.rb file? (I’m using
chef-solo).

My current base.rb is:

name 'base’
description 'base role that all nodes will have’
run_list “recipe[build-essential]”, “recipe[ohai]”, “recipe[runit]”,
“recipe[yum]”, “recipe[openssl]”, “recipe[git]”, “recipe[apt]”,
“recipe[java]”

So do I put rbenv related code in here like:

depends 'rbenv'

include_recipe "rbenv::default"
include_recipe "rbenv::ruby_build"

rbenv_ruby "1.9.3-p194"

rbenv_gem "bundler" do
  ruby_version "1.9.3-p194"
end

How can I create a list of gems I want pre-installed for default ruby to be
able to access?


#3

Oh, as for gems: toss 'em in an attribute, map the attribute into
gem_package resources after rbenv is installed and activated so that
gem_package goes to the correct VM.

Cheers,

AJ

On 19 February 2013 10:14, AJ Christensen aj@junglist.gen.nz wrote:

Create a cookbook “myorg_system_wide_ruby” and add the rbenv ‘related
code’ you mentioned in there.

depends goes into metadata.rb, the rest in a recipe

Cheers,

AJ

On 19 February 2013 10:11, S Ahmed sahmed1020@gmail.com wrote:

Thanks to your suggestions, I am going to use rbenv to manage my servers
system wide ruby and gems setup.

From the readme it seems to alude to using rbenv as dependancy to a
cookbook, but I want to setup a system wide (default) ruby and rubygems.

Does this mean I have to put this in my role_name.rb file? (I’m using
chef-solo).

My current base.rb is:

name 'base’
description 'base role that all nodes will have’
run_list “recipe[build-essential]”, “recipe[ohai]”, “recipe[runit]”,
“recipe[yum]”, “recipe[openssl]”, “recipe[git]”, “recipe[apt]”,
“recipe[java]”

So do I put rbenv related code in here like:

depends 'rbenv'

include_recipe "rbenv::default"
include_recipe "rbenv::ruby_build"

rbenv_ruby "1.9.3-p194"

rbenv_gem "bundler" do
  ruby_version "1.9.3-p194"
end

How can I create a list of gems I want pre-installed for default ruby to be
able to access?


#4

thanks, looks like I got most of it.

  1. How do I set it as global (system wide, not user specific?):
    default.rb:

include_recipe "rbenv::default"
include_recipe “rbenv::ruby_build”

rbenv_ruby “1.9.3-p194”

After my chef-solo ran, I get this when doing: ruby

rbenv: ruby: command not found

The `ruby’ command exists in these Ruby versions:
1.9.3-p194

  1. if I want to install more gems, I have to keep repeating this or like
    you said put it in a each loop right?

rbenv_gem “bundler” do
ruby_version "1.9.3-p194"
end

rbenv_gem “rubygems” do
ruby_version "1.9.3-p194"
end


On Mon, Feb 18, 2013 at 4:17 PM, AJ Christensen aj@junglist.gen.nz wrote:

Oh, as for gems: toss 'em in an attribute, map the attribute into
gem_package resources after rbenv is installed and activated so that
gem_package goes to the correct VM.

Cheers,

AJ

On 19 February 2013 10:14, AJ Christensen aj@junglist.gen.nz wrote:

Create a cookbook “myorg_system_wide_ruby” and add the rbenv ‘related
code’ you mentioned in there.

depends goes into metadata.rb, the rest in a recipe

Cheers,

AJ

On 19 February 2013 10:11, S Ahmed sahmed1020@gmail.com wrote:

Thanks to your suggestions, I am going to use rbenv to manage my servers
system wide ruby and gems setup.

From the readme it seems to alude to using rbenv as dependancy to a
cookbook, but I want to setup a system wide (default) ruby and rubygems.

Does this mean I have to put this in my role_name.rb file? (I’m using
chef-solo).

My current base.rb is:

name 'base’
description 'base role that all nodes will have’
run_list “recipe[build-essential]”, “recipe[ohai]”, “recipe[runit]”,
“recipe[yum]”, “recipe[openssl]”, “recipe[git]”, “recipe[apt]”,
“recipe[java]”

So do I put rbenv related code in here like:

depends 'rbenv'

include_recipe "rbenv::default"
include_recipe "rbenv::ruby_build"

rbenv_ruby "1.9.3-p194"

rbenv_gem "bundler" do
  ruby_version "1.9.3-p194"
end

How can I create a list of gems I want pre-installed for default ruby
to be

able to access?


#5

You’ll want ‘recipe[rbenv::system_install]’ and any appropriate $PATH
modifications via /etc/profile.d – can be a file/contents; make use
of the LWRP ‘rbenv_global’ [0]

As I mentioned previously, a node attribute hash-map like this suits:

node.default[‘my_org_rbenv’][‘system_rubygems’][‘1.9.3-p194’] = {
bundler: {
version: ‘1.2.3’,
action: ‘install’,
}
}

system_ruby_version = node[‘my_org_rbenv’][‘system_ruby_version’]

rbenv_global system_ruby_version

node[‘my_org_rbenv’][‘system_rubygems’][system_ruby_version].each do
|gem, params|
rbenv_gem gem do
rbenv_version systemruby
version params[‘version’]
action params[‘action’].to_sym
end
end

Note that this only reduces repetition and is not required at all.

Cheers,

AJ

[0] rbenv LWRPs: https://github.com/fnichol/chef-rbenv#lwrps

On 25 February 2013 07:10, S Ahmed sahmed1020@gmail.com wrote:

thanks, looks like I got most of it.

  1. How do I set it as global (system wide, not user specific?):
    default.rb:

include_recipe "rbenv::default"
include_recipe “rbenv::ruby_build”

rbenv_ruby “1.9.3-p194”

After my chef-solo ran, I get this when doing: ruby

rbenv: ruby: command not found

The `ruby’ command exists in these Ruby versions:
1.9.3-p194

  1. if I want to install more gems, I have to keep repeating this or like you
    said put it in a each loop right?

rbenv_gem “bundler” do
ruby_version "1.9.3-p194"
end

rbenv_gem “rubygems” do
ruby_version "1.9.3-p194"
end


On Mon, Feb 18, 2013 at 4:17 PM, AJ Christensen aj@junglist.gen.nz wrote:

Oh, as for gems: toss 'em in an attribute, map the attribute into
gem_package resources after rbenv is installed and activated so that
gem_package goes to the correct VM.

Cheers,

AJ

On 19 February 2013 10:14, AJ Christensen aj@junglist.gen.nz wrote:

Create a cookbook “myorg_system_wide_ruby” and add the rbenv ‘related
code’ you mentioned in there.

depends goes into metadata.rb, the rest in a recipe

Cheers,

AJ

On 19 February 2013 10:11, S Ahmed sahmed1020@gmail.com wrote:

Thanks to your suggestions, I am going to use rbenv to manage my
servers
system wide ruby and gems setup.

From the readme it seems to alude to using rbenv as dependancy to a
cookbook, but I want to setup a system wide (default) ruby and
rubygems.

Does this mean I have to put this in my role_name.rb file? (I’m using
chef-solo).

My current base.rb is:

name 'base’
description 'base role that all nodes will have’
run_list “recipe[build-essential]”, “recipe[ohai]”, “recipe[runit]”,
“recipe[yum]”, “recipe[openssl]”, “recipe[git]”, “recipe[apt]”,
“recipe[java]”

So do I put rbenv related code in here like:

depends 'rbenv'

include_recipe "rbenv::default"
include_recipe "rbenv::ruby_build"

rbenv_ruby "1.9.3-p194"

rbenv_gem "bundler" do
  ruby_version "1.9.3-p194"
end

How can I create a list of gems I want pre-installed for default ruby
to be
able to access?


#6

Ok let me start over here, I was using another rbenv that is differrent
from fnichol’s cookbook.

In my cookbooks I have rbenv (fnichols) and ruby_build (also fnichols), I
just downloaded the zip and put it in my /cookbooks (is that ok or do I
have to build it?)

/cookbook/rbenv
/cookbook/ruby_build

  1. base.rb role:

run_list … “recipe[ruby_build]”, “recipe[my_ruby]”

  1. my_ruby

metadata.rb:

depends “rbenv”

recipes/default.rb:

include_recipe "rbenv::system"
include_recipe “rbenv::ruby_build”

rbenv_ruby “1.9.3” do
ruby_version "1.9.3-p194"
global true
end

rbenv_gem “bundler” do
ruby_version "1.9.3-p194"
end

rbenv_gem “rubygems” do
ruby_version "1.9.3-p194"
end

Now when I run it I get this error:

2013-02-24T22:16:51+00:00] FATAL: Chef::Exceptions::RecipeNotFound: could
not find recipe ruby_build for cookbook rbenv

On Sun, Feb 24, 2013 at 3:48 PM, AJ Christensen aj@junglist.gen.nz wrote:

You’ll want ‘recipe[rbenv::system_install]’ and any appropriate $PATH
modifications via /etc/profile.d – can be a file/contents; make use
of the LWRP ‘rbenv_global’ [0]

As I mentioned previously, a node attribute hash-map like this suits:

node.default[‘my_org_rbenv’][‘system_rubygems’][‘1.9.3-p194’] = {
bundler: {
version: ‘1.2.3’,
action: ‘install’,
}
}

system_ruby_version = node[‘my_org_rbenv’][‘system_ruby_version’]

rbenv_global system_ruby_version

node[‘my_org_rbenv’][‘system_rubygems’][system_ruby_version].each do
|gem, params|
rbenv_gem gem do
rbenv_version systemruby
version params[‘version’]
action params[‘action’].to_sym
end
end

Note that this only reduces repetition and is not required at all.

Cheers,

AJ

[0] rbenv LWRPs: https://github.com/fnichol/chef-rbenv#lwrps

On 25 February 2013 07:10, S Ahmed sahmed1020@gmail.com wrote:

thanks, looks like I got most of it.

  1. How do I set it as global (system wide, not user specific?):
    default.rb:

include_recipe "rbenv::default"
include_recipe “rbenv::ruby_build”

rbenv_ruby “1.9.3-p194”

After my chef-solo ran, I get this when doing: ruby

rbenv: ruby: command not found

The `ruby’ command exists in these Ruby versions:
1.9.3-p194

  1. if I want to install more gems, I have to keep repeating this or like
    you
    said put it in a each loop right?

rbenv_gem “bundler” do
ruby_version "1.9.3-p194"
end

rbenv_gem “rubygems” do
ruby_version "1.9.3-p194"
end


On Mon, Feb 18, 2013 at 4:17 PM, AJ Christensen aj@junglist.gen.nz
wrote:

Oh, as for gems: toss 'em in an attribute, map the attribute into
gem_package resources after rbenv is installed and activated so that
gem_package goes to the correct VM.

Cheers,

AJ

On 19 February 2013 10:14, AJ Christensen aj@junglist.gen.nz wrote:

Create a cookbook “myorg_system_wide_ruby” and add the rbenv ‘related
code’ you mentioned in there.

depends goes into metadata.rb, the rest in a recipe

Cheers,

AJ

On 19 February 2013 10:11, S Ahmed sahmed1020@gmail.com wrote:

Thanks to your suggestions, I am going to use rbenv to manage my
servers
system wide ruby and gems setup.

From the readme it seems to alude to using rbenv as dependancy to a
cookbook, but I want to setup a system wide (default) ruby and
rubygems.

Does this mean I have to put this in my role_name.rb file? (I’m
using

chef-solo).

My current base.rb is:

name 'base’
description 'base role that all nodes will have’
run_list “recipe[build-essential]”, “recipe[ohai]”, “recipe[runit]”,
“recipe[yum]”, “recipe[openssl]”, “recipe[git]”, “recipe[apt]”,
“recipe[java]”

So do I put rbenv related code in here like:

depends 'rbenv'

include_recipe "rbenv::default"
include_recipe "rbenv::ruby_build"

rbenv_ruby "1.9.3-p194"

rbenv_gem "bundler" do
  ruby_version "1.9.3-p194"
end

How can I create a list of gems I want pre-installed for default ruby
to be
able to access?


#7

Ok got a bit futher:

recipe/default.rb:

include_recipe "ruby_build"
include_recipe "rbenv::system"
include_recipe “rbenv::system_install”

ruby_build_ruby "1.9.3-p194"
rbenv_global “1.9.3-p194”

Error:

Generated at 2013-02-25 00:08:05 +0000
Mixlib::ShellOut::ShellCommandFailed: script[rbenv global 1.9.3-p194
(system)] (/home/ubuntu/chef/cookbooks/rbenv/providers/script.rb line 28)
had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to
exit with [0], but received ‘1’
---- Begin output of “bash” “/tmp/chef-script20130225-4608-xuqhko” ----
STDOUT:
STDERR: rbenv: version global' not installed rbenv: version1.9.3-p194’ not installed
---- End output of “bash” “/tmp/chef-script20130225-4608-xuqhko” ----
Ran “bash” “/tmp/chef-script20130225-4608-xuqhko” returned 1
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/mixlib-shellout-1.1.0/lib/mixlib/shellout.rb:248:in
invalid!' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/mixlib-shellout-1.1.0/lib/mixlib/shellout.rb:234:inerror!’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/mixin/shell_out.rb:36:in
shell_out!' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/provider/execute.rb:62:inblock in action_run’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/mixin/why_run.rb:52:in
call' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/mixin/why_run.rb:52:inadd_action’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/provider.rb:151:in
converge_by' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/provider/execute.rb:61:inaction_run’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/provider/script.rb:33:in
action_run' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/provider.rb:114:inrun_action’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/resource.rb:603:in
run_action' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/runner.rb:50:inrun_action’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/runner.rb:82:in
block (2 levels) in converge' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/runner.rb:82:ineach’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/runner.rb:82:in
block in converge' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/resource_collection.rb:94:inblock in execute_each_resource’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/resource_collection/stepable_iterator.rb:116:in
call' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/resource_collection/stepable_iterator.rb:116:incall_iterator_block’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/resource_collection/stepable_iterator.rb:85:in
step' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/resource_collection/stepable_iterator.rb:104:initerate’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/resource_collection/stepable_iterator.rb:55:in
each_with_index' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/resource_collection.rb:92:inexecute_each_resource’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/runner.rb:81:in
converge' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/client.rb:404:inconverge’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/client.rb:469:in
do_run' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/client.rb:200:inrun’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/application.rb:190:in
run_chef_client' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/application/solo.rb:239:inblock in run_application’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/application/solo.rb:231:in
loop' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/application/solo.rb:231:inrun_application’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/application.rb:73:in
run' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/bin/chef-solo:25:in<top (required)>’
/usr/bin/chef-solo:23:in `load’

On Sun, Feb 24, 2013 at 5:21 PM, S Ahmed sahmed1020@gmail.com wrote:

Ok let me start over here, I was using another rbenv that is differrent
from fnichol’s cookbook.

In my cookbooks I have rbenv (fnichols) and ruby_build (also fnichols), I
just downloaded the zip and put it in my /cookbooks (is that ok or do I
have to build it?)

/cookbook/rbenv
/cookbook/ruby_build

  1. base.rb role:

run_list … “recipe[ruby_build]”, “recipe[my_ruby]”

  1. my_ruby

metadata.rb:

depends “rbenv”

recipes/default.rb:

include_recipe "rbenv::system"
include_recipe “rbenv::ruby_build”

rbenv_ruby “1.9.3” do
ruby_version "1.9.3-p194"
global true
end

rbenv_gem “bundler” do
ruby_version "1.9.3-p194"
end

rbenv_gem “rubygems” do
ruby_version "1.9.3-p194"
end

Now when I run it I get this error:

2013-02-24T22:16:51+00:00] FATAL: Chef::Exceptions::RecipeNotFound: could
not find recipe ruby_build for cookbook rbenv

On Sun, Feb 24, 2013 at 3:48 PM, AJ Christensen aj@junglist.gen.nzwrote:

You’ll want ‘recipe[rbenv::system_install]’ and any appropriate $PATH
modifications via /etc/profile.d – can be a file/contents; make use
of the LWRP ‘rbenv_global’ [0]

As I mentioned previously, a node attribute hash-map like this suits:

node.default[‘my_org_rbenv’][‘system_rubygems’][‘1.9.3-p194’] = {
bundler: {
version: ‘1.2.3’,
action: ‘install’,
}
}

system_ruby_version = node[‘my_org_rbenv’][‘system_ruby_version’]

rbenv_global system_ruby_version

node[‘my_org_rbenv’][‘system_rubygems’][system_ruby_version].each do
|gem, params|
rbenv_gem gem do
rbenv_version systemruby
version params[‘version’]
action params[‘action’].to_sym
end
end

Note that this only reduces repetition and is not required at all.

Cheers,

AJ

[0] rbenv LWRPs: https://github.com/fnichol/chef-rbenv#lwrps

On 25 February 2013 07:10, S Ahmed sahmed1020@gmail.com wrote:

thanks, looks like I got most of it.

  1. How do I set it as global (system wide, not user specific?):
    default.rb:

include_recipe "rbenv::default"
include_recipe “rbenv::ruby_build”

rbenv_ruby “1.9.3-p194”

After my chef-solo ran, I get this when doing: ruby

rbenv: ruby: command not found

The `ruby’ command exists in these Ruby versions:
1.9.3-p194

  1. if I want to install more gems, I have to keep repeating this or
    like you
    said put it in a each loop right?

rbenv_gem “bundler” do
ruby_version "1.9.3-p194"
end

rbenv_gem “rubygems” do
ruby_version "1.9.3-p194"
end


On Mon, Feb 18, 2013 at 4:17 PM, AJ Christensen aj@junglist.gen.nz
wrote:

Oh, as for gems: toss 'em in an attribute, map the attribute into
gem_package resources after rbenv is installed and activated so that
gem_package goes to the correct VM.

Cheers,

AJ

On 19 February 2013 10:14, AJ Christensen aj@junglist.gen.nz wrote:

Create a cookbook “myorg_system_wide_ruby” and add the rbenv ‘related
code’ you mentioned in there.

depends goes into metadata.rb, the rest in a recipe

Cheers,

AJ

On 19 February 2013 10:11, S Ahmed sahmed1020@gmail.com wrote:

Thanks to your suggestions, I am going to use rbenv to manage my
servers
system wide ruby and gems setup.

From the readme it seems to alude to using rbenv as dependancy to a
cookbook, but I want to setup a system wide (default) ruby and
rubygems.

Does this mean I have to put this in my role_name.rb file? (I’m
using

chef-solo).

My current base.rb is:

name 'base’
description 'base role that all nodes will have’
run_list “recipe[build-essential]”, “recipe[ohai]”, “recipe[runit]”,
“recipe[yum]”, “recipe[openssl]”, “recipe[git]”, “recipe[apt]”,
“recipe[java]”

So do I put rbenv related code in here like:

depends 'rbenv'

include_recipe "rbenv::default"
include_recipe "rbenv::ruby_build"

rbenv_ruby "1.9.3-p194"

rbenv_gem "bundler" do
  ruby_version "1.9.3-p194"
end

How can I create a list of gems I want pre-installed for default
ruby

to be
able to access?


#8

I built a test cookbook to try to figure this out. It works for me –
‘bundle && bundle exec vagrant up’ [0]

You don’t need to use the ruby_build_ruby LWRP, the functionality is
included in the rbenv LWRPs but is extended by the existence of the
ruby_build cookbook.

Be sure to inspect the Berksfile (it refers to git versions of
Fletcher’s cookbooks, not sure if these are required), and also the
metadata and default recipe of ‘system_wide_rbenv’. [1]

Cheers,

–AJ

[0] https://github.com/fujin/system_wide_rbenv
[1] https://github.com/fujin/system_wide_rbenv/blob/master/recipes/default.rb#L20-L23

On 25 February 2013 13:25, S Ahmed sahmed1020@gmail.com wrote:

Ok got a bit futher:

recipe/default.rb:

include_recipe "ruby_build"
include_recipe "rbenv::system"
include_recipe “rbenv::system_install”

ruby_build_ruby "1.9.3-p194"
rbenv_global “1.9.3-p194”

Error:

Generated at 2013-02-25 00:08:05 +0000
Mixlib::ShellOut::ShellCommandFailed: script[rbenv global 1.9.3-p194
(system)] (/home/ubuntu/chef/cookbooks/rbenv/providers/script.rb line 28)
had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit
with [0], but received ‘1’
---- Begin output of “bash” “/tmp/chef-script20130225-4608-xuqhko” ----
STDOUT:
STDERR: rbenv: version global' not installed rbenv: version1.9.3-p194’ not installed
---- End output of “bash” “/tmp/chef-script20130225-4608-xuqhko” ----
Ran “bash” “/tmp/chef-script20130225-4608-xuqhko” returned 1
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/mixlib-shellout-1.1.0/lib/mixlib/shellout.rb:248:in
invalid!' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/mixlib-shellout-1.1.0/lib/mixlib/shellout.rb:234:inerror!’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/mixin/shell_out.rb:36:in
shell_out!' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/provider/execute.rb:62:inblock in action_run’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/mixin/why_run.rb:52:in
call' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/mixin/why_run.rb:52:inadd_action’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/provider.rb:151:in
converge_by' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/provider/execute.rb:61:inaction_run’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/provider/script.rb:33:in
action_run' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/provider.rb:114:inrun_action’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/resource.rb:603:in
run_action' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/runner.rb:50:inrun_action’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/runner.rb:82:in
block (2 levels) in converge' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/runner.rb:82:ineach’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/runner.rb:82:in
block in converge' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/resource_collection.rb:94:inblock in execute_each_resource’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/resource_collection/stepable_iterator.rb:116:in
call' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/resource_collection/stepable_iterator.rb:116:incall_iterator_block’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/resource_collection/stepable_iterator.rb:85:in
step' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/resource_collection/stepable_iterator.rb:104:initerate’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/resource_collection/stepable_iterator.rb:55:in
each_with_index' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/resource_collection.rb:92:inexecute_each_resource’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/runner.rb:81:in
converge' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/client.rb:404:inconverge’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/client.rb:469:in
do_run' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/client.rb:200:inrun’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/application.rb:190:in
run_chef_client' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/application/solo.rb:239:inblock in run_application’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/application/solo.rb:231:in
loop' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/application/solo.rb:231:inrun_application’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/application.rb:73:in
run' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/bin/chef-solo:25:in<top (required)>’
/usr/bin/chef-solo:23:in `load’

On Sun, Feb 24, 2013 at 5:21 PM, S Ahmed sahmed1020@gmail.com wrote:

Ok let me start over here, I was using another rbenv that is differrent
from fnichol’s cookbook.

In my cookbooks I have rbenv (fnichols) and ruby_build (also fnichols), I
just downloaded the zip and put it in my /cookbooks (is that ok or do I have
to build it?)

/cookbook/rbenv
/cookbook/ruby_build

  1. base.rb role:

run_list … “recipe[ruby_build]”, “recipe[my_ruby]”

  1. my_ruby

metadata.rb:

depends “rbenv”

recipes/default.rb:

include_recipe "rbenv::system"
include_recipe “rbenv::ruby_build”

rbenv_ruby “1.9.3” do
ruby_version "1.9.3-p194"
global true
end

rbenv_gem “bundler” do
ruby_version "1.9.3-p194"
end

rbenv_gem “rubygems” do
ruby_version "1.9.3-p194"
end

Now when I run it I get this error:

2013-02-24T22:16:51+00:00] FATAL: Chef::Exceptions::RecipeNotFound: could
not find recipe ruby_build for cookbook rbenv

On Sun, Feb 24, 2013 at 3:48 PM, AJ Christensen aj@junglist.gen.nz
wrote:

You’ll want ‘recipe[rbenv::system_install]’ and any appropriate $PATH
modifications via /etc/profile.d – can be a file/contents; make use
of the LWRP ‘rbenv_global’ [0]

As I mentioned previously, a node attribute hash-map like this suits:

node.default[‘my_org_rbenv’][‘system_rubygems’][‘1.9.3-p194’] = {
bundler: {
version: ‘1.2.3’,
action: ‘install’,
}
}

system_ruby_version = node[‘my_org_rbenv’][‘system_ruby_version’]

rbenv_global system_ruby_version

node[‘my_org_rbenv’][‘system_rubygems’][system_ruby_version].each do
|gem, params|
rbenv_gem gem do
rbenv_version systemruby
version params[‘version’]
action params[‘action’].to_sym
end
end

Note that this only reduces repetition and is not required at all.

Cheers,

AJ

[0] rbenv LWRPs: https://github.com/fnichol/chef-rbenv#lwrps

On 25 February 2013 07:10, S Ahmed sahmed1020@gmail.com wrote:

thanks, looks like I got most of it.

  1. How do I set it as global (system wide, not user specific?):
    default.rb:

include_recipe "rbenv::default"
include_recipe “rbenv::ruby_build”

rbenv_ruby “1.9.3-p194”

After my chef-solo ran, I get this when doing: ruby

rbenv: ruby: command not found

The `ruby’ command exists in these Ruby versions:
1.9.3-p194

  1. if I want to install more gems, I have to keep repeating this or
    like you
    said put it in a each loop right?

rbenv_gem “bundler” do
ruby_version "1.9.3-p194"
end

rbenv_gem “rubygems” do
ruby_version "1.9.3-p194"
end


On Mon, Feb 18, 2013 at 4:17 PM, AJ Christensen aj@junglist.gen.nz
wrote:

Oh, as for gems: toss 'em in an attribute, map the attribute into
gem_package resources after rbenv is installed and activated so that
gem_package goes to the correct VM.

Cheers,

AJ

On 19 February 2013 10:14, AJ Christensen aj@junglist.gen.nz wrote:

Create a cookbook “myorg_system_wide_ruby” and add the rbenv
’related
code’ you mentioned in there.

depends goes into metadata.rb, the rest in a recipe

Cheers,

AJ

On 19 February 2013 10:11, S Ahmed sahmed1020@gmail.com wrote:

Thanks to your suggestions, I am going to use rbenv to manage my
servers
system wide ruby and gems setup.

From the readme it seems to alude to using rbenv as dependancy to a
cookbook, but I want to setup a system wide (default) ruby and
rubygems.

Does this mean I have to put this in my role_name.rb file? (I’m
using
chef-solo).

My current base.rb is:

name 'base’
description 'base role that all nodes will have’
run_list “recipe[build-essential]”, “recipe[ohai]”,
“recipe[runit]”,
“recipe[yum]”, “recipe[openssl]”, “recipe[git]”, “recipe[apt]”,
“recipe[java]”

So do I put rbenv related code in here like:

depends 'rbenv'

include_recipe "rbenv::default"
include_recipe "rbenv::ruby_build"

rbenv_ruby "1.9.3-p194"

rbenv_gem "bundler" do
  ruby_version "1.9.3-p194"
end

How can I create a list of gems I want pre-installed for default
ruby
to be
able to access?


#9

Oh, with regard to previous email: logs from the run @

Cheers,

AJ

On 25 February 2013 15:52, AJ Christensen aj@junglist.gen.nz wrote:

I built a test cookbook to try to figure this out. It works for me –
‘bundle && bundle exec vagrant up’ [0]

You don’t need to use the ruby_build_ruby LWRP, the functionality is
included in the rbenv LWRPs but is extended by the existence of the
ruby_build cookbook.

Be sure to inspect the Berksfile (it refers to git versions of
Fletcher’s cookbooks, not sure if these are required), and also the
metadata and default recipe of ‘system_wide_rbenv’. [1]

Cheers,

–AJ

[0] https://github.com/fujin/system_wide_rbenv
[1] https://github.com/fujin/system_wide_rbenv/blob/master/recipes/default.rb#L20-L23

On 25 February 2013 13:25, S Ahmed sahmed1020@gmail.com wrote:

Ok got a bit futher:

recipe/default.rb:

include_recipe "ruby_build"
include_recipe "rbenv::system"
include_recipe “rbenv::system_install”

ruby_build_ruby "1.9.3-p194"
rbenv_global “1.9.3-p194”

Error:

Generated at 2013-02-25 00:08:05 +0000
Mixlib::ShellOut::ShellCommandFailed: script[rbenv global 1.9.3-p194
(system)] (/home/ubuntu/chef/cookbooks/rbenv/providers/script.rb line 28)
had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit
with [0], but received ‘1’
---- Begin output of “bash” “/tmp/chef-script20130225-4608-xuqhko” ----
STDOUT:
STDERR: rbenv: version global' not installed rbenv: version1.9.3-p194’ not installed
---- End output of “bash” “/tmp/chef-script20130225-4608-xuqhko” ----
Ran “bash” “/tmp/chef-script20130225-4608-xuqhko” returned 1
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/mixlib-shellout-1.1.0/lib/mixlib/shellout.rb:248:in
invalid!' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/mixlib-shellout-1.1.0/lib/mixlib/shellout.rb:234:inerror!’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/mixin/shell_out.rb:36:in
shell_out!' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/provider/execute.rb:62:inblock in action_run’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/mixin/why_run.rb:52:in
call' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/mixin/why_run.rb:52:inadd_action’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/provider.rb:151:in
converge_by' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/provider/execute.rb:61:inaction_run’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/provider/script.rb:33:in
action_run' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/provider.rb:114:inrun_action’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/resource.rb:603:in
run_action' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/runner.rb:50:inrun_action’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/runner.rb:82:in
block (2 levels) in converge' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/runner.rb:82:ineach’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/runner.rb:82:in
block in converge' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/resource_collection.rb:94:inblock in execute_each_resource’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/resource_collection/stepable_iterator.rb:116:in
call' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/resource_collection/stepable_iterator.rb:116:incall_iterator_block’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/resource_collection/stepable_iterator.rb:85:in
step' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/resource_collection/stepable_iterator.rb:104:initerate’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/resource_collection/stepable_iterator.rb:55:in
each_with_index' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/resource_collection.rb:92:inexecute_each_resource’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/runner.rb:81:in
converge' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/client.rb:404:inconverge’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/client.rb:469:in
do_run' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/client.rb:200:inrun’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/application.rb:190:in
run_chef_client' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/application/solo.rb:239:inblock in run_application’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/application/solo.rb:231:in
loop' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/application/solo.rb:231:inrun_application’
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/application.rb:73:in
run' /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/bin/chef-solo:25:in<top (required)>’
/usr/bin/chef-solo:23:in `load’

On Sun, Feb 24, 2013 at 5:21 PM, S Ahmed sahmed1020@gmail.com wrote:

Ok let me start over here, I was using another rbenv that is differrent
from fnichol’s cookbook.

In my cookbooks I have rbenv (fnichols) and ruby_build (also fnichols), I
just downloaded the zip and put it in my /cookbooks (is that ok or do I have
to build it?)

/cookbook/rbenv
/cookbook/ruby_build

  1. base.rb role:

run_list … “recipe[ruby_build]”, “recipe[my_ruby]”

  1. my_ruby

metadata.rb:

depends “rbenv”

recipes/default.rb:

include_recipe "rbenv::system"
include_recipe “rbenv::ruby_build”

rbenv_ruby “1.9.3” do
ruby_version "1.9.3-p194"
global true
end

rbenv_gem “bundler” do
ruby_version "1.9.3-p194"
end

rbenv_gem “rubygems” do
ruby_version "1.9.3-p194"
end

Now when I run it I get this error:

2013-02-24T22:16:51+00:00] FATAL: Chef::Exceptions::RecipeNotFound: could
not find recipe ruby_build for cookbook rbenv

On Sun, Feb 24, 2013 at 3:48 PM, AJ Christensen aj@junglist.gen.nz
wrote:

You’ll want ‘recipe[rbenv::system_install]’ and any appropriate $PATH
modifications via /etc/profile.d – can be a file/contents; make use
of the LWRP ‘rbenv_global’ [0]

As I mentioned previously, a node attribute hash-map like this suits:

node.default[‘my_org_rbenv’][‘system_rubygems’][‘1.9.3-p194’] = {
bundler: {
version: ‘1.2.3’,
action: ‘install’,
}
}

system_ruby_version = node[‘my_org_rbenv’][‘system_ruby_version’]

rbenv_global system_ruby_version

node[‘my_org_rbenv’][‘system_rubygems’][system_ruby_version].each do
|gem, params|
rbenv_gem gem do
rbenv_version systemruby
version params[‘version’]
action params[‘action’].to_sym
end
end

Note that this only reduces repetition and is not required at all.

Cheers,

AJ

[0] rbenv LWRPs: https://github.com/fnichol/chef-rbenv#lwrps

On 25 February 2013 07:10, S Ahmed sahmed1020@gmail.com wrote:

thanks, looks like I got most of it.

  1. How do I set it as global (system wide, not user specific?):
    default.rb:

include_recipe "rbenv::default"
include_recipe “rbenv::ruby_build”

rbenv_ruby “1.9.3-p194”

After my chef-solo ran, I get this when doing: ruby

rbenv: ruby: command not found

The `ruby’ command exists in these Ruby versions:
1.9.3-p194

  1. if I want to install more gems, I have to keep repeating this or
    like you
    said put it in a each loop right?

rbenv_gem “bundler” do
ruby_version "1.9.3-p194"
end

rbenv_gem “rubygems” do
ruby_version "1.9.3-p194"
end


On Mon, Feb 18, 2013 at 4:17 PM, AJ Christensen aj@junglist.gen.nz
wrote:

Oh, as for gems: toss 'em in an attribute, map the attribute into
gem_package resources after rbenv is installed and activated so that
gem_package goes to the correct VM.

Cheers,

AJ

On 19 February 2013 10:14, AJ Christensen aj@junglist.gen.nz wrote:

Create a cookbook “myorg_system_wide_ruby” and add the rbenv
’related
code’ you mentioned in there.

depends goes into metadata.rb, the rest in a recipe

Cheers,

AJ

On 19 February 2013 10:11, S Ahmed sahmed1020@gmail.com wrote:

Thanks to your suggestions, I am going to use rbenv to manage my
servers
system wide ruby and gems setup.

From the readme it seems to alude to using rbenv as dependancy to a
cookbook, but I want to setup a system wide (default) ruby and
rubygems.

Does this mean I have to put this in my role_name.rb file? (I’m
using
chef-solo).

My current base.rb is:

name 'base’
description 'base role that all nodes will have’
run_list “recipe[build-essential]”, “recipe[ohai]”,
“recipe[runit]”,
“recipe[yum]”, “recipe[openssl]”, “recipe[git]”, “recipe[apt]”,
“recipe[java]”

So do I put rbenv related code in here like:

depends 'rbenv'

include_recipe "rbenv::default"
include_recipe "rbenv::ruby_build"

rbenv_ruby "1.9.3-p194"

rbenv_gem "bundler" do
  ruby_version "1.9.3-p194"
end

How can I create a list of gems I want pre-installed for default
ruby
to be
able to access?


#10

thanks finally tested it and it worked!

On Sun, Feb 24, 2013 at 10:03 PM, AJ Christensen aj@junglist.gen.nz wrote:

Oh, with regard to previous email: logs from the run @
https://gist.github.com/fujin/3486e11355980f27771d

Cheers,

AJ

On 25 February 2013 15:52, AJ Christensen aj@junglist.gen.nz wrote:

I built a test cookbook to try to figure this out. It works for me –
‘bundle && bundle exec vagrant up’ [0]

You don’t need to use the ruby_build_ruby LWRP, the functionality is
included in the rbenv LWRPs but is extended by the existence of the
ruby_build cookbook.

Be sure to inspect the Berksfile (it refers to git versions of
Fletcher’s cookbooks, not sure if these are required), and also the
metadata and default recipe of ‘system_wide_rbenv’. [1]

Cheers,

–AJ

[0] https://github.com/fujin/system_wide_rbenv
[1]
https://github.com/fujin/system_wide_rbenv/blob/master/recipes/default.rb#L20-L23

On 25 February 2013 13:25, S Ahmed sahmed1020@gmail.com wrote:

Ok got a bit futher:

recipe/default.rb:

include_recipe "ruby_build"
include_recipe "rbenv::system"
include_recipe “rbenv::system_install”

ruby_build_ruby "1.9.3-p194"
rbenv_global “1.9.3-p194”

Error:

Generated at 2013-02-25 00:08:05 +0000
Mixlib::ShellOut::ShellCommandFailed: script[rbenv global 1.9.3-p194
(system)] (/home/ubuntu/chef/cookbooks/rbenv/providers/script.rb line

had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to
exit

with [0], but received ‘1’
---- Begin output of “bash” “/tmp/chef-script20130225-4608-xuqhko” ----
STDOUT:
STDERR: rbenv: version global' not installed rbenv: version1.9.3-p194’ not installed
---- End output of “bash” “/tmp/chef-script20130225-4608-xuqhko” ----
Ran “bash” “/tmp/chef-script20130225-4608-xuqhko” returned 1

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/mixlib-shellout-1.1.0/lib/mixlib/shellout.rb:248:in

`invalid!’

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/mixlib-shellout-1.1.0/lib/mixlib/shellout.rb:234:in

`error!’

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/mixin/shell_out.rb:36:in

`shell_out!’

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/provider/execute.rb:62:in

`block in action_run’

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/mixin/why_run.rb:52:in

`call’

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/mixin/why_run.rb:52:in

`add_action’

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/provider.rb:151:in

`converge_by’

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/provider/execute.rb:61:in

`action_run’

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/provider/script.rb:33:in

`action_run’

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/provider.rb:114:in

`run_action’

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/resource.rb:603:in

`run_action’

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/runner.rb:50:in

`run_action’

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/runner.rb:82:in

`block (2 levels) in converge’

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/runner.rb:82:in

`each’

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/runner.rb:82:in

`block in converge’

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/resource_collection.rb:94:in

`block in execute_each_resource’

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/resource_collection/stepable_iterator.rb:116:in

`call’

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/resource_collection/stepable_iterator.rb:116:in

`call_iterator_block’

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/resource_collection/stepable_iterator.rb:85:in

`step’

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/resource_collection/stepable_iterator.rb:104:in

`iterate’

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/resource_collection/stepable_iterator.rb:55:in

`each_with_index’

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/resource_collection.rb:92:in

`execute_each_resource’

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/runner.rb:81:in

`converge’

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/client.rb:404:in

`converge’

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/client.rb:469:in

`do_run’

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/client.rb:200:in

`run’

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/application.rb:190:in

`run_chef_client’

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/application/solo.rb:239:in

`block in run_application’

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/application/solo.rb:231:in

`loop’

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/application/solo.rb:231:in

`run_application’

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/application.rb:73:in

`run’

/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/bin/chef-solo:25:in

<top (required)>' /usr/bin/chef-solo:23:inload’

On Sun, Feb 24, 2013 at 5:21 PM, S Ahmed sahmed1020@gmail.com wrote:

Ok let me start over here, I was using another rbenv that is differrent
from fnichol’s cookbook.

In my cookbooks I have rbenv (fnichols) and ruby_build (also
fnichols), I

just downloaded the zip and put it in my /cookbooks (is that ok or do
I have

to build it?)

/cookbook/rbenv
/cookbook/ruby_build

  1. base.rb role:

run_list … “recipe[ruby_build]”, “recipe[my_ruby]”

  1. my_ruby

metadata.rb:

depends “rbenv”

recipes/default.rb:

include_recipe "rbenv::system"
include_recipe “rbenv::ruby_build”

rbenv_ruby “1.9.3” do
ruby_version "1.9.3-p194"
global true
end

rbenv_gem “bundler” do
ruby_version "1.9.3-p194"
end

rbenv_gem “rubygems” do
ruby_version "1.9.3-p194"
end

Now when I run it I get this error:

2013-02-24T22:16:51+00:00] FATAL: Chef::Exceptions::RecipeNotFound:
could

not find recipe ruby_build for cookbook rbenv

On Sun, Feb 24, 2013 at 3:48 PM, AJ Christensen aj@junglist.gen.nz
wrote:

You’ll want ‘recipe[rbenv::system_install]’ and any appropriate $PATH
modifications via /etc/profile.d – can be a file/contents; make use
of the LWRP ‘rbenv_global’ [0]

As I mentioned previously, a node attribute hash-map like this suits:

node.default[‘my_org_rbenv’][‘system_rubygems’][‘1.9.3-p194’] = {
bundler: {
version: ‘1.2.3’,
action: ‘install’,
}
}

system_ruby_version = node[‘my_org_rbenv’][‘system_ruby_version’]

rbenv_global system_ruby_version

node[‘my_org_rbenv’][‘system_rubygems’][system_ruby_version].each do
|gem, params|
rbenv_gem gem do
rbenv_version systemruby
version params[‘version’]
action params[‘action’].to_sym
end
end

Note that this only reduces repetition and is not required at all.

Cheers,

AJ

[0] rbenv LWRPs: https://github.com/fnichol/chef-rbenv#lwrps

On 25 February 2013 07:10, S Ahmed sahmed1020@gmail.com wrote:

thanks, looks like I got most of it.

  1. How do I set it as global (system wide, not user specific?):
    default.rb:

include_recipe "rbenv::default"
include_recipe “rbenv::ruby_build”

rbenv_ruby “1.9.3-p194”

After my chef-solo ran, I get this when doing: ruby

rbenv: ruby: command not found

The `ruby’ command exists in these Ruby versions:
1.9.3-p194

  1. if I want to install more gems, I have to keep repeating this or
    like you
    said put it in a each loop right?

rbenv_gem “bundler” do
ruby_version "1.9.3-p194"
end

rbenv_gem “rubygems” do
ruby_version "1.9.3-p194"
end


On Mon, Feb 18, 2013 at 4:17 PM, AJ Christensen <aj@junglist.gen.nz

wrote:

Oh, as for gems: toss 'em in an attribute, map the attribute into
gem_package resources after rbenv is installed and activated so
that

gem_package goes to the correct VM.

Cheers,

AJ

On 19 February 2013 10:14, AJ Christensen aj@junglist.gen.nz
wrote:

Create a cookbook “myorg_system_wide_ruby” and add the rbenv
’related
code’ you mentioned in there.

depends goes into metadata.rb, the rest in a recipe

Cheers,

AJ

On 19 February 2013 10:11, S Ahmed sahmed1020@gmail.com wrote:

Thanks to your suggestions, I am going to use rbenv to manage my
servers
system wide ruby and gems setup.

From the readme it seems to alude to using rbenv as dependancy
to a

cookbook, but I want to setup a system wide (default) ruby and
rubygems.

Does this mean I have to put this in my role_name.rb file? (I’m
using
chef-solo).

My current base.rb is:

name 'base’
description 'base role that all nodes will have’
run_list “recipe[build-essential]”, “recipe[ohai]”,
“recipe[runit]”,
“recipe[yum]”, “recipe[openssl]”, “recipe[git]”, “recipe[apt]”,
“recipe[java]”

So do I put rbenv related code in here like:

depends 'rbenv'

include_recipe "rbenv::default"
include_recipe "rbenv::ruby_build"

rbenv_ruby "1.9.3-p194"

rbenv_gem "bundler" do
  ruby_version "1.9.3-p194"
end

How can I create a list of gems I want pre-installed for default
ruby
to be
able to access?