1 |
class git { |
2 |
class common { |
3 |
package { 'git-core': |
4 |
} |
5 |
} |
6 |
|
7 |
class server inherits common { |
8 |
$git_base_path = '/git/' |
9 |
|
10 |
xinetd::service { "git": |
11 |
content => template('git/xinetd') |
12 |
} |
13 |
|
14 |
file { "$git_base_path": |
15 |
ensure => directory |
16 |
} |
17 |
|
18 |
# TODO |
19 |
# define common syntax check, see svn |
20 |
# proper policy : no-fast-forward |
21 |
# no branch ? |
22 |
# no binary |
23 |
# no big file |
24 |
# no empty commit message, no root |
25 |
# 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 |
26 |
# |
27 |
# how do we handle commit permission ? |
28 |
} |
29 |
|
30 |
define repository { |
31 |
exec { "git init --bare $name": |
32 |
creates => $name, |
33 |
} |
34 |
|
35 |
file { "$name/git-daemon-export-ok": |
36 |
ensure => present, |
37 |
requires => Exec["git init --bare $name"] |
38 |
} |
39 |
} |
40 |
|
41 |
class client inherits common { |
42 |
|
43 |
|
44 |
} |
45 |
|
46 |
define snapshot($source, $refresh ='*/5', $user = 'root') { |
47 |
include git::client |
48 |
#TODO |
49 |
# should handle branch -> clone -n + branch + checkout |
50 |
# create a script |
51 |
# Idealy, should be handled by vcsrepo https://github.com/bruce/puppet-vcsrepo |
52 |
# once it is merged in puppet |
53 |
exec { "/usr/bin/git clone $source $name": |
54 |
creates => $name, |
55 |
user => $user |
56 |
} |
57 |
|
58 |
cron { "update $name": |
59 |
# FIXME no -q ? |
60 |
command => "cd $name && /usr/bin/git pull", |
61 |
user => $user, |
62 |
minute => $refresh |
63 |
} |
64 |
} |
65 |
} |
66 |
|
67 |
|
68 |
|