task "mytask1","192.168.137.3", sub {
say run "hostname";
};
run 函数是在哪里呢?
Rex::Commands::Run - 执行远程命令
[root@node01 Rex]# perldoc -l Rex::Commands::Run
/usr/local/perl/lib/site_perl/5.22.1/Rex/Commands/Run.pm
加入一段:
sub run {
print "ddad2313
";
my $cmd = shift;
[root@node01 Rex]# rex mytask1
[2017-05-12 12:58:12] WARN - Please use only the following characters for task names:
[2017-05-12 12:58:12] WARN - A-Z, a-z, 0-9 and _
[2017-05-12 12:58:12] WARN - Also the task should start with A-Z or a-z
[2017-05-12 12:58:12] WARN - You can disable this warning by setting feature flag: disable_taskname_warning
[2017-05-12 12:58:12] WARN - Please use only the following characters for task names:
[2017-05-12 12:58:12] WARN - A-Z, a-z, 0-9 and _
[2017-05-12 12:58:12] WARN - Also the task should start with A-Z or a-z
[2017-05-12 12:58:12] WARN - You can disable this warning by setting feature flag: disable_taskname_warning
[2017-05-12 12:58:12] WARN - Please use only the following characters for task names:
[2017-05-12 12:58:12] WARN - A-Z, a-z, 0-9 and _
[2017-05-12 12:58:12] WARN - Also the task should start with A-Z or a-z
[2017-05-12 12:58:12] WARN - You can disable this warning by setting feature flag: disable_taskname_warning
[2017-05-12 12:58:12] INFO - Running task mytask1 on 192.168.137.3
ddad2313
node2
就是这个方法