1 |
misc |
795 |
class git { |
2 |
|
|
class common { |
3 |
|
|
package { 'git-core': |
4 |
|
|
} |
5 |
|
|
} |
6 |
|
|
|
7 |
|
|
class server inherits common { |
8 |
misc |
800 |
# http://www.kernel.org/pub/software/scm/git/docs/everyday.html#Repository%20Administration |
9 |
misc |
796 |
$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 |
misc |
805 |
|
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 |
misc |
796 |
|
27 |
misc |
805 |
|
28 |
misc |
795 |
# TODO |
29 |
|
|
# define common syntax check, see svn |
30 |
misc |
800 |
# http://stackoverflow.com/questions/3719883/git-hook-syntax-check |
31 |
|
|
# proper policy : fast-forward-only |
32 |
|
|
# ( http://progit.org/book/ch7-4.html ) |
33 |
misc |
795 |
# no branch ? |
34 |
|
|
# no binary |
35 |
|
|
# no big file |
36 |
misc |
800 |
# no empty commit message |
37 |
|
|
# no commit from root |
38 |
|
|
# see http://www.itk.org/Wiki/Git/Hooks |
39 |
misc |
795 |
# 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 |
misc |
800 |
# mail sending |
43 |
|
|
# |
44 |
misc |
795 |
} |
45 |
|
|
|
46 |
misc |
806 |
define repository($description = '', |
47 |
|
|
$group ) { |
48 |
|
|
|
49 |
|
|
include git::server |
50 |
misc |
800 |
# http://eagleas.livejournal.com/18907.html |
51 |
misc |
806 |
# TODO group permission should be handled here too |
52 |
|
|
exec { "/usr/local/bin/create_git_repo.sh $name": |
53 |
|
|
user => root, |
54 |
misc |
898 |
group => $group, |
55 |
misc |
797 |
creates => $name, |
56 |
|
|
} |
57 |
misc |
795 |
|
58 |
misc |
798 |
file { "$name/git-daemon-export-ok": |
59 |
|
|
ensure => present, |
60 |
misc |
898 |
require => Exec["/usr/local/bin/create_git_repo.sh $name"] |
61 |
misc |
798 |
} |
62 |
misc |
799 |
|
63 |
|
|
file { "$name/description": |
64 |
|
|
ensure => present, |
65 |
misc |
899 |
content => $description, |
66 |
|
|
require => File["$name/git-daemon-export-ok"] |
67 |
misc |
799 |
} |
68 |
misc |
795 |
} |
69 |
|
|
|
70 |
|
|
class client inherits common { |
71 |
|
|
|
72 |
|
|
|
73 |
|
|
} |
74 |
|
|
|
75 |
|
|
define snapshot($source, $refresh ='*/5', $user = 'root') { |
76 |
|
|
include git::client |
77 |
|
|
#TODO |
78 |
|
|
# should handle branch -> clone -n + branch + checkout |
79 |
|
|
# create a script |
80 |
|
|
# Idealy, should be handled by vcsrepo https://github.com/bruce/puppet-vcsrepo |
81 |
|
|
# once it is merged in puppet |
82 |
|
|
exec { "/usr/bin/git clone $source $name": |
83 |
|
|
creates => $name, |
84 |
|
|
user => $user |
85 |
|
|
} |
86 |
|
|
|
87 |
|
|
cron { "update $name": |
88 |
|
|
# FIXME no -q ? |
89 |
|
|
command => "cd $name && /usr/bin/git pull", |
90 |
|
|
user => $user, |
91 |
|
|
minute => $refresh |
92 |
|
|
} |
93 |
|
|
} |
94 |
|
|
} |
95 |
|
|
|
96 |
|
|
|
97 |
|
|
|