Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is the way recommended in the Chef Fast Start tutorial:

knife ssh name:mynode -a ipaddress  -x ubuntu -i mycredentials.pem "sudo chef-client"

This is really clumsy. Is there really not a better way, or is the idea that in a real production environment, you'll have nodes auto-updating anyway?

share|improve this question
In what way do you think this is "clumsy"? – womble Jul 23 '12 at 11:04
Well, put it this way. This wouldn't be clumsy: "knife update name:mynode". Having to spell out both how to connect to the client, and the name of the chef client command (plus the fact it needs to be run with sudo permissions) is clumsy. Knife does well at abstracting away lots of other mess - why not this? – Steve Bennett Jul 24 '12 at 8:05
up vote 10 down vote accepted

That'd pretty much how you get thing started to begin with, but it only needs to be done once. The initial run of chef-client typically enables and starts the chef-client daemon as an init.d service.

If you really wanted to do it more elegantly, you can ditch knife-ssh and run ssh directly:

ssh ubuntu@ipadddress -i mycredentials.pem sudo chef-client

that will probably be faster as knife-ssh does a search against the Chef server to fetch nodes matching the search term (in this case name:dynode) which you don't strictly need to do if you already know the IP address.

share|improve this answer
Ok, I guess that answers the question - no, there isn't a better way. Pity that "knife bootstrap" can't also actually run chef-client. – Steve Bennett Jul 24 '12 at 8:07
I usually run chef-client at the end of my bootstrap script to solve that particular problem. However if you dislike knife-ssh then you will probably think the knife-bootstrap internals are equally ungainly. There's an example script on github. – Tim Potter Jul 24 '12 at 11:45
The ec2 server create knife plugin just runs bootstrap followed by SSH + chef-client. So if it makes you feel any better, the Chef authors haven't figured out anything particularly smarter. – kgilpin Sep 17 '12 at 23:58
If chef-client takes some time to run you get a timeout. :( ssh: connect to host xx.xx.xx.xx port 22: Connection timed out – gdanko May 14 '15 at 18:17

You could use knife ssh to run chef-client on all boxes that contain a certain role or recipe:

knife ssh "role:web" "sudo chef-client" -x ubuntu --sudo 

Or if you're in EC2:

knife ssh "role:web" "sudo chef-client" -x ubuntu -a ec2.public_hostname 
share|improve this answer

I use Jenkins CI to manage the runs. Linux server is setup as a workstation and has Jenkins installed on it. So I can bootstrap the nodes with modified run_list. Bootstrapping process anyway runs chef-client at the end.

For the adhoc execution, Jenkins job executes knife commands to modify run_list for a node and use SSH plugin to execute chef-client on desired node.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.