Skip to content

Instantly share code, notes, and snippets.

View mlafeldt's full-sized avatar

Mathias Lafeldt mlafeldt

View GitHub Profile
@mlafeldt
mlafeldt / notes.md
Last active December 31, 2015 03:39
Notes on SOA in Web Operations

Service-Oriented Architecture (SOA) [WEBOPS, pp. 67-69]

  • each system component is broken up into network-accessible services, which are integrated to make a functioning application
  • allows to create ever more flexible, powerful infra with less overhead and time
  • developers become free to compose new apps from network primitives, resulting in easy reuse, clear encapsulation, and simpler troubleshooting
  • core competency of Web 2.0 companies
  • SOA principles that apply to infra as code:
  • modular: small and simple services that do one thing (well)
  • cooperative: services exposed via network APIs encourage cooperation and become more useful, can hand off work to other services
  • composable: compose modularized services to automate infra as required
@mlafeldt
mlafeldt / plugin.list
Created December 11, 2013 16:03
Vagrant 1.4.0 w/ and w/o plugins
$ vagrant plugin list
vagrant-cachier (0.5.0)
vagrant-omnibus (1.1.2)
@mlafeldt
mlafeldt / gist:7772628
Created December 3, 2013 16:44
test-kitchen 1.0 + serverspec 0.13 fuckup
-----> Running serverspec test suite
/opt/chef/embedded/bin/ruby -I/tmp/busser/suites/serverspec -S /opt/chef/embedded/bin/rspec /tmp/busser/suites/serverspec/default_spec.rb --color --format documentation
1
skeleton::default
installs sample package (FAILED - 1)
does something (FAILED - 2)
Failures:
1) skeleton::default installs sample package
@mlafeldt
mlafeldt / gist:7631064
Created November 24, 2013 19:10
Ask VirtualBox for current SSH port of a Vagrant machine
machine_name=default
machine_id=$(cat ".vagrant/machines/$machine_name/virtualbox/id")
ssh_port=$(VBoxManage showvminfo "$machine_id" --machinereadable | grep ^Forwarding | head -n1 | cut -d, -f4)
echo $ssh_port
@mlafeldt
mlafeldt / env.rb
Created November 15, 2013 15:24
Aruba shims
require "cucumber"
require "aruba/cucumber"
# Add shims to PATH
SHIMS = "#{Dir.pwd}/tmp/aruba/shims"
ENV['PATH'] = "#{SHIMS}:#{ENV['PATH']}"
def generate_shims_for(commands)
FileUtils.mkdir_p(SHIMS)
commands.each do |cmd|
@mlafeldt
mlafeldt / pipefail.sh
Created November 8, 2013 10:25
pipefail example
[tmp]$ bash
[tmp]$ set -e
[tmp]$ (exit 10) | cat -
[tmp]$ echo $?
0
[tmp]$ set -o pipefail
[tmp]$ (exit 10) | cat -
[tmp]$ echo $?
10
@mlafeldt
mlafeldt / Vagrantfile
Created October 23, 2013 14:46
Vagrantfile which loads Chef attributes from a JSON file
# If you want to provide custom Chef attributes that should not end up in Git
# (e.g. secret tokens), copy `chef.json.example` to `chef.json` and edit the
# latter accordingly (in that case, the example file will be ignored).
# ...
# Configure Chef Solo provisioner
config.vm.provision :chef_solo do |chef|
# Tell Vagrant where the cookbooks are located
chef.cookbooks_path = "vendor/cookbooks"
@mlafeldt
mlafeldt / create-release.rb
Last active March 13, 2017 01:45
Accessing GitHub Releases API with Ruby -- http://developer.github.com/v3/repos/releases/
require "net/https"
require "json"
gh_token = ENV.fetch("GITHUB_TOKEN")
gh_user = ARGV.fetch(0)
gh_repo = ARGV.fetch(1)
release_name = ARGV.fetch(2)
release_desc = ARGV[3]
uri = URI("https://api.github.com")
@mlafeldt
mlafeldt / Vagrantfile
Last active December 23, 2015 07:09
Install Chef 11 with Vagrant's shell provisioner
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu-12.04"
config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/precise/current/precise-server-cloudimg-amd64-vagrant-disk1.box"
# Install Chef version 11
config.vm.provision :shell, :inline => <<EOS
set -e
if ! command -V chef-solo >/dev/null 2>/dev/null; then
curl -L https://www.opscode.com/chef/install.sh | bash -s -- -v 11.6.0
fi
@mlafeldt
mlafeldt / Vagrantfile
Created September 6, 2013 11:42
Provision a VM with Vagrant that can run the Cucumber scenarios in the current folder
# vi: set ft=ruby :
# Install Cucumber and dependencies, and run scenarios.
$script = <<SCRIPT
set -e -x
test -f /var/lib/apt/periodic/update-success-stamp || sudo apt-get update -y
sudo apt-get install -y update-notifier-common ruby rubygems ruby-bundler git
bundle install --gemfile=/vagrant/Gemfile
cd /vagrant
bundle exec rake features