Rex::Box::KVM(3)

πŸ“¦ version 1.14.3, in nixos 26.05, nixpkgs unstable

πŸ’… Rex::Box::KVM β€” bestie's guide to KVM boxes

okay so quick vibe check: this is the Rex::Box::KVM page from the User Contributed Perl Documentation, section 3 of the manual. yes we're fancy. yeah we're in the man pages. no cap.


✨ NAME ✨

Rex::Box::KVM β€” it's the Rex/Boxes KVM Module. that's literally it, that's the name, she's serving exactly what it says on the tin πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

it's a Rex/Boxes module that lets you use KVM VMs πŸ”₯

but listen β€” one (1) non-negotiable: you need to have libvirt installed. that's not a suggestion, that's a whole requirement, bestie. no libvirt, no boxes. 😭


🌸 EXAMPLES 🌸

using it in your Rexfile

okay so to use this module inside your Rexfile you can use these following commands, and yes you should absolutely copy them:

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

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

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

       $box->network(1 => {
          name => "default",
       });

       $box->auth(
          user => "root",
          password => "box",
       );

       $box->setup("setup_task");
    };
 };

it's giving main character energy honestly πŸ’…

using a YAML file instead (iykyk)

if YAML is more your vibe, you can use this following template:

 type: KVM
 vms:
    vmone:
       url: http://box.rexify.org/box/ubuntu-server-12.10-amd64.kvm.qcow2
       setup: setup_task

and then you can use it the following way in your Rexfile:

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

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

obsessed. genuinely. 🫢


πŸ‘‘ METHODS πŸ‘‘

also β€” don't forget to check out the Methods of Rex::Box::Base. this module inherits all methods of it, so anything Base can do, KVM can do too. she ate and left no crumbs. ⭐

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

this one's the constructor, but only if you're using it in OO mode:

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

iconic. straightforward. no notes. πŸŽ€

πŸ“ memory($memory_size)

sets the memory of a VM, measured in megabyte. that's megabytes, plural, don't come for me. πŸ’€

🧚 info

returns a hashRef of vm information. that's it, that's the whole method, and honestly she's thriving. ✨

🌈 ip

this method returns the ip of a vm, specifically the ip on which the ssh daemon is listening. so like… the useful one. 😌


lowkey reminder bestie: libvirt has to be installed for any of this to work. i'm not nagging, i'm just looking out for you. πŸ’–

and that's the whole page! πŸŽ€ this little beauty was served up by perl v5.42.3 on 2023-08-05, and it was literally my pleasure to walk you through it. mwah. πŸ’…βœ¨

πŸ“¦ where this page comes from