NAME

Rex::Commands::Service

DESCRIPTION

With this module you can manage Linux services.

Currently this module supports

Debian
CentOS
OpenSuSE

SYNOPSIS

use Rex::Commands::Service

service apache2 => "start";

service apache2 => "stop";

service apache2 => "restart";

service apache2 => "status";

EXPORTED FUNCTIONS

service($service, $action)

The service function accepts 2 parameters. The first is the service name and the second the action you want to perform.

starting a service
task "start-service", "server01", sub {
   service apache2 => "start";
};
stopping a service
task "stop-service", "server01", sub {
   service apache2 => "stop";
};
restarting a service
task "restart-service", "server01", sub {
   service apache2 => "restart";
};
checking status of a service
task "status-service", "server01", sub {
   if( service apache2 => "status" ) {
      say "Apache2 is running";
   }
   else {
      say "Apache2 is not running";
   }
};