Pergunta

In the case when I first ssh to the server and then run command, it executes successfully

root@chef:~# chef-solo -v
Chef: 11.10.0

But when I try to run it like this

 ssh root@188.xxx.xxx.xxx -t -C "chef-solo -c /var/chef/solo.rb"

I receive an error:

bash: chef-solo: command not found

Why is this happening, and how can I solve this issue ?

Foi útil?

Solução

It is still matter of $PATH and ssh - not chef-solo. Interactive and non-interactive sessions not necessarily have same value for the $PATH variable. Same ssh problem is described here on stackoverflow. You may also check GNU bash manual to have deeper insight of (non-)interactive and (non-)login shells. To shorten, solution would be one of the following:

  1. Run chef-solo using absolute path. Here's how your command might look like:
    • ssh root@188.xxx.xxx.xxx -t -C "/usr/local/ruby/bin/chef-solo -c /var/chef/solo.rb"
  2. Tune the .bash configuration files to load same $PATH variable for both interactive and non-interactive shells.

Note: To find out what's the absolute path, login to the machine via ssh and run which chef-solo (Don't know how experienced you are with linux. Sorry if I'm underestimating your knowledge)

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top