task 'mytask', group => "myservers", sub {
my $parameters = shift;
my $parameter1_value = $parameters->{parameter1};
#my $parameter2_value = $parameters->{parameter2};
print "$parameter1_value=$parameter1_value
";
file "/tmp/a1.sh",
source => "script/a1.sh",
mode => 755;
my $output = run "/tmp/a1.sh $parameter1_value";
say $output;
};
[root@node01 my-first-rex-project]# cat script/a1.sh
hostname;pwd;echo $1
[root@node01 my-first-rex-project]# rex mytask --parameter1=dbcdefg
[2017-04-29 14:23:23] INFO - Running task mytask on 192.168.137.3
$parameter1_value=dbcdefg
node2
/root
dbcdefg
[2017-04-29 14:23:34] INFO - All tasks successful on all hosts
[root@node01 my-first-rex-project]#