]> gitweb.fluxo.info Git - puppet-git.git/commitdiff
Refactoring to use parametrized classes and hiera
authorSilvio Rhatto <rhatto@riseup.net>
Fri, 25 Jan 2013 12:40:42 +0000 (10:40 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Fri, 25 Jan 2013 12:40:42 +0000 (10:40 -0200)
manifests/daemon.pp [moved from manifests/git-daemon.pp with 58% similarity]
manifests/git-manager.pp [deleted file]
manifests/gitweb.pp
manifests/init.pp
templates/gitweb.conf.erb

similarity index 58%
rename from manifests/git-daemon.pp
rename to manifests/daemon.pp
index 5a5e4fb34775c9e0873e036786d24e504506754a..546aae94e131fbbe14127efd748e3a9bf17a0f10 100644 (file)
@@ -4,14 +4,26 @@
 #
 #   http://reductivelabs.com/trac/puppet/wiki/Recipes/SimpleText
 
-class git-daemon inherits git-manager {
+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 $git_server_implementation /usr/bin/git git daemon --inetd --verbose --base-path=/var/git/repositories /var/git/repositories",
+    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-manager.pp b/manifests/git-manager.pp
deleted file mode 100644 (file)
index 52e546b..0000000
+++ /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
-    }
-  }
-}
index 045787d6b45c016c53d335008911c1e8d74bcbff..1305390cbd74f25815c55250c776126d8b6b7ff0 100644 (file)
@@ -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",
index 09e90105f481fcfbc441ad3a587244ec96d607f9..e3bd908c00fc4f1467cbc6e75af331c873283ddf 100644 (file)
@@ -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"
index cffe213ce19231c22ea91010d774e162a7817a8f..00f20537e44230e1879065b847467057cb341a85 100644 (file)
@@ -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 %>');