/[adm]/puppet/modules/git/manifests/init.pp
ViewVC logotype

Contents of /puppet/modules/git/manifests/init.pp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1860 - (show annotations) (download)
Tue Jul 19 23:19:39 2011 UTC (12 years, 10 months ago) by misc
File size: 5531 byte(s)
add a class to make a git mirror ( for gitweb )
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 source => 'puppet:///modules/git/create_git_repo.sh',
25 }
26
27 file { "/usr/local/bin/apply_git_puppet_config.sh":
28 ensure => present,
29 owner => root,
30 group => root,
31 mode => 755,
32 source => 'puppet:///modules/git/apply_git_puppet_config.sh',
33 }
34
35
36 # TODO
37 # define common syntax check, see svn
38 # http://stackoverflow.com/questions/3719883/git-hook-syntax-check
39 # proper policy : fast-forward-only
40 # ( http://progit.org/book/ch7-4.html )
41 # no branch ?
42 # no binary
43 # no big file
44 # no empty commit message
45 # no commit from root
46 # see http://www.itk.org/Wiki/Git/Hooks
47 # 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
48 #
49 # how do we handle commit permission ?
50 # mail sending
51 #
52 }
53
54 define repository($description = '',
55 $group ) {
56
57 include git::server
58 # http://eagleas.livejournal.com/18907.html
59 # TODO group permission should be handled here too
60 exec { "/usr/local/bin/create_git_repo.sh $name":
61 user => root,
62 group => $group,
63 creates => $name,
64 }
65
66 file { "$name/git-daemon-export-ok":
67 ensure => present,
68 require => Exec["/usr/local/bin/create_git_repo.sh $name"]
69 }
70
71 file { "$name/description":
72 ensure => present,
73 content => $description,
74 require => File["$name/git-daemon-export-ok"]
75 }
76
77 file { "$name/hooks/post-receive":
78 ensure => present,
79 owner => root,
80 group => root,
81 mode => 755,
82 content => template('git/post-receive'),
83 require => File["$name/git-daemon-export-ok"]
84 }
85
86 file { "$name/config.puppet":
87 ensure => present,
88 require => File["$name/git-daemon-export-ok"],
89 notify => Exec["/usr/local/bin/apply_git_puppet_config.sh $name"],
90 content => template('git/config.puppet'),
91 }
92
93 # $name is not really used, but this prevent duplicate declaration error
94 exec { "/usr/local/bin/apply_git_puppet_config.sh $name":
95 cwd => $name,
96 user => "root",
97 refreshonly => true
98 }
99 }
100
101 define mirror($source,
102 $refresh = '*/5') {
103
104 exec { "/usr/bin/git clone $source $name":
105 alias => "git mirror $name",
106 creates => $name,
107 }
108
109 cron { "update $name":
110 command => "/usr/bin/git pull $name" ,
111 minute => $refresh
112 }
113 }
114
115 define svn_repository($source,
116 $std_layout = true,
117 $refresh = '*/5') {
118 include git::svn
119 include git::server
120 # a cron job
121 # a exec
122 if $std_layout {
123 $options = "-s"
124 } else {
125 $options = " "
126 }
127
128 exec { "/usr/bin/git svn init $options $source $name":
129 alias => "git svn $name",
130 creates => $name,
131 }
132
133 file { "/usr/local/bin/update_git_svn.sh":
134 ensure => present,
135 owner => root,
136 group => root,
137 mode => 755,
138 source => 'puppet:///modules/git/update_git_svn.sh',
139 }
140
141 cron { "update $name":
142 # done in 2 times, so fetch can fill the repo after init
143 command => "/usr/local/bin/update_git_svn.sh $name" ,
144 minute => $refresh
145 }
146
147 file { "$name/.git/hooks/pre-receive":
148 ensure => present,
149 owner => root,
150 group => root,
151 mode => 755,
152 content => template('git/pre-receive'),
153 require => Exec["git svn $name"]
154 }
155 }
156
157 class client inherits common {
158
159
160 }
161
162 class svn inherits client {
163 package { "git-svn":
164 ensure => installed
165 }
166 }
167
168 define snapshot($source, $refresh ='*/5', $user = 'root') {
169 include git::client
170 #TODO
171 # should handle branch -> clone -n + branch + checkout
172 # create a script
173 # Idealy, should be handled by vcsrepo https://github.com/bruce/puppet-vcsrepo
174 # once it is merged in puppet
175 exec { "/usr/bin/git clone $source $name":
176 creates => $name,
177 user => $user
178 }
179
180 cron { "update $name":
181 # FIXME no -q ?
182 command => "cd $name && /usr/bin/git pull",
183 user => $user,
184 minute => $refresh
185 }
186 }
187 }
188
189
190

  ViewVC Help
Powered by ViewVC 1.1.30