Skip to content

Instantly share code, notes, and snippets.

@hartmantis
hartmantis / spec_helper.rb
Last active November 15, 2017 15:50
ChefSpec stubs for testing a recipe in isolation
require 'chefspec'
module SpecHelper
def global_stubs
# Don't worry about external cookbook dependencies
Chef::Cookbook::Metadata.any_instance.stub(:depends)
# Test each recipe in isolation, regardless of includes
@included_recipes = []
Chef::RunContext.any_instance.stub(:loaded_recipe?).and_return(false)
...
let(:object) { Testing::Test.new }
let(:run_command) { stub(:stdout => 'Some string') }
let(:shellout) { stub(:run_command => run_command) }
it 'shells out' do
Mixlib::ShellOut.stub(:new).and_return(shellout)
expect(object.shellout).to eq('Some string')
end
...
$ rake acceptance
/usr/local/Cellar/ruby/1.9.3-p194/bin/ruby -S bundle exec cucumber --color --format progress --strict --tags ~@wip
/usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/community-zero-2.0.1/lib/community_zero/server.rb:33: warning: already initialized constant DEFAULT_OPTIONS
............F...F-....F-...............................F-..................F-...................................................................................
(::) failed steps (::)
expected "ERROR Cli: Stove experienced an error!\nERROR Cli: RuntimeError\nERROR Cli: can't modify frozen String\nERROR Cli: /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/1.9.1/rubygems/version.rb:191:in `strip!'\n/usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/1.9.1/rubygems/version.rb:191:in `initialize'\n/Users/jhartman/GitHubRepos/stove/lib/stove/actions/bump.rb:11:in `new'\n/Users/jhartman/GitHubRepos/stove/lib/stove/actions/bump.rb:11:in `block in <class:Bump>'\n/Users/jhartman/GitHubRepos/stove/lib/stove/validator.rb:55:in `instance_
$ cat CHANGELOG.md
hello-world CHANGELOG
=====================
v0.1.0 (2013-01-16)
-------------------
- Initial release
$ bake 0.2.0 --changelog
@hartmantis
hartmantis / docker_defaults
Created April 29, 2014 03:07
Docker + Nginx Proxying
# Docker Upstart and SysVinit configuration file
# Customize location of Docker binary (especially for development testing).
#DOCKER="/usr/local/bin/docker"
# Use DOCKER_OPTS to modify the daemon startup options.
#DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"
DOCKER_OPTS="-D -H 127.0.0.1:8081 -H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock"
# If you need Docker to use an HTTP proxy, it can also be specified here.
@hartmantis
hartmantis / keybase.md
Created August 13, 2014 19:58
keybase.md

Keybase proof

I hereby claim:

  • I am roboticcheese on github.
  • I am roboticcheese (https://keybase.io/roboticcheese) on keybase.
  • I have a public key whose fingerprint is 8079 F045 1CD2 1B5D 0AA4 96DC 68B6 627A 5469 DC49

To claim this, I am signing this object:

A simple `ls` command.
Auditd:
type=SYSCALL msg=audit(1443472662.093:768): arch=c000003e syscall=59 success=yes exit=0 a0=100f788 a1=ef0688 a2=fe0808 a3=7fff2f4cc550 items=2 ppid=18368 pid=19531 auid=900 uid=900 gid=900 euid=900 suid=900 fsuid=900 egid=900 sgid=900 fsgid=900 ses=5 tty=pts1 comm="ls" exe="/bin/ls" key=(null)
type=EXECVE msg=audit(1443472662.093:768): argc=2 a0="ls" a1="--color=auto"
type=CWD msg=audit(1443472662.093:768): cwd="/home/vagrant"
type=PATH msg=audit(1443472662.093:768): item=0 name="/bin/ls" inode=1308212 dev=fc:00 mode=0100755 ouid=0 ogid=0 rdev=00:00 nametype=NORMAL
type=PATH msg=audit(1443472662.093:768): item=1 name=(null) inode=2093204 dev=fc:00 mode=0100755 ouid=0 ogid=0 rdev=00:00 nametype=NORMAL
</code>
@hartmantis
hartmantis / .kitchen.yml
Created December 22, 2015 18:56
Chef DK / DMG Test
---
driver:
name: vagrant
provisioner:
name: chef_zero
platforms:
- name: macosx-10.10
ssh:
@hartmantis
hartmantis / arraytest1_attributes_default.rb
Created January 20, 2016 21:03
Chef array attributes
default['arraytest'] = %w(thing1 thing2 thing3)
@hartmantis
hartmantis / ignition.cfg
Last active July 25, 2020 02:45
Testing CoreOS Ignition
{
"ignition": {
"version": "3.0.0"
},
"passwd": {
"users": [
{
"name": "core",
"sshAuthorizedKeys": [
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDJYbBdotWTaTn0B/5pOQR1pyJaA4cWEOrAaXQiOBhopOyGv7D6btqVCwNzJxkCQjn8sGqt3UV7+S2GqMkaLU0Thj09/lgAylayR1HnYk1ButAtAEj7G5A15ZnP0wHIKh64dD+p/fI69NAIRZKgdBygS27qxU5JF0oJlnX7dFv1MKBVFRmaPIl3/g3bM54Cg6KWRdy1QkpxCE7XacN0B+7khR8/Iox8eke/zj39D/Qrw34kwCmrhHouqmzOCm5UNNlb+Ea9FzcZjyLPhpLqd2bi2aLne6qpA9b3LvRuXZi8u5Bb/B4jgDtIcrOvLlx+/KIS9KWzClRr08S1NtAm+Ev5"