Building a Vagrant base box can be time consuming and at times maddening when trying to get everything to work. If you stick with it though you can tailor your development box exactly like your production systems.
Create new VM in Virtualbox
Create the VM with the following settings:
- Disable USB
- Disable Audio
- Network Adaptor - NAT
- Port Forwarding: SSH Host Port: 2222 Guest Port: 22
Install CentOS 7
- Set root user password to: vagrant
- Create Vagrant user: vagrant/vagrant
Install Guest Additions
rpm -Uvh http://ftp.linux.ncsu.edu/pub/epel/7/x86_64/e/epel-release-7-2.noarch.rpm
yum install -y gcc kernel-devel kernel-headers dkms make bzip2 perl
shutdown -r now
mkdir /media/VirtualBoxGuestAdditions
mount -r /dev/cdrom /media/VirtualBoxGuestAdditions
cd /media/VirtualBoxGuestAdditions
./VBoxLinuxAdditions
Install needed packages for vagrant
- yum install -y openssh-clients wget curl ntp
Turn on SSHD and NTPD
- systemctl enable sshd.service
- systemctl enable ntpd.service
Turn off iptables
- systemctl disable iptables.service
- systemctl disable ip6tables.service
Comment out Defaults requiretty in /etc/sudoers
Add vagrant to /etc/sudoers file
- vagrant ALL=(ALL) NOPASSWD: ALL
Set selinux to permissive Download vagrant public key
- mkdir /home/vagrant/.ssh
- chmod 0700 /home/vagrant/.ssh
- curl https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub >> /home/vagrant/.ssh/authorized_keys
- chmod 0600 /home/vagrant/.ssh/authorized_keys
- chown -R vagrant:vagrant /home/vagrant
Shutdown VM
- shutdown -h now
Package vagrant box
- vagrant package --output centos7.box --base vagrant-centos7
Sources
http://www.hostedcgi.com/how-to-create-a-centos-7-0-vagrant-base-box/
http://www.if-not-true-then-false.com/2010/install-virtualbox-guest-additions-on-fedora-centos-red-hat-rhel/