1 |
class git { |
2 |
class common { |
3 |
package { 'git-core': |
4 |
} |
5 |
} |
6 |
|
7 |
class server inherits common { |
8 |
# http://www.kernel.org/pub/software/scm/git/docs/everyday.html#Repository%20Administration |
9 |
$git_base_path = '/git/' |
10 |
|
11 |
xinetd::service { "git": |
12 |
content => template('git/xinetd') |
13 |
} |
14 |
|
15 |
file { "$git_base_path": |
16 |
ensure => directory |
17 |
} |
18 |
|
19 |
# TODO |
20 |
# define common syntax check, see svn |
21 |
# http://stackoverflow.com/questions/3719883/git-hook-syntax-check |
22 |
# proper policy : fast-forward-only |
23 |
# ( http://progit.org/book/ch7-4.html ) |
24 |
# no branch ? |
25 |
# no binary |
26 |
# no big file |
27 |
# no empty commit message |
28 |
# no commit from root |
29 |
# see http://www.itk.org/Wiki/Git/Hooks |
30 |
# automated push to another git repo ( see http://noone.org/blog/English/Computer/VCS/Thoughts%20on%20Gitorious%20and%20GitHub%20plus%20a%20useful%20git%20hook.futile |
31 |
# |
32 |
# how do we handle commit permission ? |
33 |
# mail sending |
34 |
# |
35 |
} |
36 |
|
37 |
define repository($description = '') { |
38 |
# http://eagleas.livejournal.com/18907.html |
39 |
# TODO --shared=group + set g+ws |
40 |
exec { "git init --bare $name": |
41 |
creates => $name, |
42 |
} |
43 |
|
44 |
file { "$name/git-daemon-export-ok": |
45 |
ensure => present, |
46 |
requires => Exec["git init --bare $name"] |
47 |
} |
48 |
|
49 |
file { "$name/description": |
50 |
ensure => present, |
51 |
content => $description |
52 |
} |
53 |
} |
54 |
|
55 |
class client inherits common { |
56 |
|
57 |
|
58 |
} |
59 |
|
60 |
define snapshot($source, $refresh ='*/5', $user = 'root') { |
61 |
include git::client |
62 |
#TODO |
63 |
# should handle branch -> clone -n + branch + checkout |
64 |
# create a script |
65 |
# Idealy, should be handled by vcsrepo https://github.com/bruce/puppet-vcsrepo |
66 |
# once it is merged in puppet |
67 |
exec { "/usr/bin/git clone $source $name": |
68 |
creates => $name, |
69 |
user => $user |
70 |
} |
71 |
|
72 |
cron { "update $name": |
73 |
# FIXME no -q ? |
74 |
command => "cd $name && /usr/bin/git pull", |
75 |
user => $user, |
76 |
minute => $refresh |
77 |
} |
78 |
} |
79 |
} |
80 |
|
81 |
|
82 |
|