diff modules/concat/manifests/init.pp @ 36:37675581a273 puppet-3.6

Update Puppet module for Apache (pulls in concat module)
author IBBoard <dev@ibboard.co.uk>
date Sat, 14 Mar 2015 20:07:04 +0000
parents 956e484adc12
children d9352a684e62
line wrap: on
line diff
--- a/modules/concat/manifests/init.pp	Sat Mar 14 20:01:17 2015 +0000
+++ b/modules/concat/manifests/init.pp	Sat Mar 14 20:07:04 2015 +0000
@@ -64,6 +64,7 @@
   $replace        = true,
   $order          = 'alpha',
   $ensure_newline = false,
+  $validate_cmd   = undef,
   $gnu            = undef
 ) {
   validate_re($ensure, '^present$|^absent$')
@@ -75,10 +76,15 @@
     fail('$warn is not a string or boolean')
   }
   validate_bool($force)
-  validate_string($backup)
+  if ! concat_is_bool($backup) and ! is_string($backup) {
+    fail('$backup must be string or bool!')
+  }
   validate_bool($replace)
   validate_re($order, '^alpha$|^numeric$')
   validate_bool($ensure_newline)
+  if $validate_cmd and ! is_string($validate_cmd) {
+    fail('$validate_cmd must be a string')
+  }
   if $gnu {
     warning('The $gnu parameter to concat is deprecated and has no effect')
   }
@@ -138,6 +144,12 @@
     backup  => false,
   }
 
+  # reset poisoned Exec defaults
+  Exec {
+    user  => undef,
+    group => undef,
+  }
+
   if $ensure == 'present' {
     file { $fragdir:
       ensure => directory,
@@ -165,20 +177,38 @@
     }
 
     file { $name:
-      ensure  => present,
-      owner   => $owner,
-      group   => $group,
-      mode    => $mode,
-      replace => $replace,
-      path    => $path,
-      alias   => "concat_${name}",
-      source  => "${fragdir}/${concat_name}",
-      backup  => $backup,
+      ensure       => present,
+      owner        => $owner,
+      group        => $group,
+      mode         => $mode,
+      replace      => $replace,
+      path         => $path,
+      alias        => "concat_${name}",
+      source       => "${fragdir}/${concat_name}",
+      backup       => $backup,
+    }
+
+    # Only newer versions of puppet 3.x support the validate_cmd parameter
+    if $validate_cmd {
+      File[$name] {
+        validate_cmd => $validate_cmd,
+      }
     }
 
     # remove extra whitespace from string interpolation to make testing easier
     $command = strip(regsubst("${script_command} -o \"${fragdir}/${concat_name}\" -d \"${fragdir}\" ${warnflag} ${forceflag} ${orderflag} ${newlineflag}", '\s+', ' ', 'G'))
 
+    # make sure ruby is in the path for PE
+    if $::is_pe {
+      if $::kernel == 'windows' {
+        $command_path = "${::env_windows_installdir}/bin:${::path}"
+      } else {
+        $command_path = "/opt/puppet/bin:${::path}"
+      }
+    } else {
+      $command_path = $::path
+    }
+
     # if puppet is running as root, this exec should also run as root to allow
     # the concatfragments.sh script to potentially be installed in path that
     # may not be accessible by a target non-root owner.
@@ -188,7 +218,7 @@
       notify    => File[$name],
       subscribe => File[$fragdir],
       unless    => "${command} -t",
-      path      => $::path,
+      path      => $command_path,
       require   => [
         File[$fragdir],
         File["${fragdir}/fragments"],
@@ -221,10 +251,12 @@
       default   => '/bin:/usr/bin',
     }
 
+    # Need to have an unless here for idempotency.
     exec { "concat_${name}":
       alias   => "concat_${fragdir}",
       command => $absent_exec_command,
-      path    => $absent_exec_path
+      unless  => $absent_exec_command,
+      path    => $absent_exec_path,
     }
   }
 }