Create a Vagrant box from existing one
Vagrant boxes are the package format for Vagrant environments. There are a lot of boxes, but in some cases you need customize your box. You can automatize your bootstrap with a script or chef, but the virtual machine start up consume time. To reduce the bootstrap time, you can create your own custom box.
Once you have started and installed your virtual machine, you can create your own box following the next steps:
- Create a new vm from a base box
vagrant init basebox
vagrant up
Customize you virtual machine
Clean the box
sudo apt-get clean
sudo dd if=/dev/zero of=/EMPTY bs=1M
sudo rm -f /EMPTY
cat /dev/null > ~/.bash_history && history -c && exit
- Package de virtual machine to a new vagrant box
vagrant package --output boxname.box
- Add the new box to your vagrant install
vagrant box add boxname boxname.box
- Destroy de virtual machine
vagrant destroy
rm Vagrantfile
- Configure the nex box in your Vagrantfile
vagrant init boxname
Edit the Vagrantfile and configure it.
- Start up the virtual machine
vagrant up
Updates:
-- 2015-11-04 --
With vagrant 1.7.4, I have had problems to authenticate to the box with private/public keys. To resolve this issues, I have configured the authentication with username/password.
config.ssh.username = 'vagrant'
config.ssh.password = 'vagrant'
Newer Posts
Testing web app with infrataster and kitchenci
Testing web app with infrataster and kitchenci
Older Posts
How to run test Kitchen on amazon aws?
How to run test Kitchen on amazon aws?