Rex::Box::VBox(3pm)

πŸ’– Rex::Box::VBox πŸ’–

okay bestie, so this is Rex::Box::VBox from the User Contributed Perl Documentation (yes, 3pm section, we love a Perl module moment). grab a strawberry drink πŸ“ and let's get into it.


✨ NAME ✨

Rex::Box::VBox β€” the Rex/Boxes VirtualBox Module. she does VMs. that's her whole thing. πŸ‘‘


🌸 DESCRIPTION 🌸

so basically: this is a Rex/Boxes module that lets you use VirtualBox VMs. that's it, that's the vibe. no cap.


πŸŽ€ EXAMPLES πŸŽ€

using it in your Rexfile

if you wanna use this module inside your Rexfile, you literally just drop in these commands. copy-paste era πŸ’…

use Rex::Commands::Box;
set box => "VBox";

task "prepare_box", sub {
  box {
    my ($box) = @_;

    $box->name("mybox");
    $box->url("http://box.rexify.org/box/ubuntu-server-12.10-amd64.ova");

    $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("setup_task");
  };
};

look at her go. main character energy fr fr. ✨

if you prefer a YAML file

not a YAML girlie? no problem, use this template:

type: VBox
vms:
  vmone:
    url: http://box.rexify.org/box/ubuntu-server-12.10-amd64.ova
    forward_port:
      ssh:
        - 2222
        - 22
    share_folder:
      myhome: /home/myhome
    setup: setup_task

and then in your Rexfile you use it like this:

use Rex::Commands::Box init_file => "file.yml";

task "prepare_vms", sub {
  boxes "init";
};

so clean, so organized, we're obsessed. 🧚


πŸ¦‹ HEADLESS MODE πŸ¦‹

okay so you can also run VirtualBox in headless mode β€” like, no GUI window popping up, just vibes. πŸ’€

heads up bestie: this only works on Linux and MacOS. not a Windows moment, sorry.

if you want in, just drop this option at the top of your Rexfile:

set box_options => { headless => TRUE };

periodt. πŸ’…


🌈 METHODS 🌈

πŸ“š the inherited ones

see also the Methods of Rex::Box::Base β€” because this module inherits all methods from it. she's a nepo baby but like, in a good way. πŸ‘‘


πŸ’œ new(name => $vmname)

the constructor, for when you're living that OO mode life.

my $box = Rex::Box::VBox->new(name => "vmname");

πŸ’– share_folder(%option)

creates a shared folder inside the VM, and it's filled with the content from a folder on the Host machine. 🫢

fyi: this only works with VirtualBox. iykyk.
$box->share_folder(
  name => "/path/on/host",
  name2 => "/path_2/on/host",
);

⭐ info

returns a hashRef of vm information. that's the whole method. short and iconic. ✨


πŸ¦‹ ip

this method returns the ip of a vm on which the ssh daemon is listening. so like, the ip you'd actually ssh into. slay. πŸ”₯


and that's the whole page bestie!! you're officially a Rex::Box::VBox expert, no cap. πŸ’–βœ¨πŸŽ€

this page comes to you from perl v5.40.1, dated 2025-10-03, and yeah β€” that footer is the last line of the og Rex::Box::VBox(3pm) page. byeeeee πŸ«ΆπŸ’…πŸŒˆ
πŸ“¦ where this page comes from