diff options
author | root <root@puppetmaster.black.co.at> | 2007-11-30 18:58:01 +0100 |
---|---|---|
committer | root <root@puppetmaster.black.co.at> | 2007-11-30 18:58:01 +0100 |
commit | b97345857b28ea7c2f30e9c769eee3df7fe5c1e8 (patch) | |
tree | 2601282350672c0e8ee57a862ecaade1f0d05d37 | |
parent | af7efe479130c8d131346b7c20f167e85d52e2ed (diff) | |
download | puppet-common-b97345857b28ea7c2f30e9c769eee3df7fe5c1e8.tar.gz puppet-common-b97345857b28ea7c2f30e9c769eee3df7fe5c1e8.tar.bz2 |
concatenated_file: create a sensible default for dir parameter
patch by Chris MacLeod, thanks!
-rw-r--r-- | manifests/defines/concatenated_file.pp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/manifests/defines/concatenated_file.pp b/manifests/defines/concatenated_file.pp index f4ba791..ff7bf53 100644 --- a/manifests/defines/concatenated_file.pp +++ b/manifests/defines/concatenated_file.pp @@ -5,7 +5,6 @@ # See LICENSE for the full license granted to you. # TODO: -# * get rid of the $dir parameter # * create the directory in _part too # Usage: @@ -15,7 +14,7 @@ # Use Exec["concat_$name"] as Semaphor define concatenated_file ( # where the snippets are located - $dir, + $dir = '', # a file with content to prepend $header = '', # a file with content to append @@ -24,11 +23,13 @@ define concatenated_file ( ) { - if defined(File[$dir]) { - debug("${dir} already defined") + $dir_real = $dir ? { '' => "${name}.d", default => $dir } + + if defined(File[$dir_real]) { + debug("${dir_real} already defined") } else { file { - $dir: + $dir_real: source => "puppet://$servername/common/empty", checksum => mtime, recurse => true, purge => true, force => true, @@ -56,11 +57,11 @@ define concatenated_file ( } # use >| to force clobbering the target file - exec { "/usr/bin/find ${dir} -maxdepth 1 -type f ! -name '*puppettmp' -print0 | sort -z | xargs -0 cat ${additional_cmd} >| ${name}": + exec { "/usr/bin/find ${dir_real} -maxdepth 1 -type f ! -name '*puppettmp' -print0 | sort -z | xargs -0 cat ${additional_cmd} >| ${name}": refreshonly => true, - subscribe => File[$dir], + subscribe => File[$dir_real], before => File[$name], - alias => [ "concat_${name}", "concat_${dir}"] , + alias => [ "concat_${name}", "concat_${dir_real}"] , } } |