Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
4  
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
add comment

2 Answers

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
1  
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
1  
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
add comment

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
add comment

Your Answer

 
discard

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.