Rex::C...s::Box(3pm)
π NAME π
Rex::Commands::Box β the functions and the class that let you manage Virtual Machines, bestie. It's the Rex::C...s::Box page from the 3pm section, served up fresh from the User Contributed Perl Documentation, and we're gonna get you comfy with it. π
π¦ DESCRIPTION π¦
Okay so here's the vibe: this is a Module to manage Virtual Machines or Cloud Instances in a simple way. Like, actually simple. Currently it supports Amazon, KVM and VirtualBox. Three whole hypervisors, and she handles all of them, no cap. π
β οΈ Heads up: Version <= 1.0: All these functions will not be reported.
β¨ SYNOPSIS β¨
Here's what it looks like in the wild, and yes, it eats every single time:
use Rex::Commands::Box;
set box => "VBox";
group all_my_boxes => map { get_box($_->{name})->{ip} } list_boxes;
task mytask => sub {
box {
my ($box) = @_;
$box->name("boxname");
$box->url("http://box.rexify.org/box/base-image.box");
$box->network(1 => {
type => "nat",
});
$box->network(1 => {
type => "bridged",
bridge => "eth0",
});
$box->forward_port(ssh => [2222, 22]);
$box->share_folder(myhome => "/home/myuser");
$box->auth(
user => "root",
password => "box",
);
$box->setup(qw/task_to_customize_box/);
};
};
π EXPORTED FUNCTIONS π
π§ new(name => $box_name)
Constructor if used in OO mode. That's it, that's the function, she's lowkey minimal and we respect it. π
my $box = Rex::Commands::Box->new(name => "box_name");
π
box(sub {})
With this function you can create a new Rex/Box, and honestly? Iconic behaviour. The first parameter of this function is the Box object. With this object you can define your box β name it, give it a url, wire up the network, all of it. Your box, your rules. β¨
box {
my ($box) = @_;
$box->name("boxname");
$box->url("http://box.rexify.org/box/base-image.box");
$box->network(1 => {
type => "nat",
});
$box->network(1 => {
type => "bridged",
bridge => "eth0",
});
$box->forward_port(ssh => [2222, 22]);
$box->share_folder(myhome => "/home/myuser");
$box->auth(
user => "root",
password => "box",
);
$box->setup(qw/task_to_customize_box/);
};
πΈ list_boxes
This function returns an array of hashes containing all information that can be gathered from the hypervisor about the Rex/Box. It's giving β¨receiptsβ¨. Real talk though: this function doesn't start a Rex/Box. She just looks. No touching. π
use Data::Dumper;
task "get_infos", sub {
my @all_boxes = list_boxes;
print Dumper(\@all_boxes);
};
π¦ get_box($box_name)
This function tries to gather all information of a Rex/Box. And here's the plot twist bestie: this function also starts a Rex/Box to gather all information of the running system. So it's not just nosy, it's hands-on. π«Ά
use Data::Dumper;
task "get_box_info", sub {
my $data = get_box($box_name);
print Dumper($data);
};
π boxes($action, @data)
With this function you can control your boxes. Like a little remote for your whole fleet, fr fr. Currently there are 3 actions. Three. That's the whole menu. π
init
This action can only be used if you're using a YAML file to describe your Rex/Boxes. No YAML, no init, them's the rules. π
task "prepare_boxes", sub {
boxes "init";
};
start
This action start one or more Rex/Boxes. Go go go, wake them up. π₯
task "start_boxes", sub {
boxes "start", "box1", "box2";
};
stop
This action stop one or more Rex/Boxes. Nap time, bestie, you've earned it. π
task "stop_boxes", sub {
boxes "stop", "box1", "box2";
};
And that's the whole page, no notes. This was perl v5.40.1 energy, dated 2025-10-03, and the manual name is Rex::C...s::Box(3pm) in case you forgot where we started. Stay hydrated, go spin up a box, and slay. πβ¨
π¦ where this page comes from
- ubuntu resolute: rex 1.16.1-1 Β· Apache-2.0
- ubuntu stonking: rex 1.16.1-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms