Rex::Commands::Box(3)
πΈ NAME πΈ
okay so bestie, welcome to the iconic Rex::Commands::Box(3) page β straight from the User Contributed Perl Documentation β for Rex::Commands::Box: Functions / Class to manage Virtual Machines. yes, it's literally a module for managing VMs and cloud stuff, and it's giving main character energy π
π¦ DESCRIPTION π¦
This is a Module to manage Virtual Machines or Cloud Instances in a simple way β no cap. Currently it supports Amazon, KVM and VirtualBox β¨
Version <= 1.0: All these functions will not be reported. lowkey important, so don't come for me if they're missing π
π SYNOPSIS π
here's the vibe in code form, bestie β copy it exactly:
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 π
okay, this is the whole function menu. every one of these is iconic in its own way π«Ά
β¨ new(name => $box_name) β¨
This is the constructor, but only if you're using it in OO mode. periodt.
my $box = Rex::Commands::Box->new(name => "box_name");
β¨ box(sub {}) β¨
With this function you can create a new Rex/Box. The first parameter of this function is the Box object, and with that object you can define your box. it's giving DIY but make it virtual π
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 does not start a Rex/Box β it's just here to spill the tea β
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. Heads up: it also starts a Rex/Box to gather all information of the running system. so yeah, it's a little extra, but it's doing the work πββοΈ
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. Currently there are 3 actions. let's get into it β¬οΈ
init
This action can only be used if you're using a YAML file to describe your Rex/Boxes.
task "prepare_boxes", sub {
boxes "init";
};
start
This action starts one or more Rex/Boxes. slay.
task "start_boxes", sub {
boxes "start", "box1", "box2";
};
stop
This action stops one or more Rex/Boxes. bye bestie π
task "stop_boxes", sub {
boxes "stop", "box1", "box2";
};
that's the whole page, bestie π brought to you by perl v5.42.3, dated 2023-08-05, and of course Rex::Commands::Box(3) from the User Contributed Perl Documentation. mwah π
π¦ where this page comes from
- nixos 26.05: perl5.42.3-Rex 1.14.3
- nixpkgs unstable: perl5.42.3-Rex 1.14.3
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms