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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.30