1 |
misc |
795 |
class git { |
2 |
misc |
1860 |
define mirror($source, |
3 |
misc |
1866 |
$description, |
4 |
misc |
1860 |
$refresh = '*/5') { |
5 |
|
|
|
6 |
misc |
1870 |
exec { "/usr/bin/git clone --bare $source $name": |
7 |
misc |
2500 |
alias => "git mirror $name", |
8 |
misc |
1860 |
creates => $name, |
9 |
misc |
2500 |
before => File["$name/description"], |
10 |
misc |
1860 |
} |
11 |
misc |
2500 |
|
12 |
misc |
1866 |
file { "$name/description": |
13 |
|
|
content => $description, |
14 |
|
|
} |
15 |
misc |
1860 |
|
16 |
|
|
cron { "update $name": |
17 |
misc |
1878 |
command => "cd $name ; /usr/bin/git fetch -q", |
18 |
misc |
2500 |
minute => $refresh |
19 |
misc |
1860 |
} |
20 |
|
|
} |
21 |
|
|
|
22 |
misc |
942 |
define svn_repository($source, |
23 |
|
|
$std_layout = true, |
24 |
|
|
$refresh = '*/5') { |
25 |
misc |
943 |
include git::svn |
26 |
misc |
942 |
include git::server |
27 |
|
|
# a cron job |
28 |
|
|
# a exec |
29 |
|
|
if $std_layout { |
30 |
misc |
2500 |
$options = '-s' |
31 |
misc |
942 |
} else { |
32 |
misc |
2500 |
$options = '' |
33 |
misc |
942 |
} |
34 |
|
|
|
35 |
misc |
944 |
exec { "/usr/bin/git svn init $options $source $name": |
36 |
misc |
2500 |
alias => "git svn $name", |
37 |
misc |
942 |
creates => $name, |
38 |
|
|
} |
39 |
misc |
2500 |
|
40 |
|
|
file { '/usr/local/bin/update_git_svn.sh': |
41 |
|
|
mode => '0755', |
42 |
|
|
source => 'puppet:///modules/git/update_git_svn.sh', |
43 |
misc |
947 |
} |
44 |
|
|
|
45 |
misc |
942 |
cron { "update $name": |
46 |
misc |
944 |
# done in 2 times, so fetch can fill the repo after init |
47 |
misc |
947 |
command => "/usr/local/bin/update_git_svn.sh $name" , |
48 |
misc |
2500 |
minute => $refresh |
49 |
misc |
942 |
} |
50 |
misc |
947 |
|
51 |
misc |
942 |
file { "$name/.git/hooks/pre-receive": |
52 |
misc |
2500 |
mode => '0755', |
53 |
|
|
content => template('git/pre-receive'), |
54 |
misc |
944 |
require => Exec["git svn $name"] |
55 |
misc |
942 |
} |
56 |
|
|
} |
57 |
|
|
|
58 |
misc |
795 |
class client inherits common { |
59 |
|
|
|
60 |
|
|
|
61 |
|
|
} |
62 |
|
|
|
63 |
misc |
943 |
class svn inherits client { |
64 |
misc |
2500 |
package { 'git-svn': } |
65 |
misc |
943 |
} |
66 |
|
|
|
67 |
misc |
795 |
define snapshot($source, $refresh ='*/5', $user = 'root') { |
68 |
|
|
include git::client |
69 |
|
|
#TODO |
70 |
misc |
2500 |
# should handle branch -> clone -n + branch + checkout |
71 |
|
|
# create a script |
72 |
|
|
# Idealy, should be handled by vcsrepo https://github.com/bruce/puppet-vcsrepo |
73 |
|
|
# once it is merged in puppet |
74 |
misc |
795 |
exec { "/usr/bin/git clone $source $name": |
75 |
|
|
creates => $name, |
76 |
misc |
2500 |
user => $user |
77 |
misc |
795 |
} |
78 |
misc |
2500 |
|
79 |
misc |
795 |
cron { "update $name": |
80 |
|
|
# FIXME no -q ? |
81 |
|
|
command => "cd $name && /usr/bin/git pull", |
82 |
misc |
2500 |
user => $user, |
83 |
|
|
minute => $refresh |
84 |
misc |
795 |
} |
85 |
|
|
} |
86 |
|
|
} |