1Rex(3) User Contributed Perl Documentation Rex(3)
2
3
4
6 Rex - the friendly automation framework
7
9 Rex is an automation framework that is friendly to any combinations of
10 local and remote execution, push and pull style of management, or
11 imperative and declarative approach.
12
13 Its flexibility makes it a great fit for many different use cases, but
14 most commonly Rex is used to automate application deployment and data
15 center infrastructure management tasks.
16
17 See Rex::Commands for a starting point of available built-in commands.
18
19 See rex <https://metacpan.org/pod/distribution/Rex/bin/rex> for more
20 information about how to use rex on the command line.
21
23 # In a Rexfile:
24 use Rex -feature => [qw/1.4/];
25
26 user "root";
27 password "ch4ngem3";
28
29 desc "Show system information";
30 task "sysinfo", sub {
31 say run "uname -a";
32 };
33
34 1;
35
36 # On the command line:
37 $ rex -H server[01..10] sysinfo
38
40 get_current_connection
41 This function is deprecated since 0.28! See Rex::Commands::connection.
42
43 Returns the current connection as a hashRef.
44
45 server
46 The server name
47
48 ssh 1 if it is a ssh connection, 0 if not.
49
50 is_ssh
51 Returns 1 if the current connection is a ssh connection. 0 if not.
52
53 is_local
54 Returns 1 if the current connection is local. Otherwise 0.
55
56 is_sudo
57 Returns 1 if the current operation is executed within sudo.
58
59 get_sftp
60 Returns the sftp object for the current ssh connection.
61
62 connect
63 Use this function to create a connection if you use Rex as a library.
64
65 use Rex;
66 use Rex::Commands::Run;
67 use Rex::Commands::Fs;
68
69 Rex::connect(
70 server => "remotehost",
71 user => "root",
72 password => "f00b4r",
73 private_key => "/path/to/private/key/file",
74 public_key => "/path/to/public/key/file",
75 );
76
77 if(is_file("/foo/bar")) {
78 print "Do something...\n";
79 }
80
81 my $output = run("uptime");
82
84 Many thanks to the contributors for their work. Please see CONTRIBUTORS
85 <https://github.com/RexOps/Rex/blob/master/CONTRIBUTORS> file for a
86 complete list.
87
89 Rex is a free software, licensed under: The Apache License, Version
90 2.0, January 2004
91
92
93
94perl v5.30.2 2020-04-06 Rex(3)