Vagrant is an awesome free tool for versioning environments. Basically with it you can easily get up and running virtual machine image within seconds. It's working beautifully with Oracle's free VirtualBox.
To install Vagrant and VirtualBox on Mac OS X, simply start by installing brew and cask with these 3 commands:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew tap caskroom/cask
brew install brew-cask
Then, install Vagrant and VirtualBox via brew and cask:
brew cask install vagrant virtualbox
After that you can simply check installed versions:
vagrant -v && vboxmanage -v
Add CentOS image to Vagrant (you can choose other than CentOS, here's a list of others):
vagrant box add centos https://github.com/tommy-muehle/puppet-vagrant-boxes/releases/download/1.1.0/centos-7.0-x86_64.box
To start your virtual machine, create a directory, change to it and initialise Vagrant box:
mkdir centos && cd centos && vagrant init centos
After that, you can start your box and SSH into it:
That's it! You've got CentOS VM running with Vagrant! You can package your vagrant box using
vagrant package --output centos.box command.
Other useful Vagrant and VirtualBox commands can be listed with
vagrant -h and
vboxmanage -h | less.