Handy tcsh aliases for use with chef knife shell

Here are some handy tcsh aliases for the knife shell utility of the opscode chef infrastructure automation solution:

alias knifeshell knife ssh "\!:1" interactive -a hostname -x YourUserName

This will connect to all servers matching a search query so:

knifeshell "hostname:a*" will connect to all servers with a hostname starting with the letter “a” knifescreen knife ssh "\!:1" screen -a hostname -x -x YourUserName

This will do more or less the same as the previous command but it will use the gnu screen utility

and finaly:

alias kniferun knife ssh "\!:1" "\!:2" -a hostname -x YourUserName

will run a shell command on all servers matching the search query.

example:

to show the directory listing of your home folders for all servers known by chef:

kniferun "hostname:[* TO *]" ls

for more information about the search syntax or the knife utility check the opscode wiki

Posted by Administrator on Wednesday, April 06, 2011

digg delicious technorati blinklist furl reddit