/[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 942 - (show annotations) (download)
Wed Feb 2 19:38:47 2011 UTC (13 years, 2 months ago) by misc
File size: 3673 byte(s)
draft of a git svn define
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::client
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 clone $options $source $name":
84 creates => $name,
85 }
86
87 cron { "update $name":
88 command => "cd $name && /usr/bin/git svn rebase" ,
89 minute => $refresh
90 }
91 # TODO find a way to prevent commit
92 file { "$name/.git/hooks/pre-receive":
93 ensure => present,
94 owner => root,
95 group => root,
96 mode => 755,
97 content => "#!bin/bash\nfalse"
98 }
99 }
100
101 class client inherits common {
102
103
104 }
105
106 define snapshot($source, $refresh ='*/5', $user = 'root') {
107 include git::client
108 #TODO
109 # should handle branch -> clone -n + branch + checkout
110 # create a script
111 # Idealy, should be handled by vcsrepo https://github.com/bruce/puppet-vcsrepo
112 # once it is merged in puppet
113 exec { "/usr/bin/git clone $source $name":
114 creates => $name,
115 user => $user
116 }
117
118 cron { "update $name":
119 # FIXME no -q ?
120 command => "cd $name && /usr/bin/git pull",
121 user => $user,
122 minute => $refresh
123 }
124 }
125 }
126
127
128

  ViewVC Help
Powered by ViewVC 1.1.30