Create a gist now

Instantly share code, notes, and snippets.

Sample configuration files for a test-kitchen setup based on vagrant-lxc and chef-zero.
---
driver_plugin: vagrant
provisioner: chef_zero
driver_config:
require_chef_omnibus: 11.6.0
http_proxy: http://10.0.3.1:8123
https_proxy: https://10.0.3.1:8123
provider: lxc
platforms:
- name: ubuntu-12.04
driver_config:
box: ubuntu-12.04
box_url: file:///some/where/sensible/vagrant-lxc-precise.box
suites:
- name: default
run_list:
- recipe[minitest-handler]
- recipe[my_sample::default]
data_bags_path: ../../data_bags
attributes: {}
metadata
cookbook 'minitest-handler', github: 'btm/minitest-handler-cookbook'
#!/bin/bash
# based on http://fabiorehm.com/blog/2013/07/18/crafting-your-own-vagrant-lxc-base-box/
export RELEASE=precise
BASEDIR=`pwd`
TARGETDIR=$BASEDIR/base_boxes
mkdir -p /tmp/vagrant-lxc-${RELEASE}
cd /var/lib/lxc/${RELEASE}-base
sudo tar --numeric-owner -czf /tmp/vagrant-lxc-${RELEASE}/rootfs.tar.gz ./rootfs/*
cd /tmp/vagrant-lxc-${RELEASE}
sudo chown $USER:`id -gn` rootfs.tar.gz
wget https://raw.github.com/fgrehm/vagrant-lxc/master/boxes/common/lxc-template
wget https://raw.github.com/fgrehm/vagrant-lxc/master/boxes/common/lxc.conf
wget https://raw.github.com/fgrehm/vagrant-lxc/master/boxes/common/metadata.json
chmod +x lxc-template
tar -czf $TARGETDIR/vagrant-lxc-${RELEASE}.box *
cd $BASEDIR
sudo rm -fr /tmp/vagrant-lxc-${RELEASE}
# cookbooks/my_sample/files/default/test/foo_test.rb
require 'minitest/spec'
describe_recipe 'my_sample::foo' do
include ::Chef::DSL::DataQuery
describe 'application user setup' do
it 'adds the "foo" user' do
user('foo').must_exist
end
it 'allows any active developer to login as application user' do
file('/home/foo/.ssh/authorized_keys').must_exist
search(:users, 'groups:developer AND NOT action:remove').each do |user|
file('/home/foo/.ssh/authorized_keys').must_include user[:ssh_keys]
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment