2013-05-09 21:24:22 +02:00
|
|
|
# == Define: concat::fragment
|
|
|
|
#
|
2010-05-06 23:55:02 +02:00
|
|
|
# Puts a file fragment into a directory previous setup using concat
|
2012-08-14 17:13:25 +02:00
|
|
|
#
|
2013-05-09 21:24:22 +02:00
|
|
|
# === Options:
|
|
|
|
#
|
|
|
|
# [*target*]
|
|
|
|
# The file that these fragments belong to
|
|
|
|
# [*content*]
|
|
|
|
# If present puts the content into the file
|
|
|
|
# [*source*]
|
|
|
|
# If content was not specified, use the source
|
|
|
|
# [*order*]
|
|
|
|
# By default all files gets a 10_ prefix in the directory you can set it to
|
|
|
|
# anything else using this to influence the order of the content in the file
|
|
|
|
# [*ensure*]
|
|
|
|
# Present/Absent or destination to a file to include another file
|
|
|
|
# [*mode*]
|
|
|
|
# Mode for the file
|
|
|
|
# [*owner*]
|
|
|
|
# Owner of the file
|
|
|
|
# [*group*]
|
|
|
|
# Owner of the file
|
|
|
|
# [*backup*]
|
|
|
|
# Controls the filebucketing behavior of the final file and see File type
|
|
|
|
# reference for its use. Defaults to 'puppet'
|
|
|
|
#
|
|
|
|
define concat::fragment(
|
|
|
|
$target,
|
2013-10-22 17:53:18 +02:00
|
|
|
$content = undef,
|
|
|
|
$source = undef,
|
|
|
|
$order = 10,
|
|
|
|
$ensure = 'present',
|
|
|
|
$mode = '0644',
|
|
|
|
$owner = $::id,
|
|
|
|
$group = undef,
|
|
|
|
$backup = 'puppet'
|
2013-10-15 23:07:51 +02:00
|
|
|
) {
|
|
|
|
include concat::setup
|
|
|
|
|
2013-10-22 17:53:18 +02:00
|
|
|
$safe_name = regsubst($name, '[/\n]', '_', 'GM')
|
2012-11-06 10:31:54 +01:00
|
|
|
$safe_target_name = regsubst($target, '[/\n]', '_', 'GM')
|
2013-10-22 17:53:18 +02:00
|
|
|
$concatdir = $concat::setup::concatdir
|
|
|
|
$fragdir = "${concatdir}/${safe_target_name}"
|
2010-05-06 23:55:02 +02:00
|
|
|
|
2013-10-15 23:07:51 +02:00
|
|
|
$safe_group = $group ? {
|
|
|
|
undef => $concat::setup::root_group,
|
|
|
|
default => $group,
|
|
|
|
}
|
|
|
|
|
2012-03-14 18:02:43 +01:00
|
|
|
# if content is passed, use that, else if source is passed use that
|
|
|
|
# if neither passed, but $ensure is in symlink form, make a symlink
|
2013-02-28 13:00:11 +01:00
|
|
|
case $ensure {
|
|
|
|
'', 'absent', 'present', 'file', 'directory': {
|
|
|
|
if ! ($content or $source) {
|
|
|
|
crit('No content, source or symlink specified')
|
2012-03-14 18:02:43 +01:00
|
|
|
}
|
2013-03-13 14:25:47 +01:00
|
|
|
}
|
2013-02-28 13:00:11 +01:00
|
|
|
default: {
|
|
|
|
# do nothing, make puppet-lint happy
|
2010-05-06 23:55:02 +02:00
|
|
|
}
|
2012-03-14 18:02:43 +01:00
|
|
|
}
|
2010-05-06 23:55:02 +02:00
|
|
|
|
2013-10-22 17:53:18 +02:00
|
|
|
file { "${fragdir}/fragments/${order}_${safe_name}":
|
2013-02-28 13:00:11 +01:00
|
|
|
ensure => $ensure,
|
|
|
|
mode => $mode,
|
|
|
|
owner => $owner,
|
2013-10-15 23:07:51 +02:00
|
|
|
group => $safe_group,
|
2013-02-28 13:00:11 +01:00
|
|
|
source => $source,
|
|
|
|
content => $content,
|
|
|
|
backup => $backup,
|
|
|
|
alias => "concat_fragment_${name}",
|
|
|
|
notify => Exec["concat_${target}"]
|
2012-03-14 18:02:43 +01:00
|
|
|
}
|
2010-05-06 23:55:02 +02:00
|
|
|
}
|