From 52f6c79d82018d96f1609f8c6c47e9d156d26893 Mon Sep 17 00:00:00 2001 From: mh Date: Thu, 14 May 2009 20:13:36 +0200 Subject: splitted everything up in one file per class/define --- manifests/base.pp | 5 +++ manifests/clone.pp | 37 +++++++++++++++++ manifests/defines.pp | 90 ------------------------------------------ manifests/init.pp | 8 ---- manifests/web/repo.pp | 31 +++++++++++++++ manifests/web/repo/lighttpd.pp | 19 +++++++++ 6 files changed, 92 insertions(+), 98 deletions(-) create mode 100644 manifests/base.pp create mode 100644 manifests/clone.pp delete mode 100644 manifests/defines.pp create mode 100644 manifests/web/repo.pp create mode 100644 manifests/web/repo/lighttpd.pp (limited to 'manifests') diff --git a/manifests/base.pp b/manifests/base.pp new file mode 100644 index 0000000..06742a7 --- /dev/null +++ b/manifests/base.pp @@ -0,0 +1,5 @@ +class git::base { + package{'git': + ensure => present, + } +} diff --git a/manifests/clone.pp b/manifests/clone.pp new file mode 100644 index 0000000..bfc8082 --- /dev/null +++ b/manifests/clone.pp @@ -0,0 +1,37 @@ +define git::clone( + $ensure = present, + $git_repo, + $projectroot, + $cloneddir_user='root', + $cloneddir_group='0', + $cloneddir_restrict_mode=true +){ + case $ensure { + absent: { + exec{"rm -rf $projectroot": + onlyif => "test -d $projectroot", + } + } + default: { + include git + exec {"git-clone_${name}": + command => "git-clone --no-hardlinks ${git_repo} ${projectroot}", + creates => "${projectroot}/.git", + user => root, + require => Package['git'], + notify => Exec["git-clone-chown_${name}"], + } + exec {"git-clone-chown_${name}": + command => "chown -R ${cloneddir_user}:${cloneddir_group} ${projectroot}", + refreshonly => true + } + if $cloneddir_restrict_mode { + exec {"git-clone-chmod_${name}": + command => "chmod -R o-rwx ${projectroot}", + refreshonly => true, + subscribe => Exec["git-clone_${name}"], + } + } + } + } +} diff --git a/manifests/defines.pp b/manifests/defines.pp deleted file mode 100644 index d32f948..0000000 --- a/manifests/defines.pp +++ /dev/null @@ -1,90 +0,0 @@ -# domain: the domain under which this repo will be avaiable -# projectroot: where the git repos are listened -# projects_list: which repos to export -define git::web::repo( - $projectroot, - $projects_list, - $sitename='absent' -){ - include git::web - $gitweb_url = $name - case $gitweb_sitename { - 'absent': { $gitweb_sitename = "${name} git repository" } - default: { $gitweb_sitename = $sitename } - } - $gitweb_config = "/etc/gitweb.d/${name}.conf" - file{"${gitweb_config}": - content => template("git/web/config") - } - case $gitweb_webserver { - 'lighttpd': { - git::web::repo::lighttpd{$name: - gitweb_url => $gitweb_url, - projectroot => $projectroot, - projects_list => $projects_list, - gitweb_config => $gitweb_config, - } - } - default: { fail("no supported \$gitweb_webserver defined on ${fqdn}, so can't do git::web::repo: ${name}") } - } - -} - -define git::web::repo::lighttpd( - $gitweb_url, - $projectroot, - $projects_list, - $gitweb_config -){ - include git::web::lighttpd - file{"/etc/lighttpd/gitweb.d/${name}.conf": - content => template("git/web/lighttpd"), - notify => Service['lighttpd'], - owner => root, group => 0, mode => 0644; - } - line{"add_include_of_gitwebrepo_${name}": - line => "include \"gitweb.d/${name}.conf\"", - file => "/etc/lighttpd/lighttpd-gitweb.conf", - require => File['/etc/lighttpd/lighttpd-gitweb.conf'], - notify => Service['lighttpd'], - } -} - -define git::clone( - $ensure = present, - $git_repo, - $projectroot, - $cloneddir_user='root', - $cloneddir_group='0', - $cloneddir_restrict_mode=true -){ - case $ensure { - absent: { - exec{"rm -rf $projectroot": - onlyif => "test -d $projectroot", - } - } - default: { - include git - exec {"git-clone_${name}": - command => "git-clone --no-hardlinks ${git_repo} ${projectroot}", - creates => "${projectroot}/.git", - user => root, - require => Package['git'], - notify => Exec["git-clone-chown_${name}"], - } - exec {"git-clone-chown_${name}": - command => "chown -R ${cloneddir_user}:${cloneddir_group} ${projectroot}", - refreshonly => true - } - if $cloneddir_restrict_mode { - exec {"git-clone-chmod_${name}": - command => "chmod -R o-rwx ${projectroot}", - refreshonly => true, - subscribe => Exec["git-clone_${name}"], - } - } - } - } -} - diff --git a/manifests/init.pp b/manifests/init.pp index ba0acb8..aa32b42 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -11,14 +11,6 @@ # the Free Software Foundation. # -import 'defines.pp' - class git { include git::base } - -class git::base { - package{'git': - ensure => present, - } -} diff --git a/manifests/web/repo.pp b/manifests/web/repo.pp new file mode 100644 index 0000000..8e5f21f --- /dev/null +++ b/manifests/web/repo.pp @@ -0,0 +1,31 @@ +# domain: the domain under which this repo will be avaiable +# projectroot: where the git repos are listened +# projects_list: which repos to export +define git::web::repo( + $projectroot, + $projects_list, + $sitename='absent' +){ + include git::web + $gitweb_url = $name + case $gitweb_sitename { + 'absent': { $gitweb_sitename = "${name} git repository" } + default: { $gitweb_sitename = $sitename } + } + $gitweb_config = "/etc/gitweb.d/${name}.conf" + file{"${gitweb_config}": + content => template("git/web/config") + } + case $gitweb_webserver { + 'lighttpd': { + git::web::repo::lighttpd{$name: + gitweb_url => $gitweb_url, + projectroot => $projectroot, + projects_list => $projects_list, + gitweb_config => $gitweb_config, + } + } + default: { fail("no supported \$gitweb_webserver defined on ${fqdn}, so can't do git::web::repo: ${name}") } + } + +} diff --git a/manifests/web/repo/lighttpd.pp b/manifests/web/repo/lighttpd.pp new file mode 100644 index 0000000..d8fe8f0 --- /dev/null +++ b/manifests/web/repo/lighttpd.pp @@ -0,0 +1,19 @@ +define git::web::repo::lighttpd( + $gitweb_url, + $projectroot, + $projects_list, + $gitweb_config +){ + include git::web::lighttpd + file{"/etc/lighttpd/gitweb.d/${name}.conf": + content => template("git/web/lighttpd"), + notify => Service['lighttpd'], + owner => root, group => 0, mode => 0644; + } + line{"add_include_of_gitwebrepo_${name}": + line => "include \"gitweb.d/${name}.conf\"", + file => "/etc/lighttpd/lighttpd-gitweb.conf", + require => File['/etc/lighttpd/lighttpd-gitweb.conf'], + notify => Service['lighttpd'], + } +} -- cgit v1.2.3