[root@node01 my-first-rex-project]# cat Rexfile
use Rex -feature => ['1.0'];
user "root";
password "1234567";
group myservers => "192.168.137.3";
desc "Get the uptime of all servers";
task "uptime", group => "myservers", sub {
my $output = run "uptime";
say $output;
};
desc "Start Mysql Service";
task "start_mysql", group => "myservers", sub {
service "mysql" => "start";
};
[root@node01 my-first-rex-project]# rex start_mysql
mysql 为对应操作系统的一个服务:
node2:/etc/init.d#ls -ltr mysql
-rwxr-xr-x 1 root root 10880 Mar 12 10:17 mysql