Puppet Git and Subversion modules

October 29, 2012 at 15:50

Note: this is an english version of the post published by me on Mindfood (OSOCO‘s blog). Si eres un lector español, quizá prefieras echar un vistazo a la entrada en español 🙂 .

Puppet

So we have been working over the last year with puppet, a neat configuration management tool that let’s you automatize software deployment and configuration using a DSL language (instead of using, for example, non cross platform scripts or any other home-coocked tool). Along this time we have written some OSOCO-agnostic modules that have been published in our Github account, so I thought about giving them some publicity 😀 . I’ll start with two of the most simple, puppet-git and puppet-svn, that allow you to checkout and keep up to date repositories from this two popular SCM.

Puppet Git

You can find the source code of this module in its Github repo. It allows you to checkout or update git repos into your servers. A typical case of use would be a web server that need a fresh checkout of the webs it serves when it launchs. You can find an usage example in another puppet module of ours, puppet aws-tools module:

class my_awesome_puppet_class {
    include git
    $path = "/my/existing/aws-tools/path"
    git::clone { "aws-tools-clone":
        url => "https://github.com/osoco/aws-tools.git",
        path => "$path/aws-tools",
        username => "",
        password => "",
    }
    git::pull { "aws-tools-pull":
        path => "$path/aws-tools",
    }
}

As you can see, we define both clone and pull operations. They are clever enough to only execute when it makes sense: clone will only execute when the destination doesn’t exists, and pull only when it does 🙂 . This will keep our copy of the marvelous aws-tools 😀 up to date.

Puppet Subversion

Pretty much the same thing, but using the oldie but goldie Subversion (and for those of you who are wondering – yes, you can use subversion and be cool 😎 ). The source code is also available at Github, and it provides basically the same operations. This example shows a server that checkout a website from :

class awesome_website_configuration {
    include svn
    $document_root = "/var/www/awesome_website"
    svn::checkout { "awesome-website-checkout":
        username => "my-readonly-svn-user",
        password => "someSecretPassword", 
        url => "https://svn.somecompany.org/svn/awesome_web/trunk",
        path => $document_root,
    }
    svn::update { "awesome-website-update":
        username => "my-readonly-svn-user",
        password => "someSecretPassword", 
        path => $document_root,
    }
}

And that would be all. Probably not the most extraordinary modules out there, but useful 🙂 .