aboutsummaryrefslogtreecommitdiffstats
path: root/modules/git/manifests/init.pp
diff options
context:
space:
mode:
authorMichael Scherer <misc@mageia.org>2012-03-15 22:55:12 +0000
committerMichael Scherer <misc@mageia.org>2012-03-15 22:55:12 +0000
commitbb97ef6499e5ec31064e260645a1a01abc73d886 (patch)
treea1a877a0ed4827e7be10e0afa9dbee326726f4e5 /modules/git/manifests/init.pp
parent256365022c30c836e6df619d53a9cdbb7814542e (diff)
downloadpuppet-bb97ef6499e5ec31064e260645a1a01abc73d886.tar
puppet-bb97ef6499e5ec31064e260645a1a01abc73d886.tar.gz
puppet-bb97ef6499e5ec31064e260645a1a01abc73d886.tar.bz2
puppet-bb97ef6499e5ec31064e260645a1a01abc73d886.tar.xz
puppet-bb97ef6499e5ec31064e260645a1a01abc73d886.zip
clean git module, and some partial splitting
Diffstat (limited to 'modules/git/manifests/init.pp')
-rw-r--r--modules/git/manifests/init.pp132
1 files changed, 23 insertions, 109 deletions
diff --git a/modules/git/manifests/init.pp b/modules/git/manifests/init.pp
index 5b1ef9ed..50aa8d72 100644
--- a/modules/git/manifests/init.pp
+++ b/modules/git/manifests/init.pp
@@ -1,107 +1,21 @@
class git {
- class common {
- package { 'git-core': }
- }
-
- class server inherits common {
- # http://www.kernel.org/pub/software/scm/git/docs/everyday.html#Repository%20Administration
- $git_base_path = '/git/'
-
- xinetd::service { "git":
- content => template('git/xinetd')
- }
-
- file { "$git_base_path":
- ensure => directory
- }
-
- file { "/usr/local/bin/create_git_repo.sh":
- mode => 755,
- source => 'puppet:///modules/git/create_git_repo.sh',
- }
-
- file { "/usr/local/bin/apply_git_puppet_config.sh":
- mode => 755,
- source => 'puppet:///modules/git/apply_git_puppet_config.sh',
- }
-
-
- # TODO
- # define common syntax check, see svn
- # http://stackoverflow.com/questions/3719883/git-hook-syntax-check
- # proper policy : fast-forward-only
- # ( http://progit.org/book/ch7-4.html )
- # no branch ?
- # no binary
- # no big file
- # no empty commit message
- # no commit from root
- # see http://www.itk.org/Wiki/Git/Hooks
- # 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
- #
- # how do we handle commit permission ?
- # mail sending
- #
- }
-
- define repository($description = '',
- $group ) {
-
- include git::server
- # http://eagleas.livejournal.com/18907.html
- # TODO group permission should be handled here too
- exec { "/usr/local/bin/create_git_repo.sh $name":
- user => root,
- group => $group,
- creates => $name,
- }
-
- file { "$name/git-daemon-export-ok":
- require => Exec["/usr/local/bin/create_git_repo.sh $name"]
- }
-
- file { "$name/description":
- content => $description,
- require => File["$name/git-daemon-export-ok"]
- }
-
- file { "$name/hooks/post-receive":
- mode => 755,
- content => template('git/post-receive'),
- require => File["$name/git-daemon-export-ok"]
- }
-
- file { "$name/config.puppet":
- require => File["$name/git-daemon-export-ok"],
- notify => Exec["/usr/local/bin/apply_git_puppet_config.sh $name"],
- content => template('git/config.puppet'),
- }
-
- # $name is not really used, but this prevent duplicate declaration error
- exec { "/usr/local/bin/apply_git_puppet_config.sh $name":
- cwd => $name,
- user => "root",
- refreshonly => true
- }
- }
-
define mirror($source,
$description,
$refresh = '*/5') {
exec { "/usr/bin/git clone --bare $source $name":
- alias => "git mirror $name",
+ alias => "git mirror $name",
creates => $name,
- before => File["$name/description"],
+ before => File["$name/description"],
}
-
+
file { "$name/description":
content => $description,
}
cron { "update $name":
command => "cd $name ; /usr/bin/git fetch -q",
- minute => $refresh
+ minute => $refresh
}
}
@@ -113,30 +27,30 @@ class git {
# a cron job
# a exec
if $std_layout {
- $options = "-s"
+ $options = '-s'
} else {
- $options = " "
+ $options = ''
}
exec { "/usr/bin/git svn init $options $source $name":
- alias => "git svn $name",
+ alias => "git svn $name",
creates => $name,
}
-
- file { "/usr/local/bin/update_git_svn.sh":
- mode => 755,
- source => 'puppet:///modules/git/update_git_svn.sh',
+
+ file { '/usr/local/bin/update_git_svn.sh':
+ mode => '0755',
+ source => 'puppet:///modules/git/update_git_svn.sh',
}
cron { "update $name":
# done in 2 times, so fetch can fill the repo after init
command => "/usr/local/bin/update_git_svn.sh $name" ,
- minute => $refresh
+ minute => $refresh
}
file { "$name/.git/hooks/pre-receive":
- mode => 755,
- content => template('git/pre-receive'),
+ mode => '0755',
+ content => template('git/pre-receive'),
require => Exec["git svn $name"]
}
}
@@ -147,26 +61,26 @@ class git {
}
class svn inherits client {
- package { "git-svn": }
+ package { 'git-svn': }
}
define snapshot($source, $refresh ='*/5', $user = 'root') {
include git::client
#TODO
- # should handle branch -> clone -n + branch + checkout
- # create a script
- # Idealy, should be handled by vcsrepo https://github.com/bruce/puppet-vcsrepo
- # once it is merged in puppet
+ # should handle branch -> clone -n + branch + checkout
+ # create a script
+ # Idealy, should be handled by vcsrepo https://github.com/bruce/puppet-vcsrepo
+ # once it is merged in puppet
exec { "/usr/bin/git clone $source $name":
creates => $name,
- user => $user
+ user => $user
}
-
+
cron { "update $name":
# FIXME no -q ?
command => "cd $name && /usr/bin/git pull",
- user => $user,
- minute => $refresh
+ user => $user,
+ minute => $refresh
}
}
}