only check if it is really needed
[puppet_resolvconf.git] / manifests / init.pp
index e444480..c55781a 100644 (file)
@@ -1,29 +1,43 @@
-# modules/resolvconf/manifests/init.pp - manage resolvconf stuff
-# Copyright (C) 2007 admin@immerda.ch
-# GPLv3
+#
+# resolvconf module
+#
+# Copyright 2008, admin(at)immerda.ch
+# Copyright 2008, Puzzle ITC GmbH
+# Marcel Härry haerry+puppet(at)puzzle.ch
+# Simon Josi josi+puppet(at)puzzle.ch
+#
+# This program is free software; you can redistribute 
+# it and/or modify it under the terms of the GNU 
+# General Public License version 3 as published by 
+# the Free Software Foundation.
+#
 
 # modules_dir { "resolvconf": }
 
-class resolvconf {}
-
-define resolvconf::create (
-    $domain='glei.ch', 
-    $search='glei.ch',
-    $nameserver1='212.103.67.60',  
-    $nameserver2='212.103.72.231', 
-    $nameserver3='192.168.1.104'
-) {
-    $str = "search $search
-domain $domain
-nameserver $nameserver1
-nameserver $nameserver2
-nameserver $nameserver3
-"
+class resolvconf {
+    case $operatingsystem {
+        openbsd: { info("\$reseolvconf_domain and  \$reseolvconf_search not needed on openbsd") }
+        default: {
+            case $reseolvconf_domain {
+                '': { fail("you need to define \$reseolvconf_domain for ${fqdn}") }
+            }
+            case $resolvconf_search {
+                '': { fail("you need to define \$reseolvconf_search for ${fqdn}") }
+            }
+        }
+    }
+    case $resolvconf_nameservers {
+        '': { fail("you need to define \$reseolvconf_nameservers for ${fqdn}") }
+    }
 
-    file { "/etc/resolv.conf":
-        content => $str
+    file { '/etc/resolv.conf':
+        path => '/etc/resolv.conf',
+        owner => root,
+        group => 0,
+        mode => 444,
+        content => $operatingsystem ? {
+            openbsd => template("resolvconf/resolvconf.${operatingsystem}.erb"),
+            default => template('resolvconf/resolvconf.erb'),
+        }
     }
 }
-
-
-