Skip to content

Commit a198e5d

Browse files
author
Colleen Murphy
committed
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.
1 parent 3a634af commit a198e5d

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ Ensure there's a newline at the end of the fragments.
218218

219219
#####`validate_cmd`
220220
Ensure the destination file passes the following validation command.
221+
Only supported on Puppet >= 3.5.0.
221222

222223
######Example
223224
- validate_cmd => '/usr/sbin/apache2 -t -f %'

manifests/init.pp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,16 @@
185185
path => $path,
186186
alias => "concat_${name}",
187187
source => "${fragdir}/${concat_name}",
188-
validate_cmd => $validate_cmd,
189188
backup => $backup,
190189
}
191190

191+
# Only newer versions of puppet 3.x support the validate_cmd parameter
192+
if $validate_cmd {
193+
File[$name] {
194+
validate_cmd => $validate_cmd,
195+
}
196+
}
197+
192198
# remove extra whitespace from string interpolation to make testing easier
193199
$command = strip(regsubst("${script_command} -o \"${fragdir}/${concat_name}\" -d \"${fragdir}\" ${warnflag} ${forceflag} ${orderflag} ${newlineflag}", '\s+', ' ', 'G'))
194200

0 commit comments

Comments
 (0)