NAME

Rex::Inline - write Rex in perl

DESCRIPTION

Rex::Inline is an API of Rex module write with Moose.

when you want use rex in your perl program,

and do not want to use the rex command line,

you can try to use this module.

GETTING HELP

SYNOPSIS

use Rex::Inline;
use Rex::Inline::Test;

my $rex_inline = Rex::Inline->new(use_debug => 0);

# Rex::Inline::Test is based on Rex::Inline::Base module
# See Rex::Inline::Base Documents
$rex_inline->add_task(
  Rex::Inline::Test->new(
    user => $user,
    server => [@server],
    # if need password
    password => $password,
    # optional
    public_key => $public_key,
    private_key => $private_key,
    # input param, in any format you want
    input => $input,
  )
);

# or data reference like this
$rex_inline->add_task(
  {
    name => 'something_uniq_string',  # name is required when add data_reference task
    func => sub {                     # func is required when add data_reference task
      ...
    },
    user => $user,
    server => [@server],
    # if need password
    password => $password,
    # optional
    public_key => $public_key,
    private_key => $private_key,
  }
);

$rex_inline->execute;

# get rex task reports
$rex_inline->reports;

ATTRIBUTES

use_debug

set/get debug option (Bool)

Print or not debug level log

see rex -d option

default is 0 (disabled)

use_cache

set/get use_cache option (Bool)

Use or not rex -c option

default is 1 (enable)

use_report

set/get use_report option (Bool)

show rex report result

default is 1 (enable)

log_dir

set/get log dir (String)

default is "./rexlogs/"

parallelism

set/get parallelism nums (Int)

see rex -t option

default is 5

log_paths

get log paths (ArrayRef)

format is [{task_id => log_path}, ...]

readonly

reports

get rex process reports (ArrayRef)

format is [{report = $report_ref, task_id => $task_id, date => $date, hostname => $hostname}, ...]>

readonly

METHODS

add_task

add Rex::Inline::Base Object to TaskList

or Add Data reference to TaskList

my $rex_inline = Rex::Inline->new;

$rex_inline->add_task({
    name => 'something_uniq_string', # required when add data_reference task
    func => sub { # required when add data_reference task
      ...
    },
    user => $user2,
    server => [@server2],
    # if need password
    password => $password2,
    # optional
    public_key => $public_key2,
    private_key => $private_key2,
});

...
execute

Execute all loaded Task in parallel

$rex_inline->execute;