2
votes

I'm trying to run 'sudo chef-client' on all nodes. To do that, I'm trying to run command:

sudo knife ssh name:* 'sudo chef-client'

but get errors with connection to machine

WARNING: Failed to connect to -- Net::SSH::AuthenticationFailed: *chef_workstation_user_name*@*node_name*

The nodes are real machines in local network. I've registered nodes by running

sudo knife bootstrap node_ip_address -x node_name -P node_pass --sudo

When I'm running

sudo knife ssh name:node_name -x node_user -P node_pass 'sudo chef-client'

it still asks local machine's (node) password and then runs chef-client with superuser permissions.

So the question is how to run 'sudo chef-client' on all nodes in my situation?

P.S. All nodes have different superuser name

4

4 Answers

0
votes

Try

sudo knife ssh 'name:*' 'sudo chef-client' instead of

sudo knife ssh name:* 'sudo chef-client'

0
votes

Specify the user you want connect to the instance as with -x. for example.

sudo knife ssh 'name:*' 'sudo chef-client' -x ubuntu
0
votes

I have the same superuser and tried the below which is working fine. Give username and password as an argument along with knife ssh i.e.

knife ssh -x username -P password 'name:' 'sudo chef-client'*

knife ssh -x root -P qwerty 'name:*' 'sudo chef-client'
0
votes

The command worked as expected after adding the fully qualified name (or node name) into the hosts file of the system from which you are running the command according to what is registered on the chef-server. (/etc/hosts on linux and *nix systems. A DNS could/should also work, haven't tested with DNS).

That is, the chef-workstation hosts file should contain the IP address and fully qualified names of all the nodes as registered on the chef-server and be able to ping those addresses. After some looking around, it turns out that the "knife ssh" command will reach to the server to query all the nodes -> receive the list of addresses as FQDNs, and THEN -> perform the command on the addresses received as FQDN (not ip-addresses). The work-station should be able to resolve those FQDNs.

sudo knife ssh '*:*' "sudo chef-client"

It will ask you for the sudo password for each node one after the other, but will run parallel.