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