3

I'm trying to figure out one thing and would like someone's else view on this. I installed chef on my Ubuntu server (11.10) via the awesome omnibus install. It worked perfectly fine. I was able to run chef-client and it ran without any problems.

Then I installed RVM and two rubies - and that's when my problems started. Straight after I installed RVM system wide ie by running:

curl -L https://get.rvm.io | sudo bash -s stable

And installed 2 rubies (setting one of the rubies as default ruby on the system) I couldn't run chef-client any more - I was getting "command not found" when run as normal regular user - I was thinking RVM messes some PATHS so that was the reason. I thought I'd run it as root ie:

sudo su -
chef-client

same result. Then I tried rvmsudo as it's being suggested by some people but that didn't help either. Then I gave it a last shot - I ran it as

sudo chef-client

And that's worked fine! I'm really puzzled as why is the above working and why is running chef -client as root (ie sudo su -; chef-client) NOT working. Am I missing something ? I'd really appreciate all the hints or explanations as I'm a bit lost. I'd like to run chef-client as a daemon as root and I can't do that with the sudo command above - I know I could set a user with nopasswd and it would probably work but I'd really like to understand what's going on here ;)

mgorven
  • 30,615
  • 7
  • 79
  • 122
milosgajdos
  • 1,828
  • 2
  • 21
  • 30
  • look at /etc/profile* for lines relatives to ruby/rvm and type "sudo env" and "sudo su - (new shell) env". Unfortunately i don't know chef –  Aug 27 '12 at 17:46

1 Answers1

0

Looks like you're having a path loading issue.

The omnibus installer installs Chef into /opt/chef/bin/chef-client and then symlinks to /usr/bin/chef-client ref1 so that it's available to all users in $PATH.

The moment you install rvm it's going to mess with with $PATH, specifically, which ruby is to be used by Chef, since it's loading the currently-running env's ruby when executing.

When running with sudo su -, you're changing to root's environment, and running all of the associated profile/bashrc/bash_profile loaders that set up a user's environment.

When running with sudo, you're not loading the entire environment, so RVM won't be changing paths.

Another test you could to to see the impact of the shell differences is to run:

sudo which ruby
sudo su - which ruby

And compare the differences.

You might want to look at the chef-client cookbook, which once executed, will help you set up a service daemon to control/config your chef-client service (we use this on all of our servers).

Since rvm is installed as default system-wide, then you may have to disable it for root (or the user you want to run Chef as, but I'd suggest root).

Mike Fiedler
  • 2,162
  • 1
  • 17
  • 34