Chef "Share This" script

I wrote this little script to upload the current cookbook to the Chef Supermarket.
It should be run from within the cookbook's directory.

#!/bin/bash
knife cookbook site share -o ../ $(basename $(realpath .)) -c ~/.chef/knife-supermarket.rb

Where my supermarket config is as simple as:

node_name 'SUPERMARKET_USERNAME'
client_key 'CLIENTKEY_LOCATION'

Interesting ...

more ...

Cookbook Versioning Script

The Problem

I've always disliked releasing cookbook versions manually. The process requires a lot of bureaucratic steps which are easy to forget and require no thought at all.
Before I had this script, I sometimes avoided modifying the cookbook's version when I only applied "a little fix", losing ...

more ...


Running external Ruby code from Vagrant

The Story

Like a lot of Chef users, I'm using Vagrant for testing my cookbooks. I'm also using Berkshelf for providing the Vagrant box with the cookbooks it needs.
Until recently, I was happy using the ChefDK-provided Berlshelf (v4.0.1). I stopped being happy when running berks ...

more ...


Chef Custom Resources - Missing Documentation

The new Chef documentation for Custom Resources is pretty lackluster.
This is probably because they're too busy making awesome stuff, but I still needed to learn some stuff the hard way.
Thought I'd share them.

The basics

There is no longer a "state-only" resource and an implementing provider ...

more ...

Using a global lock in Chef

The Story

Our dev team is currently using a Snowflake-like ID generation scheme that looks like this:
snowflake diagram
(Diagram by Elad Rosenhim, architect and companion at Dynamic Yield. See his post about distributed keys and how to survive managing an HBase cluster)

Those familiar with MongoDB might notice this structure ...

more ...

Enhancing Packer Templates with eRuby

The Problem

Packer is a great tool for creating machine images, and I'm using it to create EC2 AMIs.
My issue with it is that Packer is using JSON for input, and JSON is very inflexible. For instance, you can't:

  • Write comments (there was an issue open for ...
more ...

Listing Chef Cookbook Licenses

As part of a compliance check for our company, I was required to print the name/version of all FOSS proejcts I'm using.
Most of it was digging around Gemfiles and setup.pys, which isn't that interesting. The neat part was this snippet to extract license ...

more ...

Writing Complex Scripts in HBase Shell

The Story

HBase installations include a shell for running arbitrary commands.
For instance, if you want to view all of your snapshots, you can do something like:

[me@server ~]$ hbase shell
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version ...
more ...