/[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 945 - (show annotations) (download)
Wed Feb 2 19:38:53 2011 UTC (13 years, 1 month ago) by misc
File size: 3959 byte(s)
fix the shebang of post-receive
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 content => template('git/create_git_repo.sh')
25 }
26
27
28 # TODO
29 # define common syntax check, see svn
30 # http://stackoverflow.com/questions/3719883/git-hook-syntax-check
31 # proper policy : fast-forward-only
32 # ( http://progit.org/book/ch7-4.html )
33 # no branch ?
34 # no binary
35 # no big file
36 # no empty commit message
37 # no commit from root
38 # see http://www.itk.org/Wiki/Git/Hooks
39 # 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 # mail sending
43 #
44 }
45
46 define repository($description = '',
47 $group ) {
48
49 include git::server
50 # http://eagleas.livejournal.com/18907.html
51 # TODO group permission should be handled here too
52 exec { "/usr/local/bin/create_git_repo.sh $name":
53 user => root,
54 group => $group,
55 creates => $name,
56 }
57
58 file { "$name/git-daemon-export-ok":
59 ensure => present,
60 require => Exec["/usr/local/bin/create_git_repo.sh $name"]
61 }
62
63 file { "$name/description":
64 ensure => present,
65 content => $description,
66 require => File["$name/git-daemon-export-ok"]
67 }
68 }
69
70 define svn_repository($source,
71 $std_layout = true,
72 $refresh = '*/5') {
73 include git::svn
74 include git::server
75 # a cron job
76 # a exec
77 if $std_layout {
78 $options = "-s"
79 } else {
80 $options = " "
81 }
82
83 exec { "/usr/bin/git svn init $options $source $name":
84 alias => "git svn $name",
85 creates => $name,
86 }
87
88 cron { "update $name":
89 # done in 2 times, so fetch can fill the repo after init
90 command => "cd $name && /usr/bin/git svn fetch && /usr/bin/git svn rebase" ,
91 minute => $refresh
92 }
93 # TODO find a way to prevent commit
94 file { "$name/.git/hooks/pre-receive":
95 ensure => present,
96 owner => root,
97 group => root,
98 mode => 755,
99 content => "#!/bin/bash\nfalse",
100 require => Exec["git svn $name"]
101 }
102 }
103
104 class client inherits common {
105
106
107 }
108
109 class svn inherits client {
110 package { "git-svn":
111 ensure => installed
112 }
113 }
114
115 define snapshot($source, $refresh ='*/5', $user = 'root') {
116 include git::client
117 #TODO
118 # should handle branch -> clone -n + branch + checkout
119 # create a script
120 # Idealy, should be handled by vcsrepo https://github.com/bruce/puppet-vcsrepo
121 # once it is merged in puppet
122 exec { "/usr/bin/git clone $source $name":
123 creates => $name,
124 user => $user
125 }
126
127 cron { "update $name":
128 # FIXME no -q ?
129 command => "cd $name && /usr/bin/git pull",
130 user => $user,
131 minute => $refresh
132 }
133 }
134 }
135
136
137

  ViewVC Help
Powered by ViewVC 1.1.30