1 # Puts a file fragment into a directory previous setup using concat
4 # - target The file that these fragments belong to
5 # - content If present puts the content into the file
6 # - source If content was not specified, use the source
7 # - order By default all files gets a 10_ prefix in the directory
8 # you can set it to anything else using this to influence the
9 # order of the content in the file
10 # - ensure Present/Absent or destination to a file to include another file
11 # - mode Mode for the file
12 # - owner Owner of the file
13 # - group Owner of the file
14 # - backup Controls the filebucketing behavior of the final file and
15 # see File type reference for its use. Defaults to 'puppet'
16 define concat::fragment($target, $content=undef, $source=undef, $order=10, $ensure = 'present', $mode = '0644', $owner = $::id, $group = $concat::setup::root_group, $backup = 'puppet') {
17 $safe_name = regsubst($name, '[/\n]', '_', 'GM')
18 $safe_target_name = regsubst($target, '[/\n]', '_', 'GM')
19 $concatdir = $concat::setup::concatdir
20 $fragdir = "${concatdir}/${safe_target_name}"
22 # if content is passed, use that, else if source is passed use that
23 # if neither passed, but $ensure is in symlink form, make a symlink
25 '', 'absent', 'present', 'file', 'directory': {
26 if ! ($content or $source) {
27 crit('No content, source or symlink specified')
31 # do nothing, make puppet-lint happy
35 file{"${fragdir}/fragments/${order}_${safe_name}":
43 alias => "concat_fragment_${name}",
44 notify => Exec["concat_${target}"]