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