This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
####################### | |
# Rexfile | |
####################### | |
task "test", sub { | |
my @arr = ("one", "two", "three"); | |
my %hash = ( | |
name => "foo", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rexfile | |
group "webservers" => "srv1", "srv2"; | |
group "database" => "db1", "db2"; | |
require Webservers; | |
require Databases; | |
### | |
# File: lib/Webservers.pm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my @group1 = qw/host1 host2 host3/; | |
my @group2 = qw/srv1 srv2 srv3/; | |
group one => @group1; | |
group two => @group2; | |
group all => @group1, @group2; | |
task "prepare", group => "all", sub { | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Rex::Hardware; | |
use Data::Dumper; | |
user "root"; | |
password "f00b4r"; | |
pass_auth; | |
group myservers => "server1", "server2", "server3"; | |
task "get-info", group => "myservers", sub { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Save this file under /tmp/test-ssh.pl, edit the variables and run it with | |
# perl /tmp/test-ssh.pl | |
# | |
use strict; | |
use warnings; | |
# ------- PLEASE SET THE VARS ----------- | |
my $HOST = ''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Rex -base; | |
user "foouser"; | |
task "uptime", "your-server", sub { | |
say run "uptime"; | |
}; | |
before uptime => sub { | |
my ($server, $server_ref) = @_; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Term::ReadKey; | |
user "root"; | |
# get the CLI parameters | |
my %args = Rex::Args->getopts; | |
# only ask for a password if the user don't want to list tasks. | |
if(! exists $args{T}) { | |
password read_password(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use Data::Dumper; | |
use Rex::Commands::Cloud; | |
use Rex::Commands::SimpleCheck; | |
use Rex::Commands::SCM; | |
use Rex::Commands::Iptables; | |
my $access_key = "your-access-key"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
group mygroup => "srv01", "web[01..10]"; | |
task "test", sub { | |
my @servers = get_servers("mygroup"); | |
for my $srv (@servers) { | |
run_task "foo", on => $srv, params => { param1 => "value1", param2 => "value2" }; | |
} | |
}; | |
sub get_servers { |
OlderNewer