From 2ead031c3e15ad1aeee4113be3250a74fa4bc766 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Fri, 25 Jan 2013 10:40:42 -0200 Subject: Refactoring to use parametrized classes and hiera --- manifests/daemon.pp | 29 +++++++++++++++++++++++++++++ manifests/git-daemon.pp | 17 ----------------- manifests/git-manager.pp | 14 -------------- manifests/gitweb.pp | 17 ++++++----------- manifests/init.pp | 3 +-- templates/gitweb.conf.erb | 4 ++-- 6 files changed, 38 insertions(+), 46 deletions(-) create mode 100644 manifests/daemon.pp delete mode 100644 manifests/git-daemon.pp delete mode 100644 manifests/git-manager.pp diff --git a/manifests/daemon.pp b/manifests/daemon.pp new file mode 100644 index 0000000..546aae9 --- /dev/null +++ b/manifests/daemon.pp @@ -0,0 +1,29 @@ +# This class configures the git-daemon service. It ensures the packages is +# installed and a line is present in /etc/inetd.conf, which configures it. +# It depends on a "line" definition, which can be found here: +# +# http://reductivelabs.com/trac/puppet/wiki/Recipes/SimpleText + +class git::daemon ( + $implementation = hiera('git::daemon::implementation', 'gitolite') +) { + + case $implementation { + 'gitosis': { + include gitosis + } + default: { + include gitolite + } + } + + # the needed packages and services + include inetd + + # git-daemon config in inetd + line { "git-daemon-inetd": + file => "/etc/inetd.conf", + line => "git stream tcp nowait ${implementation} /usr/bin/git git daemon --inetd --verbose --base-path=/var/git/repositories /var/git/repositories", + ensure => present, + } +} diff --git a/manifests/git-daemon.pp b/manifests/git-daemon.pp deleted file mode 100644 index 5a5e4fb..0000000 --- a/manifests/git-daemon.pp +++ /dev/null @@ -1,17 +0,0 @@ -# This class configures the git-daemon service. It ensures the packages is -# installed and a line is present in /etc/inetd.conf, which configures it. -# It depends on a "line" definition, which can be found here: -# -# http://reductivelabs.com/trac/puppet/wiki/Recipes/SimpleText - -class git-daemon inherits git-manager { - # the needed packages and services - include inetd - - # git-daemon config in inetd - line { "git-daemon-inetd": - file => "/etc/inetd.conf", - line => "git stream tcp nowait $git_server_implementation /usr/bin/git git daemon --inetd --verbose --base-path=/var/git/repositories /var/git/repositories", - ensure => present, - } -} diff --git a/manifests/git-manager.pp b/manifests/git-manager.pp deleted file mode 100644 index 52e546b..0000000 --- a/manifests/git-manager.pp +++ /dev/null @@ -1,14 +0,0 @@ -class git-manager { - case $git_server_implementation { - '': { $git_server_implementation = 'gitolite' } - } - - case $git_server_implementation { - 'gitosis': { - include gitosis - } - default: { - include gitolite - } - } -} diff --git a/manifests/gitweb.pp b/manifests/gitweb.pp index 045787d..1305390 100644 --- a/manifests/gitweb.pp +++ b/manifests/gitweb.pp @@ -1,19 +1,14 @@ # This class handles a gitweb installation. -class gitweb inherits git-manager { +class gitweb( + $protocol = hiera('git::web::protocol', 'git'), + $hosting_domain = hiera('git::web::hosting_domain', $::domain) + $implementation = hiera('git::daemon::implementation', 'gitolite') +) { + # the needed packages package { gitweb: ensure => installed } - $hosting_domain = $base_domain ? { - '' => $domain, - default => $base_domain, - } - - $base_url_protocol = $gitweb_protocol ? { - '' => 'git', - default => $gitweb_protocol, - } - # gitweb config file file { "/etc/gitweb.conf": owner => "root", diff --git a/manifests/init.pp b/manifests/init.pp index 09e9010..e3bd908 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -3,6 +3,5 @@ import "git.pp" import "gitosis.pp" import "gitweb.pp" -import "git-daemon.pp" -import "git-manager.pp" +import "daemon.pp" import "gitolite.pp" diff --git a/templates/gitweb.conf.erb b/templates/gitweb.conf.erb index cffe213..00f2053 100644 --- a/templates/gitweb.conf.erb +++ b/templates/gitweb.conf.erb @@ -13,7 +13,7 @@ $git_temp = "/tmp"; $home_text = "indextext.html"; # file with project list; by default, simply scan the projectroot dir. -$projects_list = "/var/git/<% if git_server_implementation == 'gitosis' %><%= git_server_implementation %>/<% end %>projects.list"; +$projects_list = "/var/git/<% if implementation == 'gitosis' %><%= implementation %>/<% end %>projects.list"; # stylesheet to use $stylesheet = "/gitweb.css"; @@ -25,4 +25,4 @@ $logo = "/git-logo.png"; $favicon = "/git-favicon.png"; # header url -@git_base_url_list = ('<%= base_url_protocol %>://git.<%= hosting_domain %>'); +@git_base_url_list = ('<%= protocol %>://git.<%= hosting_domain %>'); -- cgit v1.2.3