1Rex::Box::VBox(3) User Contributed Perl Documentation Rex::Box::VBox(3)
2
3
4
6 Rex::Box::VBox - Rex/Boxes VirtualBox Module
7
9 This is a Rex/Boxes module to use VirtualBox VMs.
10
12 To use this module inside your Rexfile you can use the following
13 commands.
14
15 use Rex::Commands::Box;
16 set box => "VBox";
17
18 task "prepare_box", sub {
19 box {
20 my ($box) = @_;
21
22 $box->name("mybox");
23 $box->url("http://box.rexify.org/box/ubuntu-server-12.10-amd64.ova");
24
25 $box->network(1 => {
26 type => "nat",
27 });
28
29 $box->network(1 => {
30 type => "bridged",
31 bridge => "eth0",
32 });
33
34 $box->forward_port(ssh => [2222, 22]);
35
36 $box->share_folder(myhome => "/home/myuser");
37
38 $box->auth(
39 user => "root",
40 password => "box",
41 );
42
43 $box->setup("setup_task");
44 };
45 };
46
47 If you want to use a YAML file you can use the following template.
48
49 type: VBox
50 vms:
51 vmone:
52 url: http://box.rexify.org/box/ubuntu-server-12.10-amd64.ova
53 forward_port:
54 ssh:
55 - 2222
56 - 22
57 share_folder:
58 myhome: /home/myhome
59 setup: setup_task
60
61 And then you can use it the following way in your Rexfile.
62
63 use Rex::Commands::Box init_file => "file.yml";
64
65 task "prepare_vms", sub {
66 boxes "init";
67 };
68
70 It is also possible to run VirtualBox in headless mode. This only works
71 on Linux and MacOS. If you want to do this you can use the following
72 option at the top of your Rexfile.
73
74 set box_options => { headless => TRUE };
75
77 See also the Methods of Rex::Box::Base. This module inherits all
78 methods of it.
79
80 new(name => $vmname)
81 Constructor if used in OO mode.
82
83 my $box = Rex::Box::VBox->new(name => "vmname");
84
85 share_folder(%option)
86 Creates a shared folder inside the VM with the content from a folder
87 from the Host machine. This only works with VirtualBox.
88
89 $box->share_folder(
90 name => "/path/on/host",
91 name2 => "/path_2/on/host",
92 );
93
94 info
95 Returns a hashRef of vm information.
96
97 ip
98 This method return the ip of a vm on which the ssh daemon is listening.
99
100
101
102perl v5.28.1 2017-03-01 Rex::Box::VBox(3)