Merge git://labs.riseup.net/module_common
authorSilvio Rhatto <rhatto@riseup.net>
Sun, 6 Dec 2009 19:18:24 +0000 (17:18 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Sun, 6 Dec 2009 19:18:24 +0000 (17:18 -0200)
manifests/classes/lsb_release.pp
manifests/defines/line.pp

index 5745072..c08b8c2 100644 (file)
@@ -33,11 +33,11 @@ class assert_lsbdistcodename {
                                        err("lsb_release was unable to report your distcodename; please set facter_lsbdistcodename in the environment of $fqdn")
                                }
                        }
-                       exec { "false # assert_lsbdistcodename": alias => assert_lsbdistcodename, loglevel => err }
+                       exec { "/bin/false # assert_lsbdistcodename": alias => assert_lsbdistcodename, loglevel => err }
                }
                default: {
-                       exec { "true # assert_lsbdistcodename": alias => assert_lsbdistcodename, loglevel => debug }
-                       exec { "true # require_lsbdistcodename": alias => require_lsbdistcodename, loglevel => debug }
+                       exec { "/bin/true # assert_lsbdistcodename": alias => assert_lsbdistcodename, loglevel => debug }
+                       exec { "/bin/true # require_lsbdistcodename": alias => require_lsbdistcodename, loglevel => debug }
                }
        }
 
index bc2ece4..832382f 100644 (file)
 #              notify => Service[munin-node],
 #              require => Package[munin-node];
 #  }
-define line(
-       $file,
-       $line,
-       $ensure = 'present'
-) {
-       case $ensure {
-               default : { err ( "unknown ensure value '${ensure}'" ) }
-               present: {
-                       exec { "echo '${line}' >> '${file}'":
-                               unless => "grep -qFx '${line}' '${file}'"
-                       }
-               }
-               absent: {
-                       exec { "perl -ni -e 'print if \$_ ne \"${line}\n\";' '${file}'":
-                               onlyif => "grep -qFx '${line}' '${file}'"
-                       }
-               }
-       }
+#
+# Code with fixes gathered at
+# http://reductivelabs.com/trac/puppet/wiki/Recipes/SimpleText
+define line($file, $line, $ensure = 'present') {
+  case $ensure {
+    default: { err ( "unknown ensure value ${ensure}" ) }
+    present: {
+      exec { "/bin/echo '${line}' >> '${file}'":
+        unless  => "/bin/grep -qFx '${line}' '${file}'",
+        require => File["${file}"],
+      }
+    }
+    absent: {
+      exec { "/usr/bin/perl -ni -e 'print unless /^\\Q${line}\\E\$/' '${file}'":
+        onlyif => "/bin/grep -qFx '${line}' '${file}'",
+      }
+    }
+    uncomment: {
+      exec { "/bin/sed -i -e'/${line}/s/^#\+//' '${file}'":
+        onlyif => "/bin/grep '${line}' '${file}' | /bin/grep '^#' | /usr/bin/wc -l"
+      }
+    }
+    comment: {
+      exec { "/bin/sed -i -e'/${line}/s/^\(.\+\)$/#\1/' '${file}'":
+        onlyif  => "/usr/bin/test `/bin/grep '${line}' '${file}' | /bin/grep -v '^#' | /usr/bin/wc -l` -ne 0",
+        require => File["${file}"],
+      }
+    }
+  }
 }
-
-