Chef-client runs only locally as root


#1

Hi,

I am trying to execute chef-client remotely but I run into this exception:

/usr/local/lib/ruby/gems/1.8/gems/ohai-0.5.0/lib/ohai/system.rb:121:in join': can't convert nil into String (TypeError) from /usr/local/lib/ruby/gems/1.8/gems/ohai-0.5.0/lib/ohai/system.rb:121:inall_plugins’
from /usr/local/lib/ruby/gems/1.8/gems/ohai-0.5.0/lib/ohai/system.rb:118:in each' from /usr/local/lib/ruby/gems/1.8/gems/ohai-0.5.0/lib/ohai/system.rb:118:inall_plugins’
from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/…/lib/chef/client.rb:121:in run_ohai' from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/../lib/chef/client.rb:126:indetermine_node_name’
from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/…/lib/chef/client.rb:83:in run' from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/../lib/chef/application/client.rb:204:inrun_application’
from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/…/lib/chef/application/client.rb:196:in loop' from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/../lib/chef/application/client.rb:196:inrun_application’
from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/…/lib/chef/application.rb:57:in run' from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/chef-client:26 from /usr/local/bin/chef-client:19:inload’
from /usr/local/bin/chef-client:19

Here is the debug log

[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Loading plugin kernel
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -s STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Linux
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -s STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -s STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG:
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -s STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Ran (uname -s) returned 0
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -r STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: 2.6.32.1-rscloud
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -r STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -r STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG:
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -r STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Ran (uname -r) returned 0
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -v STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: #15 SMP Mon Feb 22 13:22:15 UTC 2010
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -v STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -v STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG:
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -v STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Ran (uname -v) returned 0
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -m STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: x86_64
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -m STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -m STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG:
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -m STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Ran (uname -m) returned 0

I am having the same exception when:

  • I invoke sudo chef-client from a non-root user (this is the same use case as trying remotely with ssh ‘sudo chef-client’
  • the chef-client deamon runs every 30 minutes -> the deamon runs as root:root: (root 1218 0.0 0.9 92588 19360 ? S Mar10 0:00 /usr/local/bin/ruby /usr/bin/chef-client -d -c /etc/chef/client.rb -i 1800 -s 20 -L /var/log/chef/client.log)

only running chef-client as root locally works.

I have the same $PATH in both cases:

  • running as root
  • running as sudo (I have included /sbin, /usr/sbin, /usr/local/sbin)

Any help appreciated at this point

Thanks

–Gilles


#2

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello!

That error looks like one I ran into where ‘ruby’ wasn’t in the $PATH,
though ‘ruby1.8’ was. Are you on a system like Debian that has
separate ruby1.8 and ruby packages, and ‘ruby’ isn’t installed?

On Mar 11, 2010, at 11:18 AM, Gilles Devaux wrote:

Hi,

I am trying to execute chef-client remotely but I run into this
exception:

/usr/local/lib/ruby/gems/1.8/gems/ohai-0.5.0/lib/ohai/system.rb:
121:in join': can't convert nil into String (TypeError) from /usr/local/lib/ruby/gems/1.8/gems/ohai-0.5.0/lib/ohai/ system.rb:121:inall_plugins’
from /usr/local/lib/ruby/gems/1.8/gems/ohai-0.5.0/lib/ohai/
system.rb:118:in each' from /usr/local/lib/ruby/gems/1.8/gems/ohai-0.5.0/lib/ohai/ system.rb:118:inall_plugins’
from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/…/lib/
chef/client.rb:121:in run_ohai' from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/../lib/ chef/client.rb:126:indetermine_node_name’
from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/…/lib/
chef/client.rb:83:in run' from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/../lib/ chef/application/client.rb:204:inrun_application’
from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/…/lib/
chef/application/client.rb:196:in loop' from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/../lib/ chef/application/client.rb:196:inrun_application’
from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/…/lib/
chef/application.rb:57:in run' from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/chef- client:26 from /usr/local/bin/chef-client:19:inload’
from /usr/local/bin/chef-client:19

Here is the debug log

[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Loading plugin kernel
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -s STDOUT

[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Linux
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -s STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -s STDERR

[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG:
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -s STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Ran (uname -s) returned 0
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -r STDOUT

[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: 2.6.32.1-rscloud
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -r STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -r STDERR

[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG:
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -r STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Ran (uname -r) returned 0
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -v STDOUT

[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: #15 SMP Mon Feb 22 13:22:15
UTC 2010
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -v STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -v STDERR

[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG:
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -v STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Ran (uname -v) returned 0
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -m STDOUT

[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: x86_64
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -m STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -m STDERR

[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG:
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -m STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Ran (uname -m) returned 0

I am having the same exception when:

  • I invoke sudo chef-client from a non-root user (this is the same
    use case as trying remotely with ssh ‘sudo chef-client’
  • the chef-client deamon runs every 30 minutes -> the deamon runs as
    root:root: (root 1218 0.0 0.9 92588 19360 ? S
    Mar10 0:00 /usr/local/bin/ruby /usr/bin/chef-client -d -c /etc/
    chef/client.rb -i 1800 -s 20 -L /var/log/chef/client.log)

only running chef-client as root locally works.

I have the same $PATH in both cases:

  • running as root
  • running as sudo (I have included /sbin, /usr/sbin, /usr/local/sbin)

Any help appreciated at this point

Thanks

–Gilles


Opscode, Inc
Joshua Timberman, Senior Solutions Engineer
C: 720.334.RUBY E: joshua@opscode.com

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (Darwin)

iEUEARECAAYFAkuZPXMACgkQO97WSdVpzT0QkQCYwHgvaYZQt9JEu1sJceNSSeTU
BgCfQguUm3WMF3HnV0Au07pFSr3TYo0=
=lZiw
-----END PGP SIGNATURE-----


#3

Hi Joshua,

I have more info, this is only happening on the machines where ruby-entreprise is installed.
On these machines ruby is compiled from sources (default install path), gem is compiled from source (default install path). Chef is installed from gem, ruby-entreprise is installed through chef in /opt/ruby-entreprise.

[gilles@selma ~] which ruby /usr/local/bin/ruby [gilles@selma ~] /usr/local/bin/ruby -v
ruby 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux]

ruby-entreprise is not in the path.

Thanks

–Gilles

ps: I still do not have time to work on merging the changes I made on the cookbooks to be more centos friendly but I will.

On Mar 11, 2010, at 10:58 AM, Joshua Timberman wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello!

That error looks like one I ran into where ‘ruby’ wasn’t in the $PATH, though ‘ruby1.8’ was. Are you on a system like Debian that has separate ruby1.8 and ruby packages, and ‘ruby’ isn’t installed?

On Mar 11, 2010, at 11:18 AM, Gilles Devaux wrote:

Hi,

I am trying to execute chef-client remotely but I run into this exception:

/usr/local/lib/ruby/gems/1.8/gems/ohai-0.5.0/lib/ohai/system.rb:121:in join': can't convert nil into String (TypeError) from /usr/local/lib/ruby/gems/1.8/gems/ohai-0.5.0/lib/ohai/system.rb:121:inall_plugins’
from /usr/local/lib/ruby/gems/1.8/gems/ohai-0.5.0/lib/ohai/system.rb:118:in each' from /usr/local/lib/ruby/gems/1.8/gems/ohai-0.5.0/lib/ohai/system.rb:118:inall_plugins’
from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/…/lib/chef/client.rb:121:in run_ohai' from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/../lib/chef/client.rb:126:indetermine_node_name’
from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/…/lib/chef/client.rb:83:in run' from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/../lib/chef/application/client.rb:204:inrun_application’
from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/…/lib/chef/application/client.rb:196:in loop' from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/../lib/chef/application/client.rb:196:inrun_application’
from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/…/lib/chef/application.rb:57:in run' from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/chef-client:26 from /usr/local/bin/chef-client:19:inload’
from /usr/local/bin/chef-client:19

Here is the debug log

[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Loading plugin kernel
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -s STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Linux
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -s STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -s STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG:
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -s STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Ran (uname -s) returned 0
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -r STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: 2.6.32.1-rscloud
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -r STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -r STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG:
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -r STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Ran (uname -r) returned 0
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -v STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: #15 SMP Mon Feb 22 13:22:15 UTC 2010
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -v STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -v STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG:
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -v STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Ran (uname -v) returned 0
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -m STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: x86_64
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -m STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -m STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG:
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -m STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Ran (uname -m) returned 0

I am having the same exception when:

  • I invoke sudo chef-client from a non-root user (this is the same use case as trying remotely with ssh ‘sudo chef-client’
  • the chef-client deamon runs every 30 minutes -> the deamon runs as root:root: (root 1218 0.0 0.9 92588 19360 ? S Mar10 0:00 /usr/local/bin/ruby /usr/bin/chef-client -d -c /etc/chef/client.rb -i 1800 -s 20 -L /var/log/chef/client.log)

only running chef-client as root locally works.

I have the same $PATH in both cases:

  • running as root
  • running as sudo (I have included /sbin, /usr/sbin, /usr/local/sbin)

Any help appreciated at this point

Thanks

–Gilles


Opscode, Inc
Joshua Timberman, Senior Solutions Engineer
C: 720.334.RUBY E: joshua@opscode.com

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (Darwin)

iEUEARECAAYFAkuZPXMACgkQO97WSdVpzT0QkQCYwHgvaYZQt9JEu1sJceNSSeTU
BgCfQguUm3WMF3HnV0Au07pFSr3TYo0=
=lZiw
-----END PGP SIGNATURE-----


#4

More on this:

I added these:
ohai-0.5.0/lib/ohai/plugins/ruby.rb:25 (inside run_ruby)
Ohai::Log.info(“path: #{ENV[‘PATH’]}”);
status, stdout, stderr = run_command(:command => ‘which ruby’);

[Thu, 11 Mar 2010 22:35:32 +0000] DEBUG: Loading plugin languages
[Thu, 11 Mar 2010 22:35:32 +0000] INFO: path: /usr/bin:/bin
[Thu, 11 Mar 2010 22:35:32 +0000] DEBUG: ---- Begin which ruby STDOUT ----
[Thu, 11 Mar 2010 22:35:32 +0000] DEBUG:
[Thu, 11 Mar 2010 22:35:32 +0000] DEBUG: ---- End which ruby STDOUT ----
[Thu, 11 Mar 2010 22:35:32 +0000] DEBUG: ---- Begin which ruby STDERR ----
[Thu, 11 Mar 2010 22:35:32 +0000] DEBUG: which: no ruby in (/usr/bin:/bin)

It seems ohai (or chef) runs inside a limited /usr/bin/env. Is there a way to add path at runtime?

I have a workaround using symlinks but it’s not ideal.

Thanks

–Gilles

On Mar 11, 2010, at 10:58 AM, Joshua Timberman wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello!

That error looks like one I ran into where ‘ruby’ wasn’t in the $PATH, though ‘ruby1.8’ was. Are you on a system like Debian that has separate ruby1.8 and ruby packages, and ‘ruby’ isn’t installed?

On Mar 11, 2010, at 11:18 AM, Gilles Devaux wrote:

Hi,

I am trying to execute chef-client remotely but I run into this exception:

/usr/local/lib/ruby/gems/1.8/gems/ohai-0.5.0/lib/ohai/system.rb:121:in join': can't convert nil into String (TypeError) from /usr/local/lib/ruby/gems/1.8/gems/ohai-0.5.0/lib/ohai/system.rb:121:inall_plugins’
from /usr/local/lib/ruby/gems/1.8/gems/ohai-0.5.0/lib/ohai/system.rb:118:in each' from /usr/local/lib/ruby/gems/1.8/gems/ohai-0.5.0/lib/ohai/system.rb:118:inall_plugins’
from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/…/lib/chef/client.rb:121:in run_ohai' from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/../lib/chef/client.rb:126:indetermine_node_name’
from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/…/lib/chef/client.rb:83:in run' from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/../lib/chef/application/client.rb:204:inrun_application’
from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/…/lib/chef/application/client.rb:196:in loop' from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/../lib/chef/application/client.rb:196:inrun_application’
from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/…/lib/chef/application.rb:57:in run' from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/chef-client:26 from /usr/local/bin/chef-client:19:inload’
from /usr/local/bin/chef-client:19

Here is the debug log

[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Loading plugin kernel
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -s STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Linux
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -s STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -s STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG:
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -s STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Ran (uname -s) returned 0
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -r STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: 2.6.32.1-rscloud
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -r STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -r STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG:
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -r STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Ran (uname -r) returned 0
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -v STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: #15 SMP Mon Feb 22 13:22:15 UTC 2010
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -v STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -v STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG:
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -v STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Ran (uname -v) returned 0
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -m STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: x86_64
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -m STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -m STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG:
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -m STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Ran (uname -m) returned 0

I am having the same exception when:

  • I invoke sudo chef-client from a non-root user (this is the same use case as trying remotely with ssh ‘sudo chef-client’
  • the chef-client deamon runs every 30 minutes -> the deamon runs as root:root: (root 1218 0.0 0.9 92588 19360 ? S Mar10 0:00 /usr/local/bin/ruby /usr/bin/chef-client -d -c /etc/chef/client.rb -i 1800 -s 20 -L /var/log/chef/client.log)

only running chef-client as root locally works.

I have the same $PATH in both cases:

  • running as root
  • running as sudo (I have included /sbin, /usr/sbin, /usr/local/sbin)

Any help appreciated at this point

Thanks

–Gilles


Opscode, Inc
Joshua Timberman, Senior Solutions Engineer
C: 720.334.RUBY E: joshua@opscode.com

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (Darwin)

iEUEARECAAYFAkuZPXMACgkQO97WSdVpzT0QkQCYwHgvaYZQt9JEu1sJceNSSeTU
BgCfQguUm3WMF3HnV0Au07pFSr3TYo0=
=lZiw
-----END PGP SIGNATURE-----


#5

Hi there!
Have you tried using sudo -E or your distro’s method for setting
default PATHs (/etc/profile IIRC)? Also, ssh itself may set the PATH
as described in the environment section of its man page[1].

As you’ve discovered, we use a shebang line like:
#!/usr/bin/env ruby
This is because the shebang line must specify the absolute path to the
executable, but we can’t rely on ruby to be at the same path on all
systems.

  1. http://man.cx/ssh#sec10

HTH,
Dan DeLeo

On Thu, Mar 11, 2010 at 2:43 PM, Gilles Devaux gilles.devaux@gmail.com wrote:

More on this:

I added these:
ohai-0.5.0/lib/ohai/plugins/ruby.rb:25 (inside run_ruby)
Ohai::Log.info(“path: #{ENV[‘PATH’]}”);
status, stdout, stderr = run_command(:command => ‘which ruby’);

[Thu, 11 Mar 2010 22:35:32 +0000] DEBUG: Loading plugin languages
[Thu, 11 Mar 2010 22:35:32 +0000] INFO: path: /usr/bin:/bin
[Thu, 11 Mar 2010 22:35:32 +0000] DEBUG: ---- Begin which ruby STDOUT ----
[Thu, 11 Mar 2010 22:35:32 +0000] DEBUG:
[Thu, 11 Mar 2010 22:35:32 +0000] DEBUG: ---- End which ruby STDOUT ----
[Thu, 11 Mar 2010 22:35:32 +0000] DEBUG: ---- Begin which ruby STDERR ----
[Thu, 11 Mar 2010 22:35:32 +0000] DEBUG: which: no ruby in (/usr/bin:/bin)

It seems ohai (or chef) runs inside a limited /usr/bin/env. Is there a way to add path at runtime?

I have a workaround using symlinks but it’s not ideal.

Thanks

–Gilles

On Mar 11, 2010, at 10:58 AM, Joshua Timberman wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello!

That error looks like one I ran into where ‘ruby’ wasn’t in the $PATH, though ‘ruby1.8’ was. Are you on a system like Debian that has separate ruby1.8 and ruby packages, and ‘ruby’ isn’t installed?

On Mar 11, 2010, at 11:18 AM, Gilles Devaux wrote:

Hi,

I am trying to execute chef-client remotely but I run into this exception:

/usr/local/lib/ruby/gems/1.8/gems/ohai-0.5.0/lib/ohai/system.rb:121:in join': can't convert nil into String (TypeError) from /usr/local/lib/ruby/gems/1.8/gems/ohai-0.5.0/lib/ohai/system.rb:121:inall_plugins’
from /usr/local/lib/ruby/gems/1.8/gems/ohai-0.5.0/lib/ohai/system.rb:118:in each' from /usr/local/lib/ruby/gems/1.8/gems/ohai-0.5.0/lib/ohai/system.rb:118:inall_plugins’
from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/…/lib/chef/client.rb:121:in run_ohai' from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/../lib/chef/client.rb:126:indetermine_node_name’
from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/…/lib/chef/client.rb:83:in run' from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/../lib/chef/application/client.rb:204:inrun_application’
from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/…/lib/chef/application/client.rb:196:in loop' from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/../lib/chef/application/client.rb:196:inrun_application’
from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/…/lib/chef/application.rb:57:in run' from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/chef-client:26 from /usr/local/bin/chef-client:19:inload’
from /usr/local/bin/chef-client:19

Here is the debug log

[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Loading plugin kernel
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -s STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Linux
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -s STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -s STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG:
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -s STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Ran (uname -s) returned 0
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -r STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: 2.6.32.1-rscloud
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -r STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -r STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG:
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -r STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Ran (uname -r) returned 0
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -v STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: #15 SMP Mon Feb 22 13:22:15 UTC 2010
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -v STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -v STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG:
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -v STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Ran (uname -v) returned 0
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -m STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: x86_64
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -m STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -m STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG:
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -m STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Ran (uname -m) returned 0

I am having the same exception when:

  • I invoke sudo chef-client from a non-root user (this is the same use case as trying remotely with ssh ‘sudo chef-client’
  • the chef-client deamon runs every 30 minutes -> the deamon runs as root:root: (root 1218 0.0 0.9 92588 19360 ? S Mar10 0:00 /usr/local/bin/ruby /usr/bin/chef-client -d -c /etc/chef/client.rb -i 1800 -s 20 -L /var/log/chef/client.log)

only running chef-client as root locally works.

I have the same $PATH in both cases:

  • running as root
  • running as sudo (I have included /sbin, /usr/sbin, /usr/local/sbin)

Any help appreciated at this point

Thanks

–Gilles


Opscode, Inc
Joshua Timberman, Senior Solutions Engineer
C: 720.334.RUBY E: joshua@opscode.com

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (Darwin)

iEUEARECAAYFAkuZPXMACgkQO97WSdVpzT0QkQCYwHgvaYZQt9JEu1sJceNSSeTU
BgCfQguUm3WMF3HnV0Au07pFSr3TYo0=
=lZiw
-----END PGP SIGNATURE-----


#6

Or try ‘sudo -i chef-client’

Regards,
John

On Sat, Mar 13, 2010 at 9:38 PM, Daniel DeLeo dan@kallistec.com wrote:

Hi there!
Have you tried using sudo -E or your distro’s method for setting
default PATHs (/etc/profile IIRC)? Also, ssh itself may set the PATH
as described in the environment section of its man page[1].

As you’ve discovered, we use a shebang line like:
#!/usr/bin/env ruby
This is because the shebang line must specify the absolute path to the
executable, but we can’t rely on ruby to be at the same path on all
systems.

  1. http://man.cx/ssh#sec10

HTH,
Dan DeLeo

On Thu, Mar 11, 2010 at 2:43 PM, Gilles Devaux gilles.devaux@gmail.com wrote:

More on this:

I added these:
ohai-0.5.0/lib/ohai/plugins/ruby.rb:25 (inside run_ruby)
Ohai::Log.info(“path: #{ENV[‘PATH’]}”);
status, stdout, stderr = run_command(:command => ‘which ruby’);

[Thu, 11 Mar 2010 22:35:32 +0000] DEBUG: Loading plugin languages
[Thu, 11 Mar 2010 22:35:32 +0000] INFO: path: /usr/bin:/bin
[Thu, 11 Mar 2010 22:35:32 +0000] DEBUG: ---- Begin which ruby STDOUT ----
[Thu, 11 Mar 2010 22:35:32 +0000] DEBUG:
[Thu, 11 Mar 2010 22:35:32 +0000] DEBUG: ---- End which ruby STDOUT ----
[Thu, 11 Mar 2010 22:35:32 +0000] DEBUG: ---- Begin which ruby STDERR ----
[Thu, 11 Mar 2010 22:35:32 +0000] DEBUG: which: no ruby in (/usr/bin:/bin)

It seems ohai (or chef) runs inside a limited /usr/bin/env. Is there a way to add path at runtime?

I have a workaround using symlinks but it’s not ideal.

Thanks

–Gilles

On Mar 11, 2010, at 10:58 AM, Joshua Timberman wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello!

That error looks like one I ran into where ‘ruby’ wasn’t in the $PATH, though ‘ruby1.8’ was. Are you on a system like Debian that has separate ruby1.8 and ruby packages, and ‘ruby’ isn’t installed?

On Mar 11, 2010, at 11:18 AM, Gilles Devaux wrote:

Hi,

I am trying to execute chef-client remotely but I run into this exception:

/usr/local/lib/ruby/gems/1.8/gems/ohai-0.5.0/lib/ohai/system.rb:121:in join': can't convert nil into String (TypeError) from /usr/local/lib/ruby/gems/1.8/gems/ohai-0.5.0/lib/ohai/system.rb:121:inall_plugins’
from /usr/local/lib/ruby/gems/1.8/gems/ohai-0.5.0/lib/ohai/system.rb:118:in each' from /usr/local/lib/ruby/gems/1.8/gems/ohai-0.5.0/lib/ohai/system.rb:118:inall_plugins’
from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/…/lib/chef/client.rb:121:in run_ohai' from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/../lib/chef/client.rb:126:indetermine_node_name’
from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/…/lib/chef/client.rb:83:in run' from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/../lib/chef/application/client.rb:204:inrun_application’
from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/…/lib/chef/application/client.rb:196:in loop' from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/../lib/chef/application/client.rb:196:inrun_application’
from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/…/lib/chef/application.rb:57:in run' from /usr/local/lib/ruby/gems/1.8/gems/chef-0.8.6/bin/chef-client:26 from /usr/local/bin/chef-client:19:inload’
from /usr/local/bin/chef-client:19

Here is the debug log

[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Loading plugin kernel
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -s STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Linux
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -s STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -s STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG:
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -s STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Ran (uname -s) returned 0
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -r STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: 2.6.32.1-rscloud
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -r STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -r STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG:
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -r STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Ran (uname -r) returned 0
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -v STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: #15 SMP Mon Feb 22 13:22:15 UTC 2010
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -v STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -v STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG:
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -v STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Ran (uname -v) returned 0
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -m STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: x86_64
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -m STDOUT ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- Begin uname -m STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG:
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: ---- End uname -m STDERR ----
[Thu, 11 Mar 2010 18:09:45 +0000] DEBUG: Ran (uname -m) returned 0

I am having the same exception when:

  • I invoke sudo chef-client from a non-root user (this is the same use case as trying remotely with ssh ‘sudo chef-client’
  • the chef-client deamon runs every 30 minutes -> the deamon runs as root:root: (root 1218 0.0 0.9 92588 19360 ? S Mar10 0:00 /usr/local/bin/ruby /usr/bin/chef-client -d -c /etc/chef/client.rb -i 1800 -s 20 -L /var/log/chef/client.log)

only running chef-client as root locally works.

I have the same $PATH in both cases:

  • running as root
  • running as sudo (I have included /sbin, /usr/sbin, /usr/local/sbin)

Any help appreciated at this point

Thanks

–Gilles


Opscode, Inc
Joshua Timberman, Senior Solutions Engineer
C: 720.334.RUBY E: joshua@opscode.com

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (Darwin)

iEUEARECAAYFAkuZPXMACgkQO97WSdVpzT0QkQCYwHgvaYZQt9JEu1sJceNSSeTU
BgCfQguUm3WMF3HnV0Au07pFSr3TYo0=
=lZiw
-----END PGP SIGNATURE-----


John Alberts