Skip to content

Instantly share code, notes, and snippets.

@ferki
Created May 23, 2020 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ferki/dfe59dda22710c719c17697ccb193051 to your computer and use it in GitHub Desktop.
Save ferki/dfe59dda22710c719c17697ccb193051 to your computer and use it in GitHub Desktop.
collect task results to display after the task
use strict;
use warnings;
use Rex -feature => [ '1.4', 'exec_autodie' ];
use Data::Printer;
BEGIN {
use Rex::Shared::Var;
share qw(%results_for);
}
task 'status_line', sub {
say 'doing stuff';
# collecting results
my $hostname = run 'hostname';
my $result = run 'whoami';
$results_for{$hostname} = $result;
};
after_task_finished 'status_line' => sub {
say 'Collected results:';
p %results_for;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment