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 |
file { "/usr/local/bin/create_git_repo.sh": |
20 |
ensure => present, |
21 |
owner => root, |
22 |
group => root, |
23 |
mode => 755, |
24 |
content => template('git/create_git_repo.sh') |
25 |
} |
26 |
|
27 |
|
28 |
# TODO |
29 |
# define common syntax check, see svn |
30 |
# http://stackoverflow.com/questions/3719883/git-hook-syntax-check |
31 |
# proper policy : fast-forward-only |
32 |
# ( http://progit.org/book/ch7-4.html ) |
33 |
# no branch ? |
34 |
# no binary |
35 |
# no big file |
36 |
# no empty commit message |
37 |
# no commit from root |
38 |
# see http://www.itk.org/Wiki/Git/Hooks |
39 |
# 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 |
40 |
# |
41 |
# how do we handle commit permission ? |
42 |
# mail sending |
43 |
# |
44 |
} |
45 |
|
46 |
define repository($description = '') { |
47 |
# http://eagleas.livejournal.com/18907.html |
48 |
# TODO --shared=group + set g+ws |
49 |
exec { "git init --bare $name": |
50 |
creates => $name, |
51 |
} |
52 |
|
53 |
file { "$name/git-daemon-export-ok": |
54 |
ensure => present, |
55 |
requires => Exec["git init --bare $name"] |
56 |
} |
57 |
|
58 |
file { "$name/description": |
59 |
ensure => present, |
60 |
content => $description |
61 |
} |
62 |
} |
63 |
|
64 |
class client inherits common { |
65 |
|
66 |
|
67 |
} |
68 |
|
69 |
define snapshot($source, $refresh ='*/5', $user = 'root') { |
70 |
include git::client |
71 |
#TODO |
72 |
# should handle branch -> clone -n + branch + checkout |
73 |
# create a script |
74 |
# Idealy, should be handled by vcsrepo https://github.com/bruce/puppet-vcsrepo |
75 |
# once it is merged in puppet |
76 |
exec { "/usr/bin/git clone $source $name": |
77 |
creates => $name, |
78 |
user => $user |
79 |
} |
80 |
|
81 |
cron { "update $name": |
82 |
# FIXME no -q ? |
83 |
command => "cd $name && /usr/bin/git pull", |
84 |
user => $user, |
85 |
minute => $refresh |
86 |
} |
87 |
} |
88 |
} |
89 |
|
90 |
|
91 |
|