Rex::Task - The Task Object
The Task Object. Typically you only need this class if you want to manipulate tasks after their initial creation.
use Rex::Task my $task = Rex::Task->new(name => "testtask"); $task->set_server("remoteserver"); $task->set_code(sub { say "Hello"; }); $task->modify("no_ssh", 1);
This is the constructor.
$task = Rex::Task->new( func => sub { some_code_here }, server => [ @server ], desc => $description, no_ssh => $no_ssh, hidden => $hidden, auth => { user => $user, password => $password, private_key => $private_key, public_key => $public_key, }, before => [sub {}, sub {}, ...], after => [sub {}, sub {}, ...], around => [sub {}, sub {}, ...], name => $task_name, executor => Rex::Interface::Executor->create, );
Returns the current connection object.
Returns the current executor object.
Returns true if the task is hidden. (Should not be displayed on ,,rex -T''.)
Returns the servers on which the task should be executed as an ArrayRef.
With this method you can set new servers on which the task should be executed on.
Delete every server registered to the task.
Returns the current server on which the tasks gets executed right now.
Returns the description of a task.
Set the description of a task.
Returns true (1) if the task will be executed remotely.
Returns true (1) if the task gets executed on the local host.
Returns true (1) if the task gets executed over http protocol.
Returns true (1) if the task will establish a connection to a remote system.
This method tries to guess the right connection type for the task and returns it.
Current return values are SSH, Fake and Local.
SSH - will create a ssh connection to the remote server
Local - will not create any connections
Fake - will not create any connections. But it populates the connection properties so you can use this type to iterate over a list of remote hosts but don't let rex build a connection. For example if you want to use Sys::Virt or other modules.
With this method you can modify values of the task.
Returns the current user the task will use.
Set the user of a task.
Returns the password that will be used.
Set the password of the task.
Returns the name of the task.
Returns the code of the task.
Set the code of the task.
This method is used internally to execute the specified hooks.
Set the authentication of the task.
$task->set_auth("user", "foo"); $task->set_auth("password", "bar");
Merges the authentication information from $server into the task. Tasks authentication information have precedence.
Get the parallelism count of a task.
Set the parallelism of the task.
Initiate the connection to $server.
Disconnect from the current connection.
Run the task on $server.
Returns true if rex should exit on connect failure.
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.