Skip to content

Instantly share code, notes, and snippets.

@masutaka
Last active October 20, 2015 18:18
Show Gist options
  • Save masutaka/2adfc24c8c220be292ea to your computer and use it in GitHub Desktop.
Save masutaka/2adfc24c8c220be292ea to your computer and use it in GitHub Desktop.
CI of Chef recipes using CircleCI + Vagrant + AWS + serverspec
dependencies:
cache_directories:
- ~/.vagrant.d
- ~/tmp
pre:
- |
mkdir -p ~/tmp
cd ~/tmp
VERSION=1.7.2
if [ ! -f vagrant_${VERSION}_x86_64.deb ]; then
wget https://dl.bintray.com/mitchellh/vagrant/vagrant_${VERSION}_x86_64.deb
fi
sudo dpkg -i vagrant_${VERSION}_x86_64.deb
- |
if ! vagrant plugin list | fgrep -q vagrant-aws; then
vagrant plugin install vagrant-aws
fi
test:
pre:
- vagrant up ec2
- vagrant ssh-config --host=ec2 ec2 >> ~/.ssh/config
- cp nodes/masutaka.net.json nodes/ec2.json
- bundle exec knife solo bootstrap ec2
override:
- bundle exec rake spec:ec2
post:
- vagrant destroy -f ec2
deployment:
production:
branch: master
commands:
- sed -i -e "/^Host masutaka\.net$/a User masutaka" ~/.ssh/config
- bundle exec knife solo cook masutaka.net
- bundle exec rake spec:masutakanet
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define :local do |local|
local.vm.box = "ubuntu/trusty64"
local.vm.network "private_network", ip: "192.168.50.13"
local.ssh.forward_agent = true
local.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", "2048"]
end
local.cache.scope = :box if Vagrant.has_plugin? 'vagrant-cachier'
end
config.vm.define :ec2, autostart: false do |ec2|
ec2.vm.box = 'dummy'
ec2.vm.box_url = 'https://raw.githubusercontent.com/mitchellh/vagrant-aws/master/dummy.box'
ec2.vm.synced_folder '.', '/vagrant', disabled: true
ec2.vm.provider :aws do |aws, override|
aws.access_key_id = ENV['AWS_ACCESS_KEY_ID']
aws.secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
aws.region = 'us-east-1'
aws.instance_type = 't2.micro'
aws.ami = 'ami-9eaa1cf6'
aws.security_groups = ['default']
aws.keypair_name = 'virginia'
aws.tags = { 'Name' => 'vagrant' }
override.ssh.username = 'ubuntu'
override.ssh.private_key_path = '~/.ssh/id_virginia'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment