/[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 947 - (show 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 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 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 cron { "update $name":
97 # done in 2 times, so fetch can fill the repo after init
98 command => "/usr/local/bin/update_git_svn.sh $name" ,
99 minute => $refresh
100 }
101
102 file { "$name/.git/hooks/pre-receive":
103 ensure => present,
104 owner => root,
105 group => root,
106 mode => 755,
107 content => template('git/pre-receive'),
108 require => Exec["git svn $name"]
109 }
110 }
111
112 class client inherits common {
113
114
115 }
116
117 class svn inherits client {
118 package { "git-svn":
119 ensure => installed
120 }
121 }
122
123 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