1REX(1)                User Contributed Perl Documentation               REX(1)
2
3
4

NAME

6       rex - execute tasks defined in a Rexfile
7

DESCRIPTION

9       The "rex" script can be used to execute tasks defined in a Rexfile from
10       the command line.
11

SYNOPSIS

13           bash# rex -h                      # Show usage
14           bash# rex -T                      # List tasks
15           bash# rex uname                   # Run the 'uname' task
16           bash# rex -H server[01..10] uname # Run the 'uname' task on all the specified hosts
17           bash# rex -G production uname     # Run 'uname' on hosts on the 'production' hostgroup
18           bash# rex deploy --gracefully     # Pass '--gracefully' to the 'deploy' task
19

USAGE

21           rex [<options>] [-H <host>] [-G <group>] <task> [<task-options>]
22           rex -T[m|y|v] [<string>]
23
24           -b     Run batch
25           -e     Run the given code fragment
26           -E     Execute a task on the given environment
27           -G|-g  Execute a task on the given server groups
28           -H     Execute a task on the given hosts (space delimited)
29           -z     Execute a task on hosts from this command's output
30
31           -K     Public key file for the ssh connection
32           -P     Private key file for the ssh connection
33           -p     Password for the ssh connection
34           -u     Username for the ssh connection
35
36           -d     Show debug output
37           -ddd   Show more debug output (includes profiling output)
38           -m     Monochrome output: no colors
39           -o     Output format
40           -q     Quiet mode: no log output
41           -qw    Quiet mode: only output warnings and errors
42           -Q     Really quiet: output nothing
43
44           -T     List tasks
45           -Ta    List all tasks, including hidden
46           -Tm    List tasks in machine-readable format
47           -Tv    List tasks verbosely
48           -Ty    List tasks in YAML format
49
50           -c     Turn cache ON
51           -C     Turn cache OFF
52           -f     Use this file instead of Rexfile
53           -F     Force: disregard lock file
54           -h     Display this help message
55           -M     Load this module instead of Rexfile
56           -O     Pass additional options, like CMDB path
57           -s     Use sudo for every command
58           -S     Password for sudo
59           -t     Number of threads to use (aka 'parallelism' param)
60           -v     Display (R)?ex version
61

Rexfile

63       When you run "rex" it reads the file "Rexfile" in the current working
64       directory. A Rexfile consists of 2 major parts: Configuration and Task
65       Definitions.
66
67   Configuration
68       Simple Authentication
69
70           user "bruce";
71           password "batman";
72           pass_auth;
73
74       Key Authentication
75
76           private_key "/path/to/your/private/key.file";
77           public_key "/path/to/your/public/key.file";
78
79       Define Logging
80
81           logging to_file => "rex.log";
82           logging to_syslog => "local0";
83
84       Group your servers
85
86       Rex gives you the ability to define groups of servers. Groups can be
87       defined the Rexfile:
88
89           group "frontends" => "frontend01", "frontend02", "frontend03", "frontend04", "frontend[05..09]";
90
91       Groups can also be defined in a server.ini file:
92
93           [frontends]
94           frontend[01..04]
95
96   Other Configuration
97           timeout 10;    # ssh timeout
98           parallelism 2; # execute tasks in parallel
99
100   Defining tasks
101       A basic task looks like this:
102
103           # task description
104           desc "This task tells you how long since the server was rebooted";
105
106           # task definition
107           task "shortname", sub {
108               say run "uptime";
109           };
110
111       You can also set a default server group:
112
113           desc "This is a long description of a task";
114           task "shortname", group => "frontends", sub {
115               say run "uptime";
116           };
117

TAB COMPLETION

119       Tab completion scripts are provided for Bash and Zsh in the share
120       <https://metacpan.org/release/Rex/source/share> directory. They provide
121       completions for the available CLI options, hosts, groups, environments
122       and tasks.
123
124
125
126perl v5.32.1                      2021-03-06                            REX(1)
Impressum