Current CentOS Version Used: 7.4 (1708)
This example build configuration installs and configures CentOS 7 x86_64 minimal using Ansible, and then generates a Vagrant box file for VirtualBox.
The example can be modified to use more Ansible roles, plays, and included playbooks to fully configure (or partially) configure a box file suitable for deployment for development environments.
The following software must be installed/present on your local machine before you can use Packer to build the Vagrant box file:
- Packer
- Vagrant
- VirtualBox (if you want to build the VirtualBox box)
- Ansible
Make sure all the required software (listed above) is installed, then cd to the directory containing this README.md file, and run:
$ packer build -var 'version=1.2.0' centos7.json
After a few minutes, Packer should tell you the box was generated successfully, and the box was uploaded to Vagrant Cloud.
There's an included Vagrantfile that allows quick testing of the built Vagrant boxes. From this same directory, run one the following command after building the box:
$ vagrant up
To configure NFS, Vagrant must modify system files on the host. Therefore, at some point during the vagrant up sequence, you may be prompted for administrative privileges (via the typical sudo program). These privileges are used to modify /etc/exports as well as to start and stop the NFS server daemon.
If you do not want to type your password on every vagrant up, Vagrant uses thoughtfully crafted commands to make fine-grained sudoers modifications possible to avoid entering your password.
For OS X, sudoers should have this entry:
Cmnd_Alias VAGRANT_EXPORTS_ADD = /usr/bin/tee -a /etc/exports Cmnd_Alias VAGRANT_NFSD = /sbin/nfsd restart Cmnd_Alias VAGRANT_EXPORTS_REMOVE = /usr/bin/sed -E -e /*/ d -ibak /etc/exports %admin ALL=(root) NOPASSWD: VAGRANT_EXPORTS_ADD, VAGRANT_NFSD, VAGRANT_EXPORTS_REMOVE
MIT license.