Search code examples
chef-infraknife

"sudo: chef-client: command not found" when executed with knife from workstation


I have an issue with running chef-client on my nodes when I trigger chef-client using knife on my workstation. I am on macOS and my nodes are also macOS. In general, knife seems working for me because if I execute, for example, knife ssh tags:my-mac-mini' 'pwd' -x ‘myUser’ -a ipaddress -P ‘myPasswrod’ it connects to the nodes tagged with my-mac-mini and then prints list of nodes with working directories. But when I try to execute knife ssh tags:my-mac-mini' 'sudo chef-client' -x ‘myUser’ -a ipaddress -P ‘myPasswrod’, it prints out sudo: chef-client: command not found for each node respectively. And moreover, my nodes are bootstrapped and I can run chef-client on all nodes when I am logged in to particular node. I am quite sure I am missing something in my setup but I don't really get what can be wrong. Any idea?


Solution

  • This can happen if the shell in which you are running your command, does not have the specified binary in its path. You might have to specify the complete path to your binary.

    Since you say that you can ssh into your node and run chef-client, run the below to grab the full path of the binary

    $ which chef-client
    

    The output of this would something like this

    /path/to/chef-client
    

    Now, use this full path instead of chef-client alone when running via knife