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 ...

Some Jenkins helpers for Chef

I've decided to share some code I use in Chef to pull some data and files from Jenkins

JenkinsQuery

This is a helper class, in charge of getting build-related data

# slasher_development/libraries/jenkins_query.rb

module SlasherDevelopment
  class JenkinsQuery
    def initialize(server,user,password,job)
      @scheme='https' # Modify if needed ...
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 ...

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 ...

Running Inline DSL in ChefSpec

The Problem

I have a pet Chef cookbook in charge of managing SELinux policies in Linux machines (Take a look).
Until today I got along fine without testing, because the cookbook barely had any logic to be tested. The only test I had (contributed by someone) just made sure the ...

more ...

Generating known_hosts file using Chef

The Story

This post relates to my previous post. I was trying to create a script to amend my known_hosts file (where SSH keeps fingerprints of all of the servers it connected to in the past, to prevent MitM attacks) with SSH keys collected by Chef. This benefits me in ...

more ...