Skip to content
a-tal edited this page Sep 13, 2012 · 4 revisions

Hey look, a wiki! I suppose maybe an example or two on how to use this...

Say you had a list of 1, 10, maybe 9001 boxes that are all more/less the same... that is, they have the same prompts when you log in. This all runs with expect, so keep that in mind. But, say you wanted to know what version of a package all these boxes have, simply:

bladerunner 'rpm -q packagename' host1 host2 host3 ... host8999 host9000 host9001

Be careful with pipes... also, when dealing with larger numbers of boxes, try to reduce the odds of getting unique results from every target or nothing will consolidate on output. For instance, you want to find a certain setting on all your web front ends. Put your super crazy command(s) into a file (one command per line), and tell bladerunner about it:

bladerunner -f myfile.txt webserver1 webserver2 webserver3

But... I can't just SSH straight to the web front ends, I have to go through a proxy first! No problem, tell bladerunner to use a jumpbox:

bladerunner --jumpbox sshhost1 'rm -rf /' webserver1 webserver2 webserver3

Different usernames for the jumpbox are possible, as are separate second passwords (could be sudo, SQL, etc). Let's do something really complicated... let's connect to a Cisco jumpbox as user: foo pass: password. Then connect into a bunch of database hosts, and do a select from the MySQL shell, using a different password. We should first make a file with something like this in it:

mysql -u mysql_user -p
use my_database;
select * from my_table where my_column is 'some_query';
exit;

then execute:

bladerunner -m 'cisco>' 'mysql>' -f my_file.txt --jumpbox=core-router --jumpbox-username=foo --jumpbox-password=password -s db_host1 db_host2 db_host3 ...

Note the multiple extra prompts. You can provide as many as you want but be specific in them; use the entire prompt you're expecting.

You'll be prompted for two passwords, the first is the one used to connect to the target hosts, then the SQL password. You could use -P instead of --jumpbox-password to be prompted for that one as well. If neither the second or jumpbox password are switched on, bladerunner will try the target password on any prompt it encounters.

One other thing to note, if you're running a command that takes longer than the command timeout (default 20s), bladerunner will throw ctrl+c at it and try to move on to the next command or host.

There are a slew of options you can use with this program, the goal was to make it as versatile as possible. Try --help and muck about ;)

Clone this wiki locally