From a198e5db14c8f36a919b2f6b7bd7dc3ce2891dbe Mon Sep 17 00:00:00 2001 From: Colleen Murphy Date: Wed, 11 Feb 2015 22:03:00 -0800 Subject: [PATCH] Fix validate_cmd file resource parameter The validate_cmd parameter is only valid on newer versions of puppet. This module is supporting all 3.x versions of puppet. This commit only applies the validate_cmd parameter to the file resource if it is defined and adds documentation noting that it will not work on older versons of puppet. --- README.md | 1 + manifests/init.pp | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d3e286051..8225b05e6 100644 --- a/README.md +++ b/README.md @@ -218,6 +218,7 @@ Ensure there's a newline at the end of the fragments. #####`validate_cmd` Ensure the destination file passes the following validation command. +Only supported on Puppet >= 3.5.0. ######Example - validate_cmd => '/usr/sbin/apache2 -t -f %' diff --git a/manifests/init.pp b/manifests/init.pp index 9ac3fe550..1727bec2c 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -185,10 +185,16 @@ path => $path, alias => "concat_${name}", source => "${fragdir}/${concat_name}", - validate_cmd => $validate_cmd, 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'))