NAME
Rex::Commands - All the basic commands
DESCRIPTION
This module is the core commands module.
SYNOPSIS
desc "Task description";
task "taskname", sub { ... };
task "taskname", "server1", ..., "server20", sub { ... };
group "group" => "server1", "server2", ...;
user "user";
password "password";
COMMANDLIST
Cloud Management Rex::Commands::Cloud
Cron Management Rex::Commands::Cron
Database Commands Rex::Commands::DB
SCP Up- and Download Rex::Commands::Upload, Rex::Commands::Download
File Manipulation Rex::Commands::File
Filesystem Manipulation Rex::Commands::Fs
Information Gathering Rex::Commands::Gather
Manipulation of /etc/hosts Rex::Commands::Host
Get an inventory of your Hardware Rex::Commands::Inventory
Manage your iptables rules Rex::Commands::Iptables
Kernel Commands Rex::Commands::Kernel
LVM Commands Rex::Commands::LVM
Package Commands Rex::Commands::Pkg
Process Management Rex::Commands::Process
Rsync Files Rex::Commands::Rsync
Run Remote Commands Rex::Commands::Run
Manage System Services (sysvinit) Rex::Commands::Service
Sysctl Commands Rex::Commands::Sysctl
Live Tail files Rex::Commands::Tail
Manage user and group accounts Rex::Commands::User
EXPORTED FUNCTIONS
- no_ssh([$task])
-
Disable ssh for all tasks or a specified task.
If you want to disable ssh connection for your complete tasks (for example if you only want to use libVirt) put this in the main section of your Rexfile.
no_ssh;
If you want to disable ssh connection for a given task, put no_ssh in front of the task definition.
no_ssh task "mytask", "myserver", sub { say "Do something without a ssh connection"; };
- task($name [, @servers], $funcref)
-
This function will create a new task.
- Create a local task (a server independent task)
-
task "mytask", sub { say "Do something"; };
If you call this task with (R)?ex it will run on your local machine. You can explicit run this task on other machines if you specify the -H command line parameter.
- Create a server bound task.
-
task "mytask", "server1", sub { say "Do something"; };
You can also specify more than one server.
task "mytask", "server1", "server2", "server3", sub { say "Do something"; };
Or you can use some expressions to define more than one server.
task "mytask", "server[1..3]", sub { say "Do something"; };
If you want, you can overwrite the servers with the -H command line parameter.
- Create a group bound task.
-
You can define server groups with the group function.
group "allserver" => "server[1..3]", "workstation[1..10]"; task "mytask", group => "allserver", sub { say "Do something"; };
- desc($description)
-
Set the description of a task.
desc "This is a task description of the following task"; task "mytask", sub { say "Do something"; }
- group($name, @servers)
-
With this function you can group servers, so that you don't need to write too much ;-)
group "servergroup", "www1", "www2", "www3", "memcache01", "memcache02", "memcache03";
Or with the expression syntax.
group "servergroup", "www[1..3]", "memcache[01..03]";
- batch($name, @tasks)
-
With the batch function you can call tasks in a batch.
batch "name", "task1", "task2", "task3";
And call it with the -b console parameter. rex -b name
- user($user)
-
Set the user for the ssh connection.
- password($password)
-
Set the password for the ssh connection (or for the private key file).
- sudo_password($password)
-
Set the password for the sudo command.
- timeout($seconds)
-
Set the timeout for the ssh connection and other network related stuff.
- max_connect_retries($count)
-
Set the maximum number of connection retries.
- get_random($count, @chars)
-
Returns a random string of $count characters on the basis of @chars.
my $rnd = get_random(8, 'a' .. 'z');
- do_task($task)
-
Call $task from an other task. Will execute the given $task with the servers defined in $task.
task "task1", "server1", sub { say "Running on server1"; do_task "task2"; }; task "task2", "server2", sub { say "Running on server2"; };
You may also use an arrayRef for $task if you want to call multiple tasks.
do_task [ qw/task1 task2 task3/ ];
- public_key($key)
-
Set the public key.
- private_key($key)
-
Set the private key.
- pass_auth
-
If you want to user password authentication, then you need to call pass_auth.
user "root"; password "root"; pass_auth;
- parallelism($count)
-
Will execute the tasks in parallel on the given servers. $count is the thread count to be used.
- logging
-
With this function you can define the logging behaviour of (R)?ex.
- needs($package [, @tasks])
-
With needs you can define dependencies between tasks. The "needed" tasks will be called with the same server configuration as the calling task.
- Depend on all tasks in a given package.
-
Depend on all tasks in the package MyPkg. All tasks will be called with the server server1.
task "mytask", "server1", sub { needs MyPkg; };
- Depend on a single task in a given package.
-
Depend on the uname task in the package MyPkg. The uname task will be called with the server server1.
task "mytask", "server1", sub { needs MyPkg "uname"; };
- LOCAL(&)
-
With the LOCAL function you can do local commands within a task that is defined to work on remote servers.
task "mytask", "server1", "server2", sub { # this will call 'uptime' on the servers 'server1' and 'server2' say run "uptime"; # this will call 'uptime' on the local machine. LOCAL { say run "uptime"; }; };
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 19:
Non-ASCII character seen before =encoding in '{ ...'. Assuming UTF-8