diff options
Diffstat (limited to 'modules/git')
| -rw-r--r-- | modules/git/files/apply_git_puppet_config.sh | 2 | ||||
| -rw-r--r-- | modules/git/files/create_git_repo.sh | 3 | ||||
| -rw-r--r-- | modules/git/manifests/client.pp | 3 | ||||
| -rw-r--r-- | modules/git/manifests/common.pp | 3 | ||||
| -rw-r--r-- | modules/git/manifests/init.pp | 173 | ||||
| -rw-r--r-- | modules/git/manifests/mirror.pp | 20 | ||||
| -rw-r--r-- | modules/git/manifests/server.pp | 37 | ||||
| -rw-r--r-- | modules/git/manifests/snapshot.pp | 24 | ||||
| -rw-r--r-- | modules/git/manifests/svn.pp | 4 | ||||
| -rw-r--r-- | modules/git/manifests/svn_repository.pp | 35 | ||||
| -rw-r--r-- | modules/git/templates/xinetd | 4 |
11 files changed, 131 insertions, 177 deletions
diff --git a/modules/git/files/apply_git_puppet_config.sh b/modules/git/files/apply_git_puppet_config.sh index 29ede998..1ed6fbf1 100644 --- a/modules/git/files/apply_git_puppet_config.sh +++ b/modules/git/files/apply_git_puppet_config.sh @@ -4,4 +4,4 @@ while read line do # --local is a option for the newer git git config --add $line -done < config.puppet +done < config.puppet diff --git a/modules/git/files/create_git_repo.sh b/modules/git/files/create_git_repo.sh index 1104edbe..144d063b 100644 --- a/modules/git/files/create_git_repo.sh +++ b/modules/git/files/create_git_repo.sh @@ -1,6 +1,6 @@ #!/bin/bash umask 0002 -# http://eagleas.livejournal.com/18907.html +# https://eagleas.livejournal.com/18907.html name="$1" mkdir -p $name cd $name @@ -8,4 +8,3 @@ git --bare init --shared=group chmod g+ws branches info objects refs ( cd objects; chmod g+ws * ) git config receive.denyNonFastForwards true - diff --git a/modules/git/manifests/client.pp b/modules/git/manifests/client.pp new file mode 100644 index 00000000..2ba50721 --- /dev/null +++ b/modules/git/manifests/client.pp @@ -0,0 +1,3 @@ +class git::client { + include git::common +} diff --git a/modules/git/manifests/common.pp b/modules/git/manifests/common.pp new file mode 100644 index 00000000..ed8ebbdf --- /dev/null +++ b/modules/git/manifests/common.pp @@ -0,0 +1,3 @@ +class git::common { + package { 'git-core': } +} diff --git a/modules/git/manifests/init.pp b/modules/git/manifests/init.pp index 5b1ef9ed..dece14f0 100644 --- a/modules/git/manifests/init.pp +++ b/modules/git/manifests/init.pp @@ -1,172 +1 @@ -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", - creates => $name, - before => File["$name/description"], - } - - file { "$name/description": - content => $description, - } - - cron { "update $name": - command => "cd $name ; /usr/bin/git fetch -q", - minute => $refresh - } - } - - define svn_repository($source, - $std_layout = true, - $refresh = '*/5') { - include git::svn - include git::server - # a cron job - # a exec - if $std_layout { - $options = "-s" - } else { - $options = " " - } - - exec { "/usr/bin/git svn init $options $source $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', - } - - 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 - } - - file { "$name/.git/hooks/pre-receive": - mode => 755, - content => template('git/pre-receive'), - require => Exec["git svn $name"] - } - } - - class client inherits common { - - - } - - class svn inherits client { - 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 - exec { "/usr/bin/git clone $source $name": - creates => $name, - user => $user - } - - cron { "update $name": - # FIXME no -q ? - command => "cd $name && /usr/bin/git pull", - user => $user, - minute => $refresh - } - } -} +class git { } diff --git a/modules/git/manifests/mirror.pp b/modules/git/manifests/mirror.pp new file mode 100644 index 00000000..f7364846 --- /dev/null +++ b/modules/git/manifests/mirror.pp @@ -0,0 +1,20 @@ +define git::mirror( $source, + $description, + $refresh = '*/5') { + + include git::common + exec { "/usr/bin/git clone --mirror ${source} ${name}": + alias => "git mirror ${name}", + creates => $name, + before => File["${name}/description"], + } + + file { "${name}/description": + content => $description, + } + + cron { "update ${name}": + command => "cd ${name} ; /usr/bin/git fetch -q", + minute => $refresh + } +} diff --git a/modules/git/manifests/server.pp b/modules/git/manifests/server.pp new file mode 100644 index 00000000..3f07ed9c --- /dev/null +++ b/modules/git/manifests/server.pp @@ -0,0 +1,37 @@ +class git::server { + include git::common + + $git_base_path = '/git/' + + xinetd::service { 'git': + content => template('git/xinetd') + } + + file { '/usr/local/bin/create_git_repo.sh': + mode => '0755', + source => 'puppet:///modules/git/create_git_repo.sh', + } + + file { '/usr/local/bin/apply_git_puppet_config.sh': + mode => '0755', + source => 'puppet:///modules/git/apply_git_puppet_config.sh', + } + + + # TODO + # define common syntax check, see svn + # https://stackoverflow.com/questions/3719883/git-hook-syntax-check + # proper policy : fast-forward-only + # ( https://progit.org/book/ch7-4.html ) + # no branch ? + # no binary + # no big file + # no empty commit message + # no commit from root + # see https://www.itk.org/Wiki/Git/Hooks + # automated push to another git repo ( see https://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 + # +} diff --git a/modules/git/manifests/snapshot.pp b/modules/git/manifests/snapshot.pp new file mode 100644 index 00000000..06473efe --- /dev/null +++ b/modules/git/manifests/snapshot.pp @@ -0,0 +1,24 @@ +define git::snapshot( $source, + $refresh = '*/5', + $user = 'root', + $branch = 'master') { + include git::client + #TODO + # should handle branch -> clone -n + branch + checkout + # create a script + # Ideally, should be handled by vcsrepo + # https://github.com/bruce/puppet-vcsrepo + # once it is merged in puppet + exec { "/usr/bin/git clone -b ${branch} ${source} ${name}": + creates => $name, + user => $user + } + + if ($refresh != '0') { + cron { "update ${name}": + command => "cd ${name} && /usr/bin/git pull -q && /usr/bin/git submodule --quiet update --init --recursive", + user => $user, + minute => $refresh + } + } +} diff --git a/modules/git/manifests/svn.pp b/modules/git/manifests/svn.pp new file mode 100644 index 00000000..43df012b --- /dev/null +++ b/modules/git/manifests/svn.pp @@ -0,0 +1,4 @@ +class git::svn { + include git::client + package { 'git-svn': } +} diff --git a/modules/git/manifests/svn_repository.pp b/modules/git/manifests/svn_repository.pp new file mode 100644 index 00000000..ea215ce6 --- /dev/null +++ b/modules/git/manifests/svn_repository.pp @@ -0,0 +1,35 @@ +define git::svn_repository( $source, + $std_layout = true, + $refresh = '*/5') { + include git::svn + include git::server + # a cron job + # a exec + if $std_layout { + $options = '-s' + } else { + $options = '' + } + + exec { "/usr/bin/git svn init ${options} ${source} ${name}": + alias => "git svn ${name}", + creates => $name, + } + + 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 + } + + file { "${name}/.git/hooks/pre-receive": + mode => '0755', + content => template('git/pre-receive'), + require => Exec["git svn ${name}"] + } +} diff --git a/modules/git/templates/xinetd b/modules/git/templates/xinetd index 2cbf78e3..654ae2be 100644 --- a/modules/git/templates/xinetd +++ b/modules/git/templates/xinetd @@ -4,10 +4,10 @@ service git type = UNLISTED port = 9418 socket_type = stream - server = <%= lib_dir %>/git-core/git-daemon + server = <%= @lib_dir %>/git-core/git-daemon wait = no user = nobody - server_args = --inetd --verbose --export-all --base-path=<%= git_base_path %> + server_args = --inetd --verbose --export-all --base-path=<%= @git_base_path %> log_on_failure += HOST flags = IPv6 } |
