<p>Have you considered to use <a href="https://www.ansible.com/" rel="nofollow noreferrer">Ansible</a>?</p>

<p>You have some resources about using <a href="https://docs.ansible.com/ansible/2.5/plugins/inventory/virtualbox.html" rel="nofollow noreferrer">Ansible with VirtualBox</a> and also <a href="https://www.vagrantup.com/docs/provisioning/ansible.html" rel="nofollow noreferrer">vagrant</a></p>

CC BY-SA 3.0
2018-04-19T14:49:19.667Z
Yes, I am already heavily using ansible to provision the virtual machine once it is up. I am trying to see what is the best option to get the virtual machine to a state so that I can use ansible to provision it
keyboard
CC BY-SA 3.0
2018-04-19T14:53:36.100Z
Oks, in case you want to change from vagrant and virtualbox maybe I can help you more, I'm currently using Google Cloud Platform and is very easy to create a custom image and launch with the API, then you don't need Ansible unless you want some extra customisation
wolmi
CC BY-SA 3.0
2018-04-19T14:55:23.323Z
I am willing to change from vagrant/virtual box but I am currently trying to avoid deploying in the cloud (see reply #2 in original question)
keyboard
CC BY-SA 3.0
2018-04-19T14:58:11.207Z
Instead of relying on custom images for individual VMs, I would rather have 1 base VM for a platform (like Ubuntu 16.04) and then use ansible to provision them differently - instead of having 3 custom Ubuntu 16.04 images.
keyboard
CC BY-SA 3.0
2018-04-19T15:23:26.487Z
According to your last comment, you may wish to have a look at packer
Tensibai
CC BY-SA 3.0
2018-04-19T10:53:59.007Z
2018-04-19T10:53:59.007Z
wolmi
<blockquote>
  <p>I've been wondering if there is any other similar software/tool that just does a one time provision, sets up a static IP/MAC address, and allows for easy start/resume/shutdown when testing/deploying/maintaining.</p>
</blockquote>

<p>Sure... a virtualbox VM is simply a XML file. You can copy/modify it as such easily. Use <code>vboxmanage</code> to clone the hdd images as necessary.</p>

<p>So, I don't think it would be too far fetched to just create a template VM in virtualbox once, and then use a little script to do the rest. This way, you have complete control over everything. As you are using Ansible to provision the fresh VM anyway, you don't lose that much by ditching Vagrant.</p>

CC BY-SA 3.0
2018-04-19T22:47:56.533Z
2018-04-19T22:47:56.533Z
AnoE
<p>This is targeted for something a little more industrial strength, but have you looked at <a href="https://www.theforeman.org/" rel="nofollow noreferrer">Foreman</a>? I use the <a href="https://github.com/theforeman/foreman_bootdisk" rel="nofollow noreferrer">Foreman bootdisk plugin</a> to provision my VMs and bare metal machines via kickstart using iPXE. You will need a DHCP server for that though...</p>

CC BY-SA 4.0
2018-06-07T18:10:44.453Z
Kind of nuclear weapon to kill a bug in my opinion, as you need to replace vbox dhcp server, pxe server and host foreman. This could be a single machine but still, that's a large oberhead over a vagrantfile. Again, that's just my opinion :)
Tensibai
CC BY-SA 4.0
2018-06-07T18:57:56.090Z
Yeah... Reading between the lines, I figured this was probably overkill, but I don't actually host PXE/TFTP for my foreman bootdisk implementation. I also figured his home router probably serves DHCP... So it really just ends up being a foreman install? You can use it to manage bare metal, so you can therefore use it to manage vbox guests too. Just not quite so automagically - unless you use [foreman-hooks](https://access.redhat.com/documentation/en-us/red_hat_satellite/6.2/html/server_administration_guide/sect-red_hat_satellite-server_administration_guide-red_hat_satellite_foreman_hooks)
James Shewey
CC BY-SA 4.0
2018-06-07T18:59:16.373Z
I mostly wanted to include it for completeness. It might be overkill for the OP, but perhaps not for the next person who stumbles upon this question with a similar problem.
James Shewey
CC BY-SA 4.0
2018-06-07T22:30:16.973Z
Fair enough, I get the point even if I doubt someone searching about something solved by foreman will hit this question. But that's just my feeling :)
Tensibai
CC BY-SA 4.0
2018-06-07T15:09:50.880Z
2018-06-07T15:09:50.880Z
James Shewey
<p>I've been using vagrant for provisioning virtual machines (Linux only) and so far I've been happy with it. The two things I dislike about it - the hardcoded dependency on the <code>user vagrant</code> as well as making the very first interface a virtual box NAT - this causes some routing problems when communicating outside my LAN - it has eth0 created by vagrant and eth1 in bridged mode. As far as I understand, this was a design decision so there is no way around it. </p>

<p>I currently use vagrant </p>

<ul>
<li>To create a Virtual Box virtual machine, </li>
<li>Set Static IP/MAC addresses</li>
<li>Create my own secondary user, and then treat it as a standalone "physical" host. I then use this user for any additional provisioning.</li>
</ul>

<p>I can delete the <code>user vagrant</code> - the problem is that if I do vagrant up (or vagrant halt I believe to gracefully shutdown) it tries to ssh and the command hangs while it retries. The other problem is that I need to delete it each time I spin up a VM and I <strong>cannot</strong> when doing the first time provisioning because I am logged in as user vagrant. </p>

<p>I've been wondering if there is any other similar software/tool that just does a one time provision, sets up a static IP/MAC address, and allows for easy start/resume/shutdown when testing/deploying/maintaining. </p>

<p>I've been looking at Hashicorp's packer but I don't think it is possible to automatically configure IP/MAC addresses. </p>

<p>I am mainly looking for creating a virtual machine from scratch as if it was installed on a bare metal desktop computer by hand using a ISO on a CD.</p>

<p>In the end, using packer to provision and then using VirtualBox command line tools to recreate some of the functionality that vagrant does will suffice (sett IP/MAC address) - but I wonder if there are any other tools used for creating <strong>secure</strong> (no vagrant user and ssh only with private key) vms.</p>

CC BY-SA 3.0
2018-04-19T07:52:33.667Z
I'm tempted to say no, as no one does production on virtualbox but only development and as such the matter you describe is not a problem for a local test box.
Tensibai
CC BY-SA 3.0
2018-04-19T14:51:29.803Z
Makes sense - what is used for production vms then? VM Ware? What is the best way to spin up a secure production VM with a static IP (only one user that can only ssh with private key)  For now, I am trying to avoid deploying in the cloud so I am trying to avoid AWS (for instance). I am looking to manage my own VMs in a bare-metal server(s) that I would rent (or house in a Datacenter)
keyboard
CC BY-SA 3.0
2018-04-19T15:22:28.787Z
I just mean you don't handle a production machine lifecycle with vagrant, so cleaning up the vagrant user at end of provisioning is the usual thing to do. The vsphere plugin for vagrant handle qetting up the IP properly.
Tensibai
CC BY-SA 3.0
2018-04-21T02:14:08.520Z
Got it - so I assume you meant "dont handle a production lifecycle with [user] vagrant". what I am trying out now is using packer to create a virtual machine with my own user, (not vagrant), installing a public key during the vm installation, and then supplying a corresponding private key so that vagrant up know where to ssh. Although not really sure whether it will work the way I think it will
keyboard
CC BY-SA 3.0
2018-04-21T07:14:09.517Z
I mean with vagrant, either you need to provision and destroy machines for test purpose and vagrant is OK, or you want to hande a longer life cycle and then vagrant is brittle and doesn't scale well to handle future destruction/re provisionning.
Tensibai
CC BY-SA 3.0
2018-04-21T07:17:11.550Z
what would you recommend as an alternative to vagrant?
keyboard
CC BY-SA 3.0
2018-04-21T11:39:55.290Z
Depends, for AWS I use cloudformation templates with aws cli, for vsphere I use vagrant just to spin up machines and configure chef. My choice for bare metal, azure or gcp would be different
Tensibai
CC BY-SA 3.0
2018-04-22T04:26:49.157Z
When using vagrant to configure vsphere machines, do you use your own boxes or the ones from the vagrant cloud?
keyboard
CC BY-SA 3.0
2018-04-22T21:31:14.163Z
In house installed sources, for various reasons, but mainly because there's was no cloud ova for vsphere when we started (I don't if there's some now BTW)
Tensibai
<vagrant><provisioning><virtualization>
Other tools to provision virtual machines
keyboard
# Other tools to provision virtual machines

(Asked by: username_0 on 2018-04-19)

I've been using vagrant for provisioning virtual machines (Linux only) and so far I've been happy with it. The two things I dislike about it - the hardcoded dependency on the `user vagrant` as well as making the very first interface a virtual box NAT - this causes some routing problems when communicating outside my LAN - it has eth0 created by vagrant and eth1 in bridged mode. As far as I understand, this was a design decision so there is no way around it.

I currently use vagrant

* To create a Virtual Box virtual machine,
* Set Static IP/MAC addresses
* Create my own secondary user, and then treat it as a standalone "physical" host. I then use this user for any additional provisioning.

I can delete the `user vagrant` - the problem is that if I do vagrant up (or vagrant halt I believe to gracefully shutdown) it tries to ssh and the command hangs while it retries. The other problem is that I need to delete it each time I spin up a VM and I **cannot** when doing the first time provisioning because I am logged in as user vagrant.

I've been wondering if there is any other similar software/tool that just does a one time provision, sets up a static IP/MAC address, and allows for easy start/resume/shutdown when testing/deploying/maintaining.

I've been looking at Hashicorp's packer but I don't think it is possible to automatically configure IP/MAC addresses.

I am mainly looking for creating a virtual machine from scratch as if it was installed on a bare metal desktop computer by hand using a ISO on a CD.

In the end, using packer to provision and then using VirtualBox command line tools to recreate some of the functionality that vagrant does will suffice (sett IP/MAC address) - but I wonder if there are any other tools used for creating **secure** (no vagrant user and ssh only with private key) vms.

**Tags:** vagrant, provisioning, virtualization

> **Comments:**
> **username_1**: I'm tempted to say no, as no one does production on virtualbox but only development and as such the matter you describe is not a problem for a local test box.  
> **username_0**: Makes sense - what is used for production vms then? VM Ware? What is the best way to spin up a secure production VM with a static IP (only one user that can only ssh with private key)  For now, I am trying to avoid deploying in the cloud so I am trying to avoid AWS (for instance). I am looking to manage my own VMs in a bare-metal server(s) that I would rent (or house in a Datacenter)  
> **username_1**: I just mean you don't handle a production machine lifecycle with vagrant, so cleaning up the vagrant user at end of provisioning is the usual thing to do. The vsphere plugin for vagrant handle qetting up the IP properly.  
> **username_0**: Got it - so I assume you meant "dont handle a production lifecycle with [user] vagrant". what I am trying out now is using packer to create a virtual machine with my own user, (not vagrant), installing a public key during the vm installation, and then supplying a corresponding private key so that vagrant up know where to ssh. Although not really sure whether it will work the way I think it will  
> **username_1**: I mean with vagrant, either you need to provision and destroy machines for test purpose and vagrant is OK, or you want to hande a longer life cycle and then vagrant is brittle and doesn't scale well to handle future destruction/re provisionning.  
> **username_0**: what would you recommend as an alternative to vagrant?  
> **username_1**: Depends, for AWS I use cloudformation templates with aws cli, for vsphere I use vagrant just to spin up machines and configure chef. My choice for bare metal, azure or gcp would be different  
> **username_0**: When using vagrant to configure vsphere machines, do you use your own boxes or the ones from the vagrant cloud?  
> **username_1**: In house installed sources, for various reasons, but mainly because there's was no cloud ova for vsphere when we started (I don't if there's some now BTW)  

---

## 3 answers

### Answer by username_2 on 2018-04-19. Score: 2

Have you considered to use [Ansible](https://www.ansible.com/)?

You have some resources about using [Ansible with VirtualBox](https://docs.ansible.com/ansible/2.5/plugins/inventory/virtualbox.html) and also [vagrant](https://www.vagrantup.com/docs/provisioning/ansible.html)

> **Comments:**
> **username_0**: Yes, I am already heavily using ansible to provision the virtual machine once it is up. I am trying to see what is the best option to get the virtual machine to a state so that I can use ansible to provision it  
> **username_2**: Oks, in case you want to change from vagrant and virtualbox maybe I can help you more, I'm currently using Google Cloud Platform and is very easy to create a custom image and launch with the API, then you don't need Ansible unless you want some extra customisation  
> **username_0**: I am willing to change from vagrant/virtual box but I am currently trying to avoid deploying in the cloud (see reply #2 in original question)  
> **username_0**: Instead of relying on custom images for individual VMs, I would rather have 1 base VM for a platform (like Ubuntu 16.04) and then use ansible to provision them differently - instead of having 3 custom Ubuntu 16.04 images.  
> **username_1**: According to your last comment, you may wish to have a look at packer  

---

### Answer by username_3 on 2018-04-19. Score: 1

> I've been wondering if there is any other similar software/tool that just does a one time provision, sets up a static IP/MAC address, and allows for easy start/resume/shutdown when testing/deploying/maintaining.

Sure... a virtualbox VM is simply a XML file. You can copy/modify it as such easily. Use `vboxmanage` to clone the hdd images as necessary.

So, I don't think it would be too far fetched to just create a template VM in virtualbox once, and then use a little script to do the rest. This way, you have complete control over everything. As you are using Ansible to provision the fresh VM anyway, you don't lose that much by ditching Vagrant.


---

### Answer by username_4 on 2018-06-07. Score: 0

This is targeted for something a little more industrial strength, but have you looked at [Foreman](https://www.theforeman.org/)? I use the [Foreman bootdisk plugin](https://github.com/theforeman/foreman_bootdisk) to provision my VMs and bare metal machines via kickstart using iPXE. You will need a DHCP server for that though...

> **Comments:**
> **username_1**: Kind of nuclear weapon to kill a bug in my opinion, as you need to replace vbox dhcp server, pxe server and host foreman. This could be a single machine but still, that's a large oberhead over a vagrantfile. Again, that's just my opinion :)  
> **username_4**: Yeah... Reading between the lines, I figured this was probably overkill, but I don't actually host PXE/TFTP for my foreman bootdisk implementation. I also figured his home router probably serves DHCP... So it really just ends up being a foreman install? You can use it to manage bare metal, so you can therefore use it to manage vbox guests too. Just not quite so automagically - unless you use [foreman-hooks](https://access.redhat.com/documentation/en-us/red_hat_satellite/6.2/html/server_administration_guide/sect-red_hat_satellite-server_administration_guide-red_hat_satellite_foreman_hooks)  
> **username_4**: I mostly wanted to include it for completeness. It might be overkill for the OP, but perhaps not for the next person who stumbles upon this question with a similar problem.  
> **username_1**: Fair enough, I get the point even if I doubt someone searching about something solved by foreman will hit this question. But that's just my feeling :)  

---

