Merge pull request #18 from dalen/master
A patch to make puppet-concat better comply with community style guidelines.
This commit is contained in:
commit
e9c97b8820
3 changed files with 135 additions and 139 deletions
|
@ -13,7 +13,7 @@
|
|||
# - 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, $content='', $source='', $order=10, $ensure = "present", $mode = 0644, $owner = $::id, $group = $concat::setup::root_group, $backup = "puppet") {
|
||||
define concat::fragment($target, $content='', $source='', $order=10, $ensure = 'present', $mode = '0644', $owner = $::id, $group = $concat::setup::root_group, $backup = 'puppet') {
|
||||
$safe_name = regsubst($name, '/', '_', 'G')
|
||||
$safe_target_name = regsubst($target, '/', '_', 'G')
|
||||
$concatdir = $concat::setup::concatdir
|
||||
|
@ -22,12 +22,12 @@ define concat::fragment($target, $content='', $source='', $order=10, $ensure = "
|
|||
# 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
|
||||
case $content {
|
||||
"": {
|
||||
'': {
|
||||
case $source {
|
||||
"": {
|
||||
'': {
|
||||
case $ensure {
|
||||
"", "absent", "present", "file", "directory": {
|
||||
crit("No content, source or symlink specified")
|
||||
'', 'absent', 'present', 'file', 'directory': {
|
||||
crit('No content, source or symlink specified')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,14 +38,12 @@ define concat::fragment($target, $content='', $source='', $order=10, $ensure = "
|
|||
}
|
||||
|
||||
file{"${fragdir}/fragments/${order}_${safe_name}":
|
||||
ensure => $ensure,
|
||||
mode => $mode,
|
||||
owner => $owner,
|
||||
group => $group,
|
||||
ensure => $ensure,
|
||||
backup => $backup,
|
||||
alias => "concat_fragment_${name}",
|
||||
notify => Exec["concat_${target}"]
|
||||
}
|
||||
}
|
||||
|
||||
# vi:tabstop=4:expandtab:ai
|
||||
|
|
|
@ -87,36 +87,36 @@
|
|||
# ALIASES:
|
||||
# - The exec can notified using Exec["concat_/path/to/file"] or Exec["concat_/path/to/directory"]
|
||||
# - The final file can be referened as File["/path/to/file"] or File["concat_/path/to/file"]
|
||||
define concat($mode = 0644, $owner = $::id, $group = $concat::setup::root_group, $warn = "false", $force = "false", $backup = "puppet", $gnu = undef, $order="alpha") {
|
||||
define concat($mode = '0644', $owner = $::id, $group = $concat::setup::root_group, $warn = false, $force = false, $backup = 'puppet', $gnu = undef, $order='alpha') {
|
||||
$safe_name = regsubst($name, '/', '_', 'G')
|
||||
$concatdir = $concat::setup::concatdir
|
||||
$version = $concat::setup::majorversion
|
||||
$fragdir = "${concatdir}/${safe_name}"
|
||||
$concat_name = "fragments.concat.out"
|
||||
$concat_name = 'fragments.concat.out'
|
||||
$default_warn_message = '# This file is managed by Puppet. DO NOT EDIT.'
|
||||
|
||||
case $warn {
|
||||
'true',true,yes,on: { $warnmsg = "$default_warn_message" }
|
||||
'false',false,no,off: { $warnmsg = "" }
|
||||
default: { $warnmsg = "$warn" }
|
||||
'true',true,yes,on: { $warnmsg = $default_warn_message }
|
||||
'false',false,no,off: { $warnmsg = '' }
|
||||
default: { $warnmsg = $warn }
|
||||
}
|
||||
|
||||
$warnmsg_escaped = regsubst($warnmsg, "'", "'\\\\''", 'G')
|
||||
$warnflag = $warnmsg_escaped ? {
|
||||
'' => '',
|
||||
default => "-w '$warnmsg_escaped'"
|
||||
default => "-w '${warnmsg_escaped}'"
|
||||
}
|
||||
|
||||
case $force {
|
||||
'true',true,yes,on: { $forceflag = "-f" }
|
||||
'false',false,no,off: { $forceflag = "" }
|
||||
default: { fail("Improper 'force' value given to concat: $force") }
|
||||
'true',true,yes,on: { $forceflag = '-f' }
|
||||
'false',false,no,off: { $forceflag = '' }
|
||||
default: { fail("Improper 'force' value given to concat: ${force}") }
|
||||
}
|
||||
|
||||
case $order {
|
||||
numeric: { $orderflag = "-n" }
|
||||
alpha: { $orderflag = "" }
|
||||
default: { fail("Improper 'order' value given to concat: $order") }
|
||||
numeric: { $orderflag = '-n' }
|
||||
alpha: { $orderflag = '' }
|
||||
default: { fail("Improper 'order' value given to concat: ${order}") }
|
||||
}
|
||||
|
||||
File{
|
||||
|
@ -134,9 +134,9 @@ define concat($mode = 0644, $owner = $::id, $group = $concat::setup::root_group,
|
|||
recurse => true,
|
||||
purge => true,
|
||||
force => true,
|
||||
ignore => [".svn", ".git", ".gitignore"],
|
||||
ignore => ['.svn', '.git', '.gitignore'],
|
||||
source => $version ? {
|
||||
24 => "puppet:///concat/null",
|
||||
24 => 'puppet:///concat/null',
|
||||
default => undef,
|
||||
},
|
||||
notify => Exec["concat_${name}"];
|
||||
|
@ -148,12 +148,12 @@ define concat($mode = 0644, $owner = $::id, $group = $concat::setup::root_group,
|
|||
ensure => present;
|
||||
|
||||
$name:
|
||||
ensure => present,
|
||||
source => "${fragdir}/${concat_name}",
|
||||
owner => $owner,
|
||||
group => $group,
|
||||
checksum => md5,
|
||||
mode => $mode,
|
||||
ensure => present,
|
||||
alias => "concat_${name}";
|
||||
}
|
||||
|
||||
|
|
|
@ -24,10 +24,10 @@ class concat::setup {
|
|||
file{"${concatdir}/bin/concatfragments.sh":
|
||||
owner => $id,
|
||||
group => $root_group,
|
||||
mode => 755,
|
||||
mode => '0755',
|
||||
source => $majorversion ? {
|
||||
24 => "puppet:///concat/concatfragments.sh",
|
||||
default => "puppet:///modules/concat/concatfragments.sh"
|
||||
24 => 'puppet:///concat/concatfragments.sh',
|
||||
default => 'puppet:///modules/concat/concatfragments.sh'
|
||||
};
|
||||
|
||||
[ $concatdir, "${concatdir}/bin" ]:
|
||||
|
@ -41,5 +41,3 @@ class concat::setup {
|
|||
ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
# vi:tabstop=4:expandtab:ai
|
||||
|
|
Loading…
Reference in a new issue