5

I have a VirtualBox VM, created "by hand" (i.e., without using vagrant at all), which runs Debian.

What is the simplest way to generate a vagrant file that would replicate this box? Is there an automated way to do this?

5
  • What do you mean by "replicate"? If you mean recreating from bare Debian and installing all packages, then you have to do that yourself.
    – harrymc
    Commented Mar 30, 2019 at 12:48
  • Did you already tried what suggested here? In this way you can Convert a VirtualBox .ova VM into a Vagrant box then from there you can duplicate/clone... If that was you goal let me know that I will write one answer with some words more...
    – Hastur
    Commented Apr 1, 2019 at 11:52
  • The automated way/procedures (eventually existent) may depend on the host OS. Which is yours?
    – Hastur
    Commented Apr 4, 2019 at 12:24
  • @Hastur: my host is also Debian.
    – kjo
    Commented Apr 4, 2019 at 15:17
  • @kjo thx. BTW I found vagrantmanager but unfortunately is not for Linux...
    – Hastur
    Commented Apr 5, 2019 at 10:00

1 Answer 1

2
+200

You can try following the steps reported in the github page "Convert a VirtualBox .ova VM into a Vagrant box #7", skipping the first one because you already have your VM (and you are not starting from an ova file)...

  1. Individuate the internal name, ID, reading it from the GUI or by commandline with the VBoxManage command:

    VBoxManage list vms
    "UCS 4.1" {acef4c0a-35be-4640-a214-be135417f011}

    You are interested in acef4c0a-35be-4640-a214-be135417f011, that on your computer will be different (instead of UCS 4.1 you have to select the VM name you given to your debian system).

  2. Package that VM as a Vagrant box

    vagrant package --base acef4c0a-35be-4640-a214-be135417f011 --output UCS.box

    Take the unique ID found before and write instead of acef4c0a-35be-4640-a214-be135417f011 in the above command line. Note that you can change the output filename as you want (instead of UCS.box you can use whatever.box), but you will need to use the same name in the next command.

  3. Add to the list of your local Vagrant boxes

    vagrant box add UCS.box --name UCS

    With the file name chosen before you can add the box to vagrant, choosing even the human readable name (in the above case UCS). The name has to be reported in the next file.

  4. Create a Vagrantfile to use this box, or modify one you already have:

    Vagrant.configure("2") do |config|
    config.vm.box = "UCS"
    # ...
    end

  5. vagrant up

3
  • Thanks, but I don't see any *.ova files in my vms directory, so I think this may not work for me.
    – kjo
    Commented Apr 3, 2019 at 21:13
  • You're welcome. You have not to see any ova file (it's the analogous of a zip file or cab...). Enter in a shell (DOS prompt or Linux Bash Shell if you are under windows 10) and write the command in the point 1 VBoxManage list vms. It will answer with the list of the already present VM. Take the strange number (acef4c0a...) associated with the "human readable" one (it will be different on your computer... then continue to use the other commands... You can change the names but you have to change even in the next step (see the bold part to understand better).
    – Hastur
    Commented Apr 4, 2019 at 10:10
  • Add config.ssh.insert_key = false and follow this answer to remove ssh problems: "Warning: Authentication failure. Retrying... " after packaging box Commented Nov 19, 2020 at 18:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .