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

  ViewVC Help
Powered by ViewVC 1.1.30