Use one found here: http://www.vagrantbox.es you can use one of those to build upon or you can create one.
These steps are if you want to to create a fresh box.
Grab the latest CentOS image here:
http://www.centos.org/download/
I use the minimal image http://ftp.usf.edu/pub/centos/7.0.1406/isos/x86_64/CentOS-7.0-1406-x86_64-Minimal.iso
First you need to create a VM using Fusion.
- Select “Install from disc or image” >> Continue
- “Use another disc or disc image” >> Find your iso >> Continue
- Uncheck “Use Easy Install” make sure “Make your home folder accessible to the virtual machine is unchecked. >> Continue
- Click “Customize Settings” >> Rename your vm and place it somewhere safe.
Settings for new VM:
Sharing
Make sure sharing is disabled.
Processor & Memory
Select 1 Processor and 512 MB Memory, this is minimal because not everyone has a system with 16 cores and 64gb of memory.
Display
Make sure everything here is unchecked, Accelerated 3d and Retina Display not needed.
Network Adapter
Make sure “Share with my Mac” is selected.
Hard Disk
Uncheck “Split into multiple files”
ClickApply
Sound Card
Click “Remove Sound Card”
USB & Bluetooth
Click “Advance USB options” >> Click “Remove USB Controller”
Printer
Click “Remove Printer Port”
Compatibility
Click “Advanced options” >> I use hardware version7, but you can use whatever you feel is necessary. It is the compatibility you are looking for, if you and everyone you are suppling the box is using Fusion 7 leave it alone. If by chance you don’t know who is going to use your box you’ll want to be as compatible as you can.
Isolation
Uncheck “Enable Drag and Drop” and “Enable Copy and Paste”
Installing CentOS:
Select Language.
Installation Destination. Click “Done” >> Begin Installation
Root Password >> Set it to vagrant >> Click “Done” twice.
Click “Reboot”
Install complete.
Configure CentOS:
Login as root password is vagrant.
My ethernet didn’t work so I had to regenerate a MAC address in network settings under the “Network Adapter” pane in Fusion.
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# update yum yum update yum groupinstall "Development Tools" yum install kernel-devel # vmware tools for guest # http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2075048 curl -O http://packages.vmware.com/tools/keys/VMWARE-PACKAGING-GPG-DSA-KEY.pub curl -O http://packages.vmware.com/tools/keys/VMWARE-PACKAGING-GPG-RSA-KEY.pub rpm --import VMWARE-PACKAGING-GPG-DSA-KEY.pub rpm --import VMWARE-PACKAGING-GPG-RSA-KEY.pub vi /etc/yum.repos.d/vmware-tools.repo # insert this into file [vmware-tools] name = VMware Tools baseurl = http://packages.vmware.com/packages/rhel7/x86_64/ enabled = 1 gpgcheck = 1 # install yum install open-vm-tools-deploypkg # if having problems click install VMWare Tools mkdir /mnt/cdrom mount /dev/cdrom /mnt/cdrom cp /mnt/cdrom/VMwareTools-9.9.0-2304977.tar.gz /tmp cd /tmp tar -C /tmp -zxvf VMwareTools-9.9.0-2304977.tar.gz cd vmware-tools-distrib ./vmware-install.pl # pay close attention to install process. # restart systemctl restart vmtoolsd # check ssh service should be active service sshd status # check firewall service service firewalld status # Set SELinux to permissive mode # Permissive: In Permissive mode, SELinux is enabled but will not enforce the security policy, only warn and log actions. Permissive mode is useful for troubleshooting SELinux issues sed -i -e 's/^SELINUX=.*/SELINUX=permissive/' /etc/selinux/config # add vagrant user useradd vagrant # switch to vagrant user su - vagrant # make ssh directory mkdir -m 0700 -p /home/vagrant/.ssh # grab vagrant authorized_keys curl https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub >> /home/vagrant/.ssh/authorized_keys # make sure permissions are correct for file chmod 600 /home/vagrant/.ssh/authorized_keys # switch back to root exit # important step modifying sudoers comment out requiretty # allows ssh to run sudo commands sed -i 's/^\(Defaults.*requiretty\)/#\1/' /etc/sudoers # allows vagrant to use sudo without password entry echo 'vagrant ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers # clean up yum clean all rm -rf /tmp/* /var/log/wtmp /var/log/btmp history -c shutdown -h now |
Post Configure:
Remove CD/DVD Drive
Click on “Remove CD/DVD Drive”
Creating a Vagrant Box
cd to where your vmware vm is stored usually its ~/Documents/Virtual\ Machines/
My example
0 1 2 |
cd /Volumes/VMs/Vagrant\ CentOS 64-bit\ Minimal.vmwarevm |
Defrag & Shrink virtual disk.
0 1 2 3 4 |
/Applications/VMware\ Fusion.app/Contents/Library/vmware-vdiskmanager -d Virtual\ Disk.vmdk /Applications/VMware\ Fusion.app/Contents/Library/vmware-vdiskmanager -k Virtual\ Disk.vmdk |
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# add metadata file vi metadata.json # add this { "provider": "vmware_fusion" } # remove log files rm -f vmware*.log # finally time to create the box file tar cvzf centos-7.0-x86_64-minimal.vmware.box ./* # once done remove metadata.json file rm -f metadata.json |
Adding Vagrant Box
0 1 2 |
vagrant box add centos-7.0-x86_64-minimal /Volumes/VMs/Vagrant\ CentOS 64-bit\ Minimal.vmwarevm/centos-7.0-x86_64-minimal.vmware.box |
A lof of this is from Thornelabs.