Rex is a tool to ease the execution of commands on multiple remote servers. You can define small tasks, chain tasks to batches, link them with servers or server groups, and execute them easily in your terminal.
If you run rex it will read the file Rexfile in the current working directory. A Rexfile consists 3 major parts.
In that part you define the user and password you want to use to log into your servers. You can even define timeouts or the paralellism of task exexecution.
Define the user
user "<user>";
Define the password
password "<password>";
Set password authentication
pass_auth;
Define Private Key
private_key "/path/to/your/private/key.file";
Define Public Key
public_key "/path/to/your/public/key.file";
Log to a file
logging to_file => "rex.log";
Log to syslog
logging to_syslog => "local0";
Define ssh timeout
timeout 10;
Define parallelism
parallelism 2;
Rex gives you the possibility to group your servers. So you don't need to type every servername multiple times.
group "frontends" => "frontend01", "frontend02", "frontend03", "frontend04";
You can even define ranges in the servernames:
group "frontends" => "frontend[01..04]";
Create a task description
desc "This is a long description of a task";
Create the task
task "shortname", group => "frontends", sub { run "uptime"; };
or, if you don't have groups
task "shortname", "frontend01", "frontend02", "frontend03", "frontend04", sub { run "uptime"; };
and with serverranges
task "shortname", "frontend[01..04]", sub { run "uptime"; };
To install Rex, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Rex
CPAN shell
perl -MCPAN -e shell install Rex
For more information on module installation, please visit the detailed CPAN module installation guide.