Vagrant for DevOps: Custom Linux boxes

In one of the previous posts I explained how to create a custom box running Windows.
So in this post I’ll show how you can create your custom box running Linux – both CentOS and Ubuntu.
I won’t use Packer in this example – just regular VirtualBox and shell commands.

Here’re some basic steps to create a custom vagrant box with Linux:

1. Download suitable ISO from official site or any other source if you will;
2. Create VirtualBox VM and disable USB and Audio;
3. Install updates and necessary software (“Development Tools”, nano wget ncdu tree ssmtp lynx htop net-tools telnet unzip);
4. If you want to run Puppet or Cher you need to install clients, but I prefer Ansible for small infrastructures;
5. Create administrator user “vagrant” with well-known password “vagrant” during or after the installation;
6. Allow password-less sudo by adding with visudovagrant ALL=(ALL) NOPASSWD:ALL
7. Disable UseDNS options in /etc/ssh/sshd_config if it’s present (in Ubuntu and CentOS they’re not enabled by default)
8. Disable requiretty using visudo (relevant for CentOS 7);
9. Download well-known ssh key and set correct permissions for the Open-SSH:

10.¬†Enable AuthorizedKeysFile in /etc/ssh/sshd_config (uncomment AuthorizedKeysFile %h/.ssh/authorized_keys string; however it’s already been done in CentOS7);

11. Install VirtualBox guest tools process for:





12. Prepare hard drive for compression:


13. Create box from VM:


14. Import box to local Vagrant installation:


15. Test the created box:

Screen Shot 2016-06-12 at 23.24.59

16. Upload the box to the Atlas repo or any other places;
17. Download & test box on some other Vagrant host.

Vagrant for DevOps table of contents