Howto start using (R)?ex
This is a small howto showing the first steps with (R)?ex.
Preparation
- Download and install rex (See the get page)
Creating a Rexfile
At first create a file named Rexfile in your $HOME directory (or anywhere else).
user "my-user";
password "my-password";
pass_auth;
group myserver => "mywebserver", "mymailserver", "myfileserver";
desc "Get the uptime of all server";
task "uptime", group => "myserver", sub {
say run "uptime";
};
This Example will login as my-user with the password my-password on all the servers in the group myserver and run the command "uptime".
Change into the directory where you just created the Rexfile (in a terminal).
$ cd /home/jan
$ rex uptime
Adding a second task
To add a second task, just add the next lines to your Rexfile.
desc "Start Apache Service";
task "free", group => "myserver", sub {
service "apache2" => "start";
}
This task will start the service apache2 on all the servers in the myserver group.
Display all tasks in a Rexfile
If you want to display all tasks in your Rexfile use the following command.
$ rex -T
Tasks
free Start Apache Service
uptime Get the uptime of all server
Batches
comments powered by Disqus