This post is a supplement to Cookbooks 101 in AWS OpsWorks documentation to prepare a Mac OSX to test Chef recipes for OpsWorks using the following tools:
Installing Vagrant, VirtualBox and Chef Development Kit
Download the latest Vagrant, VirtualBox and Che Development Kit from the above links and install them. They can be installed by double clicking the downloaded dmg package of each tool. An installation window will appear similar to the screenshots below. Double click each package and follow the on-screen instructions to complete the installation.
Installing Vagrant Plugins
From Terminal, execute the following commands to install plugins to integrate with Berfshelf and Omnibus respectively:
sudo vagrant plugin install vagrant-berkshelf
sudo vagrant plugin install vagrant-omnibus
Vagrant Berkshelf automatically downloads and installs cookbooks into Vagrant Virtual Machines.
Vagrant Omibus automatically installs the desired version of Chef via the platform-specific Omnibus packages into Vagrant Virtual Machines.
It may prompt you to install Command Line Developer Tools if you don’t have the tools. Proceed to install the tools and re-run vagrant plugin install commands to install vagrant-berkshelf and vagrant-omibus plugins.
Adjusting DHCP Option for VirtualBox
VirtualBox comes with a default DHCP server that set to the following:
$ VBBoxManage list dhcpservers
However, vboxnet0 is set to a different IP adddress space when it is created:
$ VBoxManage list hostonlyifs
In order to reconcile the conflict, execute the following command from Terminal to remove the default DHCP server:
VBoxManage dhcpserver remove --netname HostInterfaceNetworking-vboxnet0
Adjusting VCS files for Berkshelf
If you plan to use git, you may encounter a permission denied error while running vagrant provision:
stderr: /opt/chefdk/embedded/lib/ruby/2.1.0/fileutils.rb:1402:in `initialize': Permission denied @ rb_sysopen - /home/schen/.berkshelf/vagrant-berkshelf/shelves/berkshelf20150223-20325-2b14d0l-default/test_vm/.git/objects/01/6f2ce56a1eff7451b477a2b52a16ed288117da (Errno::EACCES)
from /opt/chefdk/embedded/lib/ruby/2.1.0/fileutils.rb:1402:in `open'
If it happens, add ‘**/.git’ to the EXCLUDED_VCS_FILES_WHEN_VENDORING in the /opt/chefdk/embedded/apps/berkshelf/lib/berkshelf/berksfile.rb to instruct Berkshelf to ignore git’s metadata which is stored in the .git folder.
Installing AWS Command Line Interface
If you are planning to interact with Amazon Web Services , you will need to install AWS Command Line Interface (AWC CLI). It can be installed using pip. If your Mac OSX does not have pip, download get-pip.py from https://pip.pypa.io/en/latest/installing.html and execute the following command from Terminal to install pip:
Once pip is installed, execute the following command from Terminal to install AWS Command Line Interface:
pip install awscli
Configuring AWS Command Line Interface
Execute the following command from Terminal, it will prompt you to enter your AWS profile information:
If you have multiple profiles, edit ~/.aws/credentials directly. Refer to AWS Official Documentation for more details.