John Alberts

Ramblings from a busy devops/sysadmin

New knife-convert Knife Plugin

At my last job, I saw the light a while ago and switched from a monolithic Chef repo to individual repositories per cookbook. In addition, I also stopped using roles and started using role cookbooks. Converting my roles to cookbooks wasn't a huge deal because I mostly used roles as a way of identifying server types and setting a runlist. Most of my roles also didn't have any attributes specified and I didn't have a whole lot of roles. A manual conversion only took an hour or so. This is vastly different from my current job. We have quite a few roles and those roles often have attributes specified and also have enviromental runlists specified. In addition, our environment definitions contain hundreds of default attribute settings.

Manually converting these roles and environments to cookbooks was not an option. So began my search for something to automate the conversion. I happened to come accross a very nice knife plugin called knife-role-convert. It did a great job of converting roles to a recipe; however, it did not support converting environments. There were also some features missing that I needed for creating the new role and environment cookbooks that I needed in the format I wanted to use. Hence, knife-convert was born. It borrows very heavily from the knife-role-convert codebase, but adds a few additional features for converting roles and also adds the ability to convert environments. The plugin doesn't create any files. It instead prints the recipe to stdout. I considered having the plugin directly create a cookbook based on the role or environment file specified; however, I felt this would severely limit the flexability of the plugin and the use cases. Since the output goes to stdout, you can easily redirect the output to any place of your choice and easiliy manipulate the output before writing it to a file. For my use case, I plan to write a wrapper script that will automatically parse my role and environment files, and call the knife plugin to produce the output I need and then redirect that to the appropriate cookbook and recipe structure for my organization. I haven't written the wrapper script yet, hopefully I'll get that done today. :)


knife convert role

knife convert take a single role and spits an equivalent recipe to stdout.

knife convert role ROLE (options)
    -r, --recipe RECIPE              Recipe name you want the role to be ceonverted to
    -C, --comment_enabled            Enable a comment at the top of the generated recipe
    -c, --cookbook COOKBOOK          Cookbook name you want the role to be added to
    -d, --no_default                 Don't output default attributes
    -o, --no_override                Don't output override attributes
    -R, --no_runlist                 Don't output runlist lines

knife convert environment

knife convert takes a single environment and spits an equivalent recipe to stdout.

knife convert environment ENVIRONMENT (options)
    -a, --author Author name         Author name to use in the comment of the generated recipe
    -C, --comment_enabled            Enable a comment at the top of the generated recipe
    -c, --cookbook COOKBOOK          Cookbook name you want the environment to be added to
    -E, --environment ENVIRONMENT    Set the Chef environment
    -d, --no_default                 Don't output default attributes
    -o, --no_override                Don't output override attributes
    -r, --recipe RECIPE              Recipe name you want the environment to be converted to

Docpad working again

So… it's been quite a long time since I posted anything. Since my last post, I no longer work for Exlibris and am now working as a full time Devops consultant at Samsung Music in Palo Alto. Yeah… devops is an overloaded word, oh well. It's short than System Configuration and Automation Engineer or anything else that resembles what I do. ;)
It sucks being away from my home and family in NW Indiana, but at least I'm able to go home and visit every couple of weeks. Hopefully this thing switches to full time remote and I'll be thrilled. I certainly can't complain about the weather out here except maybe to say it's a bit boring. No rain, sunny and ~78F every day.
I've been here for almost a couple months now, so the initial new job learning curve is gone now. I'm finally writing some new Chef cookbooks to get new things done instead of just tweaking or adding small features to existing cookbooks. I'm hoping to find time to write up some blog posts about some of the work I'm doing with Chef and other tools we're using.

Slowly working on my new site

I finally spent a tiny amount of time working on my new docpad site and figured out how to get a tags working how I wanted them. Notice the tag cloud on the side. :) Yeah, it uses inline css. Oh well, it was the quickest way to just get it done.
Now, if I can only find some time to write a post on the EBS cookbook I've been working on…

New Website

I've decided to give Github pages a try, so that meant I needed to give a static website generator a try. I'm using Docpad right now. It seems like it has a lot of cool features and pretty easy to use. This template is pretty nice and was shamelessly borrowed from Ben Delarre's blog.

Always keep your copy of a particular file in a git merge

I found this little gem about how to always keep a particular file untouched during merges. I can think of multiple reasons that you might want to have the same named file in multiple branches of the same repo, while each branch has it's own unique copy of that file. For me, I have a file in a couple branches that I need to have unique information in it that doesn't apply to the other branches. This feature allows me to have a unique in each branch.

    git config '"always keep ours" merge driver'
    git config merge.ours.driver 'touch %A'
    echo " merge=ours" >> .gitattributes
    git add .gitattributes
    git commit -m "keep my copy of the file"

Now, when I do a 'git merge', I don't have to worry about my file getting clobbered.