Overview

mass.pl is the implementation of a relatively simple idea. Instead of interactively doing some task on one machine, then duplicating the effort on N other machines, write a shell script, then scp it to N machines and execute it as root.

I don't really expect anyone to use it. It's extremely ugly, but it works well. Ansible is extremely similar, but it requires describing config in YAML and using modules instead of simply doing what you need in shell. Note that it's possible to describe "tasks" in mass with YAML as well, for example, you could use mass to copy Ansible and some YAML files to hosts, then run Ansible in local mode.

Features

Host name expressions

The argument to --name can now be an expression composed of groups of machines from names.pl (and single machines). For example, --name "web-machine1" takes the simple difference of web and machine1, where they're both either named groups (perl arrays from names.pl) or individual machines. Machines with dashes in the name can be escaped with single quotes or a backslash infront of the dash.

The operators are:

More examples: given names.pl like this:

@web = qw(web1 web2 web3);
@linux = qw(web2 web3 mail1);
@solaris = qw(web1 mail2 honey-pot);

Example session

mass% ./mass.pl
mass.pl version 1.14
./mass.pl --script script --machines machine1,...,machineN
--name namedlist --send file --retrieve file --ssh [1 or 2]
--noroot --sshpass --sshphrase --su --sudo --user username --bd --noping
--ssh [1 or 2] --pingonly

general opts:
--script script     specify the name of the script to run on the targets
--machines machines operate on this comma separated list of machines
--name namedlist    use the named list of machines from names.pl
--send files        send this comma separated list of files
--retrieve files    scp these files back after executing the script
--numchild n        number of processes to fork, default min of 10 or number of targets
--verbose       show ping and scp output
--debug         show output from each child as it's read

auth opts:
--noroot        don't try to use su to become root
--sshpass       ask for password to authenticate to ssh with
--sshphrase     ask for passphrase to authenticate to ssh with
--su            become root via su instead of sudo
--sudo          become root via sudo instead of su
--user username     specify the user we should scp and ssh as
--bd            backdoor, equal to --noroot --user root --sshpass

misc opts:
--ssh option        specify ssh options (version etc)
--retonly       only retrieve files, no script
--pingonly      only ping hosts
--nocleanup     don't delete sent files
--dry           like --pingonly --noping
--groups        only display host groups
--export        like dry but output export statement for bash, to be used via eval

