Puppet Class: gitolite

Defined in:
manifests/init.pp

Overview

Class: gitolite

This module manages gitolite

Parameters:

user: name of gitolite management user (default "gitolite")
password: HASHED (not plain-text) password of gitolite management user
homedir: home directory of gitolite management user
  *NOTE* repositories are hosted here
version: release tag of desired Gitolite version (default "v2.3")
  can accept version strings, git hashes, or other branches/tags
packages: set this to false if you want to define the necessary packages elsewhere

Actions:

Installs packages to satisfy requirements
Creates source directory (/usr/src/gitolite) and checks out Gitolite repo
Creates gitolite management user (local system user)
Runs gl-system-install command

Requires:

POSIX-compliant sh (attempts to install bash)
git (must be v1.6.6 or later)
perl (must be 5.8 or later)
ssh (client)

Sample Usage:

class {
  "gitolite":
    password => '$1$oqINGwwF$yTik.GEYoKJtEHJBzt/.01';
}
Remember: No empty lines between comments and class definition

Parameters:

  • user (Any) (defaults to: "gitolite")
  • password (Any)
  • homedir (Any) (defaults to: "/var/gitolite")
  • version (Any) (defaults to: "v2.3")
  • packages (Any) (defaults to: true)
[View source]

37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'manifests/init.pp', line 37

class gitolite (
  $user = "gitolite",
  $password,
  $homedir = "/var/gitolite",
  $version = "v2.3",
  $packages = true
) {

  $bashpkg = $operatingsystem ? {
    /(redhat|centos|fedora)/ => "bash",
    /(debian|ubuntu)/        => "bash",
    default                  => "bash"
  }
  $gitpkg = $operatingsystem ? {
    /(redhat|centos|fedora)/ => "git",
    /(debian|ubuntu)/        => "git-core",
    default                  => "git"
  }
  $perlpkg = $operatingsystem ? {
    /(redhat|centos|fedora)/ => "perl",
    /(debian|ubuntu)/        => "perl",
    default                  => "perl"
  }
  $sshpkg = $operatingsystem ? {
    /(redhat|centos|fedora)/ => "openssh-clients",
    /(debian|ubuntu)/        => "openssh-client",
    default                  => "ssh-client"
  }

  $srcdir = "/usr/src/gitolite"

  if $packages {
    Package {
      ensure => "present"
    }

    package {
      $gitolite::bashpkg:
        ;
      $gitolite::gitpkg:
        require => Package[$gitolite::sshpkg];
      $gitolite::perlpkg:
        require => Package[$gitolite::bashpkg];
      $gitolite::sshpkg:
        require => Package[$gitolite::bashpkg];
    }
  }

  group {
    $gitolite::user:
      ensure => "present";
  }


  user {
    $gitolite::user:
      require  => Group[$gitolite::user],
      ensure   => "present",
      comment  => "Gitolite Hosting",
      gid      => "gitolite",
      home     => $gitolite::homedir,
      password => $gitolite::password,
      system   => true;
  }

  file {
    $gitolite::homedir:
      require => User[$gitolite::user],
      ensure  => "directory",
      owner   => $gitolite::user,
      group   => $gitolite::user,
      mode    => 750;
  }

  vcsrepo {
    $gitolite::srcdir:
      provider => "git",
      ensure   => "present",
      source   => "http://github.com/sitaramc/gitolite.git",
      revision => $gitolite::version,
      require  => [
        Package[$gitolite::gitpkg,$gitolite::perlpkg],
        User[$gitolite::user],
        File[$gitolite::homedir]
      ],
      notify => Exec["gl-system-install"];
  }

  exec {
    "gl-system-install":
      require     => Vcsrepo[$gitolite::srcdir],
      command     => "${gitolite::srcdir}/src/gl-system-install /usr/bin ${gitolite::homedir}/conf ${gitolite::homedir}/hooks",
      cwd         => $gitolite::srcdir,
      user        => "root",
      group       => "root",
      logoutput   => "on_failure",
      creates     => "${gitolite::homedir}/conf",
      refreshonly => true;
  }
}