[root@node01 my-first-rex-project]# cat Rexfile
use Rex -feature => ['1.0'];
user "root";
private_key "/root/.ssh/id_rsa";
public_key "/root/.ssh/id_rsa.pub";
key_auth;
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" => "stop";
};
task "upload_file", group => "myservers", sub {
file "/etc/ntp.conf",
source => "ntp.conf"
};
[root@node01 my-first-rex-project]# rex upload_file
[2017-04-25 13:21:31] INFO - Running task upload_file on 192.168.137.3
[2017-04-25 13:21:32] INFO - All tasks successful on all hosts
[root@node01 my-first-rex-project]#