mass% time ./mass.pl --name host --scr do uptime --noroot 
trying to run do uptime on 50 machines
host01,host02,host03,host04,host05,host06,host07,host08,host09,
host10,host11,host12,host13,host14,host15,host16,host17,host18,
host19,host20,host21,host22,host23,host24,host25,host26,host27,
host28,host29,host30,host31,host32,host33,host34,host35,host36,
host37,host38,host39,host40,host41,host42,host43,host44,host45,
host46,host47,host48,host49,host50
host17:  21:52:32 up 150 days,  2:30,  1 user,  load average: 0.04, 0.05, 0.00
host11:  20:52:23 up 150 days,  2:29,  1 user,  load average: 0.00, 0.00, 0.00
host20:  21:52:26 up 150 days,  2:23,  1 user,  load average: 0.01, 0.01, 0.00
host24:  21:52:29 up 170 days,  2:04,  1 user,  load average: 0.05, 0.03, 0.00
host12:  21:52:24 up 150 days,  2:30,  4 users,  load average: 0.10, 0.09, 0.09
host33:  21:52:30 up 150 days,  2:24,  1 user,  load average: 0.00, 0.04, 0.02
host22:  21:52:27 up 150 days,  2:28,  1 user,  load average: 0.01, 0.02, 0.00
host14:  21:52:32 up 79 days,  7:50,  6 users,  load average: 0.00, 0.00, 0.00
host39:  21:52:26 up 88 days,  5:26,  3 users,  load average: 0.06, 0.06, 0.06
host18:  21:52:23 up 88 days,  5:26, 12 users,  load average: 0.18, 0.20, 0.15
host08:  21:53:27 up 147 days,  5:22,  4 users,  load average: 0.00, 0.02, 0.00
host43:  21:52:29 up 91 days,  9:05,  1 user,  load average: 0.16, 0.13, 0.09
host44:  21:52:24 up 170 days,  1:57,  1 user,  load average: 0.06, 0.05, 0.01
host41:  21:52:23 up 171 days,  3:48,  1 user,  load average: 0.00, 0.00, 0.00
host40:  21:52:26 up 150 days,  2:28,  1 user,  load average: 0.02, 0.02, 0.00
host13:  21:52:27 up 154 days,  5:18,  3 users,  load average: 0.00, 0.00, 0.00
host48:  21:52:31 up 170 days,  2:08,  1 user,  load average: 0.73, 0.23, 0.08
host21:  21:52:24 up 150 days,  2:31,  1 user,  load average: 0.12, 0.04, 0.01
host15:  21:52:23 up 387 days, 11:09,  5 users,  load average: 0.16, 0.14, 0.09
host31:  21:52:26 up 150 days,  2:27,  1 user,  load average: 0.31, 0.12, 0.03
host09:  21:52:23 up 150 days,  2:24,  1 user,  load average: 0.06, 0.07, 0.01
host28:  21:52:31 up 88 days,  5:26,  1 user,  load average: 0.03, 0.07, 0.02
host23:  21:52:27 up 88 days,  5:25,  1 user,  load average: 0.07, 0.10, 0.13
host05:  21:52:30 up 150 days,  2:31,  1 user,  load average: 0.00, 0.01, 0.00
host36:  21:52:29 up 150 days,  2:31,  1 user,  load average: 0.00, 0.02, 0.00
host50:  21:52:25 up 4 days, 11:09, 12 users,  load average: 0.05, 0.03, 0.00
host01:  21:52:32 up 150 days,  2:31,  1 user,  load average: 0.12, 0.03, 0.01
host04:  21:52:26 up 150 days,  2:29,  1 user,  load average: 0.10, 0.03, 0.01
host25:  21:52:31 up 150 days,  2:31,  1 user,  load average: 0.04, 0.09, 0.05
host07:  21:52:24 up 150 days,  2:28,  3 users,  load average: 0.41, 0.38, 0.33
host19:  21:52:23 up 53 days,  7:20,  6 users,  load average: 0.01, 0.03, 0.01
host46:  21:52:28 up 17 days,  9:30,  2 users,  load average: 0.01, 0.02, 0.00
host27:  21:52:29 up 150 days,  2:31,  1 user,  load average: 0.08, 0.06, 0.01
host02:  21:52:26 up 171 days,  5:44,  1 user,  load average: 0.03, 0.04, 0.00
host49:  21:52:24 up 150 days,  2:28,  1 user,  load average: 0.08, 0.06, 0.01
host03:  21:52:27 up 150 days,  2:30,  4 users,  load average: 0.14, 0.15, 0.10
host29:  21:52:23 up 169 days, 22:49,  1 user,  load average: 0.37, 0.14, 0.10
host35:  21:52:26 up 150 days,  2:29,  1 user,  load average: 0.00, 0.00, 0.00
host30:  21:52:24 up 150 days,  2:24,  1 user,  load average: 0.03, 0.03, 0.00
host47:  21:52:23 up 170 days,  2:04,  1 user,  load average: 0.05, 0.05, 0.00
40 passed: host01,host02,host03,host04,host05,host07,host08,host09,host11,
host12,host13,host14,host15,host17,host18,host19,host20,host21,
host22,host23,host24,host25,host27,host28,host29,host30,host31,
host33,host35,host36,host39,host40,host41,host43,host44,host46,
host47,host48,host49,host50
6 failed: host06,host10,host16,host26,host32,host37
4 fatal errors: host34,host38,host42,host45
./mass.pl --name host --scr do uptime --noroot  1.77s user 0.99s system 22% cpu 12.164 total

Files

mass.tar.bz2 Package of the next few files (mass.pl, names.pl, newusers.pl, pushsomething, userinfo.pl)
mass.pl
names.pl Example machine names file
newusers.pl This file creates users on FreeBSD/OpenBSD, Linux and Solaris and sets up their homedir and .ssh/authorized_keys files. It works well with mass.pl.
userinfo.pl This is the info file used by newusers.pl
do Tiny shell script to enable running arbitrary short commands
pushsomething A simple example shell script showing how to use "# send: " to put some file into /usr/local/bin with specific modes.

Required packages

Expect
IO::Stty
IO::Tty
Term::ReadKey
Text::Balanced
Parse::RecDescent

Contact

I dislike spam, so if you have to contact me, I'm sure you can find an email address.

Similar programs

Similar programs with broken links

Mass logo

Since some people wanted more graphics on my wabpaeg I decided to make a logo for mass.pl, so here it is: push buttan