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

Managing AWS Security Groups with Piculet

The Problem

One of the first things I noticed when starting to work with AWS is that security groups are very hard to maintain:

  • Name and description are immutable - One can't modify the name/description of a Security Group after it's created
  • Groups contain magical constants - There is ...
more ...

Chef Snippets

I thought I'd upload some interesting Chef-related snippets I accumulated.

Chef Shell

chef-shell is an easy way to gain the context of a Chef client.
I mainly use it to debug recipes by executing little bits of them in the shell.

As client

If you're running it on ...

more ...


Migrating Graphite's Dashboards

I just made a small script to migrate dashboards between two graphite servers.
Couldn't find a similar one anywhere, so I thought I'd upload it.
Note it's using http for its HTTP calls. It looks real nice.

old_server='http://old.server.com:1234'
new_server='http://better.server ...
more ...

Preparing Certificate files for Nginx

The Story

When installing SSL certificates for nginx, assuming you're using certificate hierarchy (and not a self-signed ceritificate), you're required to concatenate all of the certificate files (*.crt) to a single file, starting from your site's certificate up to the root certificate.
Today I got this bundle ...

more ...

Managing EC2 reservations with Scripts

The Story

Since we tend to hold our AWS EC2 VMs for a long time, we usually reserve them.
Reservations are like pre-buying instances - you pay AWS ahead of time for (let's say) a year, and get a discounted price.
The insterestng thing about EC2 reservations is that they ...

more ...

Appending Newline to File Ends with Ruby

I recently took over managing some config files from my dev colleagues. I was extremely annoyed to be reminded that Notepad (Windows' text editor) does 2 major Unix-incompatible things:

  1. CRLF line ending (\r\n and not \n)
  2. No newline at the end of file, which is something of a nicety ...
more ...

Managing chef users with Chef

I needed to create seperate Chef accounts for some utility program running in my Chef server.
I was finally able to deprecate it today, but I saved those snippets because they're neat. These snippets use chef-server-ctl, which is a utility software included in Chef server's installation

The bits ...

more ...