Rex-Inline

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

0.0.7 Tue Apr 14 10:36 CST 2015
  - "add log report to log file"

0.0.6 Wen Apr 8 10:01 CST 2015
  - "force use SSH instead OpenSSH"

0.0.5 Thu Apr 2 18:10 CST 2015
  - "update document"

0.0.4 Thu Apr 2 17:58 CST 2015
  - "add <user> <password> <private_key> <public_key> Attr, Now you can set default authentication in <new>"

0.0.3 Thu Apr 2 12:45 CST 2015
  - "add <add_auth> METHOD to add default authentication"
  - "add <report_as_yaml> METHOD to reports as yaml"
  - "add <report_as_json> METHOD to reports as json"
  - "add <print_as_yaml> METHOD to print as yaml"
  - "add <print_as_json> METHOD to print as json"

0.0.2 Wen Apr 1 18:00 CST 2015
  - "update document"

README.md  view on Meta::CPAN


  use Rex -feature => ['1.0'];
  use Rex::Inline;

  my $rex_inline = Rex::Inline->new;
  $rex_inline->add_task(
      {
        user => $user,
        server => [@server],
        password => $password,
        # private_key => $private_key_path,
        # public_key => $public_key_path,
        func => sub {
          # 这里写要在 Rex 中执行的语句
        }
      }
  );

  $rex_inline->execute;
  my $reports = $rex_inline->reports;

lib/Rex/Inline/Base.pm  view on Meta::CPAN

=cut
has server => (is => 'ro', required => 1);
=item user

username used when ssh connection

=item password

password used when ssh connection

=item private_key

private_key filename used when ssh connection

=item public_key

public_key filename used when ssh connection

=item sudo [TRUE|FALSE]

use sudo when execute commands

default is C<undef>

=cut
has user => (is => 'ro', default => '');
has [qw(password private_key public_key sudo)] => (is => 'ro');
=item input

input param for tasklist module in any format you need

=cut
has input => (is => 'rw');
=back

=cut
has name => (is => 'ro', lazy => 1, builder => 1);
has task_auth => (is => 'ro', lazy => 1, builder => 1);

sub _build_id { time ^ $$ ^ unpack "%L*", `ps axww | gzip` }
sub _build_name { join('_',grep {$_} (split(/::/, shift->meta->{package}))[qw(-2 -1)]) }
sub _build_task_auth {
  my %auth;
  $auth{user} = $_[0]->{user};
  $auth{password} = $_[0]->{password} if $_[0]->{password};
  $auth{public_key} = $_[0]->{public_key} if $_[0]->{public_key};
  $auth{private_key} = $_[0]->{private_key} if $_[0]->{private_key};
  $auth{sudo} = $_[0]->{sudo} if $_[0]->{sudo};
  return {%auth};
}

__PACKAGE__->meta->make_immutable;

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.666 second using v1.00-cache-2.02-grep-82fe00e-cpan-2cc899e4a130 )