简体   繁体   中英

Can't run chef-solo command through ssh

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 ?

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM