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
task "mytask", sub { | |
my $param = shift; | |
say $param->{param1}; | |
say $param->{param2}; | |
}; | |
# call with: |
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
task "run", "host1", sub { | |
# run task "prepare" on the current ssh connection | |
prepare(); | |
# run task "start_services" on the current ssh connection | |
start_services(); | |
# create a new connection, to the server defined in the task definition | |
# and run the task prepare | |
do_task "prepare"; |
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 Rex::Commands::Cloud; | |
use Data::Dumper; | |
user "root"; | |
password "blahblub123%%"; | |
pass_auth; |
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 servers => "db", "frontend[01..04]"; | |
task "test", sub { | |
# this returns the content of the group as is. so the frontend servers | |
# don't get parsed to frontend01, frontend02, ... | |
my @servers_raw = Rex::Group->get_group("servers"); | |
print Dumper(\@servers_raw); | |
# this will parse the frontend[01..04] into 4 servers |
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 | |
user "root"; | |
key_auth; | |
task "mytask", sub { | |
# do something | |
}; | |
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 | |
use Expect; | |
set connection => "OpenSSH"; | |
my $expect_timeout = 5; | |
my $git_password = 'f00b4r'; | |
my $sudo_password = 'test'; |
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 -feature => '0.40'; | |
use String::Escape 'string2hash'; | |
user "root"; | |
group mygroup => "srv02", "srv01", "srv03"; | |
configure_auth("server.lst"); | |
task "test", group => "mygroup", sub { | |
my $output = run "uptime"; | |
say $output; |
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::Commands::DB { | |
dsn => "DBI:mysql:database=test;host=localhost", | |
user => "myuser", | |
password => "foobar", | |
}; | |
group mygroup => map { $_->{name} } db select => { | |
fields => "name", | |
from => "servers", |
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 { |
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"; |