Skip to content

Instantly share code, notes, and snippets.

@tknerr
tknerr / install.sh
Last active December 22, 2015 01:39
slightly modified version of https://www.opscode.com/chef/install.sh which downloads the installer to `/var/chef/cache/` so it will be cached by `vagrant-cachier` (see fgrehm/vagrant-cachier#13)
#!/bin/bash
# This is the current stable release to default to, with Omnibus patch level (e.g. 10.12.0-1)
# Note that the chef template downloads 'x.y.z' not 'x.y.z-r' which should be a duplicate of the latest -r
use_shell=0
prerelease="false"
# Check whether a command exists - returns 0 if it does, 1 if it does not
exists() {
#!/bin/bash
# This is the current stable release to default to, with Omnibus patch level (e.g. 10.12.0-1)
# Note that the chef template downloads 'x.y.z' not 'x.y.z-r' which should be a duplicate of the latest -r
use_shell=0
prerelease="false"
# Check whether a command exists - returns 0 if it does, 1 if it does not
exists() {
@tknerr
tknerr / lock_deps_in_metadata.rb
Created October 4, 2013 22:55
transforms `Berksfile.lock`ed dependencies to `metadata.rb` depends statements
#!/bin/ruby
require 'json'
# parse locked dependencies
json = JSON.parse(`berks list -F json`)
# transform them to metadata.rb format
deps = json['cookbooks'].map { |cb| %Q(depends "#{cb['name']}", "#{cb['version']}") }
# output for copy/paste to metadata
@tknerr
tknerr / AlternativeBarBean.java
Created December 13, 2013 22:08
Using annotation-based Java EE Dependency Injection with selective override via ejb-jar.xml deployment descriptor with GlassFish 3.1.2.2 Files: * FooBean, which depends on a Bar * BarBean, which is the default implementation of a Bar * AlternativeBarBean is the Bar that should be used * ejb-jar.xml overrides the default Bar in FooBean with the A…
package com.acme;
/**
* alternative implementation of Bar, provided by com.acme, will be packaged alongside org.sample
*
* mappedName is required here, see http://stackoverflow.com/questions/7443306/javaee-6-javax-naming-namealreadyboundexception-use-rebind-to-override
*/
@Stateless(mappedName = "AlternativeBarBean")
public class AlternativeBarBean implements Bar {
...
@tknerr
tknerr / disqussion
Created January 26, 2014 12:33
Restored comments from DISQUS discussion about the environment cookbook pattern: http://vialstudios.logdown.com/posts/166848-the-environment-cookbook-pattern
--------------------------------
Torben Knerr • 19 days ago
Nice post! Finally some clarification on the different interpretations of what an application, library or wrapper cookbook is :-)
I have one question about the environment cookbooks though: what if you have two different applications (e.g. my_face and your_face) requiring a different set of dependencies running in the same environment?
IMHO locking dependency versions and exposing the public recipes / attributes via metadata.rb is a great thing, but it should be doable on a finer-grained basis than environments, namely on a per application (e.g. my_face) basis. For this exact reason I'm not using chef environments to lock the dependency versions, but rather something like an "uber application cookbook" which combines the properties of an application cookbook and the locking and documentation of an environment cookbook.
What do you think? And what would be a good name for it?
@tknerr
tknerr / install.sh
Last active August 29, 2015 13:56
Latest https://www.opscode.com/chef/install.sh (25/02/2013) with modifications to make it play nicely with vagrant-cachier #13
#!/bin/sh
# WARNING: REQUIRES /bin/sh
#
# - must run on /bin/sh on solaris 9
# - must run on /bin/sh on AIX 6.x
# - if you think you are a bash wizard, you probably do not understand
# this programming language. do not touch.
# - if you are under 40, get peer review from your elders.
#
# Author:: Tyler Cloke ([email protected])
@tknerr
tknerr / Teaser.md
Last active August 29, 2015 14:01
Vagrant / Chef Workshop Teaser

Vagrant / Chef Workshop

This DevOps / Infrastructure-As-Code with #Vagrant and #Chef workshop is all about automation, configuration management and being able to spin up everything from single servers to whole infrastructures at the push of a button.

Why?

Because your infrastructure should be:

  • reliably and repeatedly reproducible
  • described in a human readable DSL
@tknerr
tknerr / chef-vagrant-codebox.sh
Last active August 29, 2015 14:02
Additional setup to make a codebox.io Ruby box (Ubuntu 12.10) ready for Chef / Vagrant development
# show system info
cat /etc/lsb-release
uname -a
# set locale to UTF-8
locale -a
export LANG=C.UTF-8
export LC_ALL=C.UTF-8
# TMP is unset, makes vagrant use . instead
@tknerr
tknerr / Berksfile
Last active February 6, 2017 15:19
Sample metadata.rb which reads its dependencies from Berksfile.lock. This is meant for use in "top-level cookbooks" only (~= "environment cookbook" pattern but using metadata rather than environments for locking deps)
source "https://supermarket.chef.io"
# manage direct dependencies here in Berksfile
cookbook "apache2", "1.10.4"
# dependency on self
cookbook "my-app", path: "."
@tknerr
tknerr / log
Last active August 29, 2015 14:02
debug output of running `vagrant up --debug &> log` for github issue https://github.com/fgrehm/vagrant-lxc/issues/290
INFO global: Vagrant version: 1.6.3
INFO global: Ruby version: 2.0.0
INFO global: RubyGems version: 2.0.14
INFO global: VAGRANT_EXECUTABLE="/opt/vagrant/bin/../embedded/gems/gems/vagrant-1.6.3/bin/vagrant"
INFO global: VAGRANT_INSTALLER_EMBEDDED_DIR="/opt/vagrant/bin/../embedded"
INFO global: VAGRANT_INSTALLER_VERSION="2"
INFO global: VAGRANT_DETECTED_OS="Linux"
INFO global: VAGRANT_INSTALLER_ENV="1"
INFO global: VAGRANT_INTERNAL_BUNDLERIZED="1"
INFO global: VAGRANT_LOG="debug"