diff options
author | Micah Anderson <micah@riseup.net> | 2010-09-02 19:04:29 -0400 |
---|---|---|
committer | Micah Anderson <micah@riseup.net> | 2010-09-02 19:04:29 -0400 |
commit | 63a16ad8c07e880e68cb7c0a895f7e26ca1434f8 (patch) | |
tree | 1ca7da340aef82e8fe87f44c680cedc93795ecbf /manifests/defines/concatenated_file.pp | |
parent | 76b0a31a76b8ab7509da3389379daa24b0610f73 (diff) | |
parent | 51e06fd0d2fa1c8999f328051e5e717bc18e77e7 (diff) | |
download | puppet-common-63a16ad8c07e880e68cb7c0a895f7e26ca1434f8.tar.gz puppet-common-63a16ad8c07e880e68cb7c0a895f7e26ca1434f8.tar.bz2 |
Merge remote branch 'immerda/master'
Conflicts:
lib/puppet/parser/functions/gsub.rb
lib/puppet/parser/functions/prefix_with.rb
lib/puppet/parser/functions/sha1.rb
lib/puppet/parser/functions/slash_escape.rb
lib/puppet/parser/functions/substitute.rb
manifests/classes/lsb_release.pp
manifests/defines/concatenated_file.pp
manifests/defines/config_file.pp
manifests/defines/line.pp
manifests/defines/module_dir.pp
manifests/defines/module_file.pp
manifests/defines/replace.pp
manifests/init.pp
Diffstat (limited to 'manifests/defines/concatenated_file.pp')
-rw-r--r-- | manifests/defines/concatenated_file.pp | 142 |
1 files changed, 71 insertions, 71 deletions
diff --git a/manifests/defines/concatenated_file.pp b/manifests/defines/concatenated_file.pp index b85456c..491e2c8 100644 --- a/manifests/defines/concatenated_file.pp +++ b/manifests/defines/concatenated_file.pp @@ -4,8 +4,6 @@ # Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at> # See LICENSE for the full license granted to you. -module_dir { "common/cf": } - # TODO: # * create the directory in _part too @@ -24,77 +22,78 @@ module_dir { "common/cf": } # # Depend on File[$name] to change if and only if its contents change. Notify # Exec["concat_${name}"] if you want to force an update. -# +# # Usage: # concatenated_file { "/etc/some.conf": -# dir => "/etc/some.conf.d", +# dir => "/etc/some.conf.d", # } define concatenated_file ( - # where the snippets are located - $dir = '', - # a file with content to prepend - $header = '', - # a file with content to append - $footer = '', - # default permissions for the target file - $mode = 0644, $owner = root, $group = 0 - ) + # where the snippets are located + $dir = '', + # a file with content to prepend + $header = '', + # a file with content to append + $footer = '', + # default permissions for the target file + $mode = 0644, $owner = root, $group = 0 + ) { + include common::moduledir::common::cf - $dir_real = $dir ? { '' => "${name}.d", default => $dir } + $dir_real = $dir ? { '' => "${name}.d", default => $dir } - $tmp_file_name = regsubst($dir_real, '/', '_', 'G') - $tmp_file = "${module_dir_path}/${tmp_file_name}" + $tmp_file_name = regsubst($dir_real, '/', '_', 'G') + $tmp_file = "${common::moduledir::module_dir_path}/${tmp_file_name}" - if defined(File[$dir_real]) { - debug("${dir_real} already defined") - } else { - file { - $dir_real: - source => "puppet://$server/modules/common/empty", - checksum => mtime, - ignore => '.ignore', - recurse => true, purge => true, force => true, - mode => $mode, owner => $owner, group => $group, - notify => Exec["concat_${name}"]; - } - } + if defined(File[$dir_real]) { + debug("${dir_real} already defined") + } else { + file { + $dir_real: + source => "puppet:///modules/common/empty", + checksum => mtime, + ignore => '.ignore', + recurse => true, purge => true, force => true, + mode => $mode, owner => $owner, group => $group, + notify => Exec["concat_${name}"]; + } + } - file { - $tmp_file: - ensure => present, checksum => md5, - mode => $mode, owner => $owner, group => $group; - # decouple the actual file from the generation process by using a - # temporary file and puppet's source mechanism. This ensures that events - # for notify/subscribe will only be generated when there is an actual - # change. - $name: - ensure => present, checksum => md5, - source => $tmp_file, - mode => $mode, owner => $owner, group => $group, - require => File[$tmp_file]; - } + file { + $tmp_file: + ensure => present, checksum => md5, + mode => $mode, owner => $owner, group => $group; + # decouple the actual file from the generation process by using a + # temporary file and puppet's source mechanism. This ensures that events + # for notify/subscribe will only be generated when there is an actual + # change. + $name: + ensure => present, checksum => md5, + source => $tmp_file, + mode => $mode, owner => $owner, group => $group, + require => File[$tmp_file]; + } - # if there is a header or footer file, add it - $additional_cmd = $header ? { - '' => $footer ? { - '' => '', - default => "| cat - '${footer}' " - }, - default => $footer ? { - '' => "| cat '${header}' - ", - default => "| cat '${header}' - '${footer}' " - } - } + # if there is a header or footer file, add it + $additional_cmd = $header ? { + '' => $footer ? { + '' => '', + default => "| cat - '${footer}' " + }, + default => $footer ? { + '' => "| cat '${header}' - ", + default => "| cat '${header}' - '${footer}' " + } + } - # use >| to force clobbering the target file - exec { "concat_${name}": - command => "/usr/bin/find ${dir_real} -maxdepth 1 -type f ! -name '*puppettmp' -print0 | sort -z | xargs -0 cat ${additional_cmd} >| ${tmp_file}", - subscribe => [ File[$dir_real] ], - before => File[$tmp_file], - alias => [ "concat_${dir_real}"], - loglevel => info - } + # use >| to force clobbering the target file + exec { "concat_${name}": + command => "/usr/bin/find ${dir_real} -maxdepth 1 -type f ! -name '*puppettmp' -print0 | sort -z | xargs -0 cat ${additional_cmd} >| ${tmp_file}", + subscribe => [ File[$dir_real] ], + before => File[$tmp_file], + alias => [ "concat_${dir_real}"], + loglevel => info + } } @@ -102,16 +101,17 @@ define concatenated_file ( # Add a snippet called $name to the concatenated_file at $dir. # The file can be referenced as File["cf_part_${name}"] define concatenated_file_part ( - $dir, $content = '', $ensure = present, - $mode = 0644, $owner = root, $group = 0 - ) + $dir, $content = '', $ensure = present, + $mode = 0644, $owner = root, $group = 0 + ) { - file { "${dir}/${name}": - ensure => $ensure, content => $content, - mode => $mode, owner => $owner, group => $group, - alias => "cf_part_${name}", - notify => Exec["concat_${dir}"], - } + file { "${dir}/${name}": + ensure => $ensure, content => $content, + mode => $mode, owner => $owner, group => $group, + alias => "cf_part_${name}", + notify => Exec["concat_${dir}"], + } } + |