[nycbug-talk] Code Deployment Question

Jared Brothers brothers at logn.org
Wed Jun 24 11:52:44 EDT 2009


On Tue, Jun 23, 2009 at 5:56 PM, Matt Juszczak<matt at atopia.net> wrote:
> Hi all,
>
> I have to do some code deployment to about 20 webservers as a temporary
> solution.  We're running puppet which works fine for config file
> management (with SVN to store the config files), but I'm trying to figure
> out the code deployment.

> Snip

Here is what I came up with, let me know what you think.  I have
developers create a tag for the version they want deployed.  My
subversion::workingcopy resource does a check out if it hasn't done so
and switches to the latest tag when I change the $branch variable.  I
use iClassify to set variables, but tmtowtdi and ymmv.  Using a
working copy rather than an export leaves .svn directories lying
around, but Apache is configured to hide them with 404s.

# modules/subversion/manifests/init.pp
class subversion {
    package { subversion:
        ensure => installed,
    }
}
define subversion::workingcopy ($repourl, $branch, $copydir) {
    include subversion
    file { "$copydir":
        owner => apache, group => apache, mode => 755,
        ensure => directory,
    }
    # initial check out
    exec { "svnco-$name":
        command => "/usr/bin/svn co --non-interactive $repourl/$branch
$copydir/$name",
        creates => "$copydir/$name/.svn",
        require => [Package[subversion], File["$copydir"]],
    }
    # switch branches
    exec { "svnswitch-$name":
        command => "/usr/bin/svn switch --non-interactive
$repourl/$branch $copydir/$name",
        unless => "/usr/bin/svn info $copydir/$name|/bin/grep -q
'URL:.*$branch\$'",
        require => [Package[subversion], File["$copydir"], Exec["svnco-$name"]],
    }
}

# web-foo.pp
class web-foo {
    if $branch {
        subversion::workingcopy { foo:
            repourl => 'http://svn.example.com/foo/tags',
            branch => "$branch",
            copydir => '/www/foo',
        }
    }
}

-- 
Thanks,
Jared Brothers



More information about the talk mailing list