Here's how you can quickly get testing or developing against the cookbook thanks to Vagrant and Berkshelf.
export OPSCODE_USER=""
export AWS_ACCESS_KEY_ID=""
export AWS_SECRET_ACCESS_KEY=""
apt-get install ruby-dev
vagrant plugin install vagrant-berkshelf
vagrant plugin install vagrant-omnibus
vagrant plugin install vagrant-chef-zero
git clone git://github.com/corp/chef-corp.git
cd chef-corp
mkdir -p ./test/integration/default/data_bags/secrets
knife data bag show secrets brain -f json >> ./test/integration/default/data_bags/secrets/brain.json
vagrant up
You can then SSH into the running VM using the vagrant ssh
command.
You can specify the Git Branch to checkout by using BRANCH="test-feature" vagrant up
The VM can easily be stopped and deleted with the vagrant destroy
or vagrant destroy -f
command. Please see the official Vagrant documentation for a more in depth explanation of available commands.
Open up your favorite code editor to: ./src of the directory you checked out the repo. Either use your code editor or the terminal LOCAL to your machine, not the VM to commit code back upstream, the VM only has PULL permissions and does not have your github credentials.
You can connect to the VM in order to run or debug code by doing:
vagrant up
vagrant ssh
vagrant@centos6:~/$ sudo su - corp-brain
corp-brain@centos6:~/$ cd /opt/corp/brain-env/brain
You can then runtests
or braindebug
or workerdebug
these commands are shortcuts for commands such as: /opt/corp/brain-env/bin/env-wrapper.sh /opt/corp/brain-env/bin/python /opt/corp/brain-env/brain/brain.py debug
and make sure you have the correct environment variables loaded when using things like sudo to access privileged ports of 80 or 443.
vagrant up
vagrant ssh
vagrant@centos6:~/$ sudo su - corp-brain
corp-brain@centos6:~/$ cd /opt/corp/brain-env/brain
corp-brain@centos6:~/$ runtests
apt-get install ruby19 ruby19-dev
gem19 install foodcritic
gem19 install test-kitchen
bundle install
bundle exec berks install
BRANCH="test-feature" bundle exec strainer test
BRANCH="test-feature" kitchen test