- From: Daniel DeLeo <
>
- To:
- Subject: [chef] Re: Re: Re: chef-client runs only locally as root
- Date: Sat, 13 Mar 2010 18:38:51 -0800
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
<
>
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:in
>
>> `all_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:in
>
>> `all_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:in
>
>> `determine_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:in
>
>> `run_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:in
>
>> `run_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:in `load'
>
>> 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:
>
>
>
>
>
> -----BEGIN PGP SIGNATURE-----
>
> Version: GnuPG v1.4.10 (Darwin)
>
>
>
> iEUEARECAAYFAkuZPXMACgkQO97WSdVpzT0QkQCYwHgvaYZQt9JEu1sJceNSSeTU
>
> BgCfQguUm3WMF3HnV0Au07pFSr3TYo0=
>
> =lZiw
>
> -----END PGP SIGNATURE-----
>
>
Archive powered by MHonArc 2.6.16.