Skip to content
krimdomu edited this page Apr 8, 2011 · 11 revisions

These functions are new in (R)?ex Version 0.3.

Rex

  • rsync interface

    A simple rsync interface is now available. To use it, you need the Perl Module Expect.

    use Rex::Commands::Rsync;
    
    desc "Sync /etc";
    task "etc", "server1", "server2", "server3", sub {
       sync "/filestore/public/etc", "/etc";
    };

    Or, if you want to sync a remote directory to a local one

    task "get-logs", "server", sub {
        sync "/var/log", "/tmp/logs", { download => 1 };
    };
  • debug mode

    There is a new command line switch "-d" for debugging.

  • Logging

    Now you can define a logging destination.

    Log to a file:

    logging to_file => 'rex.log';

    Log to syslog:

    logging to_syslog => 'local0';
  • Run Command from Command-Line

    Example:

    rex -e "run 'hostname'" -H "www01 www02 www03" -u root -p password

    or with serverranges

    rex -e "run 'hostname'" -H "www[01..10]" -u root -p password

    or if you only want to get the hostname from every 3rd server

    rex -e "run 'hostname'" -H "www[01..10/3]" -u root -p password
  • Server-Ranges

    Now you can define serverranges like "www[1..10]" or "www[01..10]".

    task "uname", "www[1..10]", sub {
       run "uname -a";
    };

    or

    group "webserver" => "www[01..15]", "web[1..3]";
    task "uname", group => "webserver", sub {
       run "uname -a";
    };
  • Call Tasks from other tasks

    Now you can call tasks from other tasks.

    Example:

    task "hostname", "server1", "server2", sub {
       run "hostname";
       do_task "uname";
    };
    
    task "uname", "server1", "server2", sub {
       run "uname -a";
    };

rexify

  • A simple command to create a Rexfile skeleton.

    rexify ProjectName

    This will create a Rexfile and file lib/Rex/ProjectName.pm where you can define your Tasks.

Clone this wiki locally