(R)?ex Deployment & Configuration Management

Search

News

2016-09-08

Work with (R)?ex at adjust! Check out their job posting for details, or contact our fellow core developer, FErki.

2016-07-16

(R)?ex 1.4.1 released, fixing many bugs. See the release notes for more details.

2016-03-07

(R)?ex 1.4.0 released, containing lots of goodies. See the release notes for more details.

2015-09-04

(R)?ex 1.3.3 released, fixing a bunch of bugs. See the release notes for more details.

2015-06-22

adjust GmbH is sponsoring the (R)?ex project with a new build server. Thank you for your support!

2015-06-17

(R)?ex 1.3.2 released, fixing issues related to file manipulation when run on BSDs. See the release notes for more details.

2015-06-08

(R)?ex 1.3.1 released, fixing Rex::Commands::DB related tests.

2015-05-27

Read the second part of "Rex in practice" series about Test-driven infrastructure.

2015-05-09

repositor.io 1.1.0 released. repositor.io is a repository management tool for apt, yum, yast and docker. This is a bugfix release with fixes for ubuntu and centos7 installation media mirroring.

2015-05-03

(R)?ex 1.2.0 released. See the release notes for more details.

2015-03-27

View the slides of the talk An introduction to Rex from Andy Beverley.

Conferences

2016-06-21

Training

Need Help?

Rex is a pure open source project, you can find community support in the following places:

Professional support is also available.

» Home » Docs » API » 1.3 » Rex » Task.pm

Task.pm

API Version:

NAME

Rex::Task - The Task Object

DESCRIPTION

The Task Object. Typically you only need this class if you want to manipulate tasks after their initial creation.

SYNOPSIS

 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);

METHODS

new

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 {}, ...],
    before_task_start => [sub {}, sub {}, ...],
    after_task_finished => [sub {}, sub {}, ...],
    name => $task_name,
    executor => Rex::Interface::Executor->create,
  );

connection

Returns the current connection object.

executor

Returns the current executor object.

hidden

Returns true if the task is hidden. (Should not be displayed on ,,rex -T''.)

server

Returns the servers on which the task should be executed as an ArrayRef.

set_server(@server)

With this method you can set new servers on which the task should be executed on.

delete_server

Delete every server registered to the task.

current_server

Returns the current server on which the tasks gets executed right now.

desc

Returns the description of a task.

set_desc($description)

Set the description of a task.

is_remote

Returns true (1) if the task will be executed remotely.

is_local

Returns true (1) if the task gets executed on the local host.

is_http

Returns true (1) if the task gets executed over http protocol.

want_connect

Returns true (1) if the task will establish a connection to a remote system.

get_connection_type

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.

modify($key, $value)

With this method you can modify values of the task.

user

Returns the current user the task will use.

set_user($user)

Set the user of a task.

password

Returns the password that will be used.

set_password($password)

Set the password of the task.

name

Returns the name of the task.

code

Returns the code of the task.

set_code(\&code_ref)

Set the code of the task.

run_hook($server, $hook)

This method is used internally to execute the specified hooks.

set_auth($key, $value)

Set the authentication of the task.

 $task->set_auth("user", "foo");
 $task->set_auth("password", "bar");

merge_auth($server)

Merges the authentication information from $server into the task. Tasks authentication information have precedence.

parallelism

Get the parallelism count of a task.

set_parallelism($count)

Set the parallelism of the task.

connect($server)

Initiate the connection to $server.

disconnect

Disconnect from the current connection.

run($server, %options)

Run the task on $server.

exit_on_connect_fail()

Returns true if rex should exit on connect failure.

Fork me on GitHub
Google Group / Twitter / GitHub / Mailinglist / irc.freenode.net #rex   -.รด.-   Disclaimer