Tag Archives: puppet

FUDCon Blacksburg: sysadminSG, Fedora Infrastructure, pam_otp and more!

Well, FUDCon Blacksburg has come and gone. I believe it was the most productive I’ve been at a FUDCon EVER! I was able to get quite a bit accomplished and much more than I had planned!

What was it that I did, you ask? Well let me tell you all of the tasks I was able to complete.

System Administration Study Group

Over the past year, I’ve been working on a way to do a regular free study group for those who want to improve their system administration skills, get certified, or just brush up on something they didn’t quite understand.

Enter sysadminSG, a self-guided tour of many of the standard tasks any system administrator should know. The main goal was to create an instance of a Fedora 14 machine for studiers to use.

Some of the tasks on the study sheets indicate certain issues that would need to be resolved which can’t be resolved without a ‘master’ instance. I was able to recruit a couple of excellent individuals to help get this further than I thought it would. Jon Stanley and Ivan Makfinsky helped put together many of the pieces which will help studiers get more done. Specifically, an ldap server for centralized authentication and iscsi target luns for use with LUKS encryption, LVM and disk partitioning.

Fedora Infrastructure

I attended the Fedora Infrastructure session, where we covered two major things of concern. One was removing the puppet staging branch and moving everything into ‘Production’. This is a mental shift for many, but makes sense because in truth, everything maintained from an infrastructure perspective is production.

Additionally, a longer term plan of being able to spin up ‘staging’ environments for any new things that will go into production looks to be the direction we’ll be going. Many of the applications we have in Fedora require some work to get us to this point, mostly so they can be more atomic pieces. I think a proof of concept environment will provide us with an good idea of how much work will be involved.

pam_otp

After the Fedora Infrastructure hackfest, there was a two-factor authentication hackfest. We discussed using Yubikeys and a unique PIN together for authentication within Fedora. The initial goal was determined to setup sudo authentication for sysadmin-main group with two-factor authentication.

Nathaniel McCallum found the pam_otp library and was able to get it to compile. He passed it on to me to test and document it, which I was able to get working after a drunk night by the fire. I was then able to document the usage of it and have a test rpm that we’ll be using.

All in all, it was a very productive weekend and more work will be getting done over the next few weeks as well. It’s all very exciting and fun, a really good reason for attending FUDCon!

Cheers,

Herlo

Git Hooks: Making the awesomest RCS ever even better!

Over the past month or so, I’ve been really digging into git.  It’s quite the revision control system (RCS) and has some seriously awesome tools to do just about anything with your data.  My latest project has been around my semi-new job at Backcountry.com as a Senior Linux Administrator.  Essentially, my entire job right now is to automate and make our infrastructure idempotent.  I am tasked with setting up cobbler, puppet, koji and other tools that will make our infrastructure more agile and scalable.

To do this, I’ve been using a centralized git repository using gitosis and gitweb.  Because it’s behind the Backcountry firewalls, there is no easy way to share our repository data.  However, there are some great git repos at github, which I highly recommend.

Anyway, we do the hub-and-spoke model with our git repositories.  Meaning that we have a central repository where much of the data is stored so everyone can get access.  Of course, though, most people clone these repositories and work on the code where they choose.  Because we have several people pushing puppet data to our repository, which has been on subversion until 2 weeks ago, I am keen on making sure the puppet code we push to the central repo is at least syntactically valid.

Git Hooks: The skinny

Essentially, the key here is to understand is that git, like many other popular revision control systems is distributed.  This means that many people keep repos locally and push to the central repository after many many commits (or just one or two).  Git keeps the history in a clean way and all of the commits are pushed and tracked.  Essentially, we need some way to validate the data coming in from an outside source.  Enter git hooks.

There are several git hooks, but three that are quite critical to this scenario; pre-commit, pre-receive and post-receive.

The first, pre-commit is specific to the repository where the commit is taking place, such that a validation of the puppet syntax here is useful to help the person writing the puppet rules.

Next is post-receive which is generally useful for sending out emails after a successful push.  It would list the files and the diff of each in an email to those who wish to know about the commit.

And finally, the least documented of the bunch; the one with the least amount of examples, pre-receive.  The pre-receive hook has some really awesome power, but without knowing the git commands backward and forward, it can be very frustrating to get working.

The value of the pre-receive hook

Whenever a push is made to the centralized repository, you don’t just want to let any willy nilly commit crawl in there.  You can’t trust that the author of the commits did his part to validate the code.  So you need to at least do some basic checks.  That is what the pre-receive hook does.  In the following example, I am parsing files that end in ‘.pp’ with puppet syntax validation as you would do from the command line.

#!/bin/bash

while read old_sha1 new_sha1 refname anothervalue ; do
    list=$(git show --pretty="format:" --name-only $new_sha1 | grep -e ".pp$")
    for tmpfile in ${list}; do
        git show ${new_sha1}:${tmpfile} | puppet --color=false --confdir=/tmp --vardir=/tmp --parseonly --ignoreimport
        if [ "$?" -ne "0" ]; then exit 1; fi
    done
done

exit $?

The above script, placed in a bare repository at hooks/pre-receive with the execute (+x) bit turned on, will get a list of files that end in ‘.pp’ and run the puppet validator for the newest commit in the push.  Essentially, I can validate someone else’s puppet code in just a few seconds and return a failure if it doesn’t succeed.  With git hooks, a failure means no commit/push/etc will actually happen.

I sure hope this helps someone else to understand pre-receive hooks as well as git hooks in general.  If you have any helpful suggestions or comments, those are most welcome as well.

Cheers,

Herlo

Cancelled: SLLUG Daytime SIG: Basics of Puppet cancelled

At about 11pm last night, our presenter sent me a message indicating that there were some unresolvable conflicts and I wanted to get the word out that today’s meeting has been cancelled.  I’ll be up at the Salt Lake Public Library to hang out and chat for an hour about whatever you all want, but there will be no presentation.

I apologize for the last minute notice.  I’m hoping to have the Basics of Puppet presentation next month.

Cheers,

Herlo

Meeting: SLLUG Daytime SIG – May 13, 11:30am-1pm, Basics of Puppet

Presentation: Basics of Puppet
Presenter: Andrew Shafer

Next Wednesday, May 13 is the next SLLUG Daytime SIG meeting.  We’ll be getting a great presentation on Puppet from Andrew Shafer of Reductive Labs.  Andrew is a full-time Puppet developer and has been demonstrating the value of puppet for some time.  He lives here in Salt Lake and is excited to show the basics of Puppet.

What is Puppet?  (for the curious and uninitiated)

Puppet is an open-source next-generation server automation tool. It is composed of a declarative language for expressing system configuration, a client and server for distributing it, and a library for realizing the configuration.

More information is available here: http://reductivelabs.com/trac/puppet/wiki/FrequentlyAskedQuestions

———————————————————————————-

We meet in conference room A on the lower level of the Salt Lake Library.  Head down the stairs, make a left turn.  The conference room  is directly under the foyer area (the area with all the shops on the 1st level)  If you aren’t clear, ask the information desk.

Also, our meetings should be posted on the Electric Signs by the entrance to the library on the first floor.

Cheers,

Herlo