fix whitespace (remove tabs & trailing whitespace)

This commit is contained in:
Jerome Charaoui 2010-05-07 17:38:15 -04:00 committed by Micah Anderson
parent 1379f6cba1
commit ca9b0fecd9
5 changed files with 135 additions and 144 deletions

View file

@ -22,87 +22,78 @@
#
# 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 = "${common::moduledir::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:///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
}
#case $header {
#'': {}
#default: { Exec["concat_${name}"] { subscribe +> File[$header] } }
#}
#case $footer {
#'': {}
#default: { Exec["concat_${name}"] { subscribe +> File[$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
}
}
@ -110,17 +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}"],
}
}

View file

@ -4,10 +4,10 @@
# Usage:
# config_file { filename:
# content => "....\n",
# content => "....\n",
# }
#
# Examples:
# Examples:
#
# To create the file /etc/vservers/${vs_name}/context with specific
# content:
@ -28,26 +28,26 @@
# }
define config_file ($content = '', $source = '', $ensure = 'present') {
file { $name:
ensure => $ensure,
# keep old versions on the server
backup => server,
# default permissions for config files
mode => 0644, owner => root, group => 0,
# really detect changes to this file
checksum => md5,
}
file { $name:
ensure => $ensure,
# keep old versions on the server
backup => server,
# default permissions for config files
mode => 0644, owner => root, group => 0,
# really detect changes to this file
checksum => md5,
}
case $source {
'': { }
default: { File[$name] { source => $source } }
}
case $source {
'': { }
default: { File[$name] { source => $source } }
}
case $content {
'': { }
default: { File[$name] { content => $content } }
}
case $content {
'': { }
default: { File[$name] { content => $content } }
}
}

View file

@ -12,30 +12,30 @@
# file { "${common::moduledir::module_dir_path}/somedir/somefile": }
define module_dir (
$mode = 0644, $owner = root, $group = 0
)
$mode = 0644, $owner = root, $group = 0
)
{
include common::moduledir
$dir = "$common::moduledir::module_dir_path/${name}"
if defined(File[$dir]) {
debug("${dir} already defined")
} else {
file {
$dir:
source => [ "puppet://$server/modules/${name}/modules_dir", "puppet://$server/modules/common/empty"],
checksum => mtime,
# ignore the placeholder
ignore => '\.ignore',
recurse => true, purge => true, force => true,
mode => $mode, owner => $owner, group => $group;
}
}
include common::moduledir
$dir = "$common::moduledir::module_dir_path/${name}"
if defined(File[$dir]) {
debug("${dir} already defined")
} else {
file {
$dir:
source => [ "puppet://$server/modules/${name}/modules_dir", "puppet://$server/modules/common/empty"],
checksum => mtime,
# ignore the placeholder
ignore => '\.ignore',
recurse => true, purge => true, force => true,
mode => $mode, owner => $owner, group => $group;
}
}
}
# alias for compatibility
define modules_dir (
$mode = 0644, $owner = root, $group = 0
)
$mode = 0644, $owner = root, $group = 0
)
{
module_dir { $name: mode => $mode, owner => $owner, group => $group }
}

View file

@ -6,28 +6,28 @@
# Usage:
# modules_file { "module/file":
# source => "puppet://${server}/...",
# mode => 644, # default
# owner => root, # default
# group => 0, # default
# source => "puppet://${server}/...",
# mode => 644, # default
# owner => root, # default
# group => 0, # default
# }
define module_file (
$source,
$mode = 0644, $owner = root, $group = 0
)
$source,
$mode = 0644, $owner = root, $group = 0
)
{
include common::moduledir
file {
"${common::moduledir::module_dir_path}/${name}":
source => $source,
mode => $mode, owner => $owner, group => $group;
}
include common::moduledir
file {
"${common::moduledir::module_dir_path}/${name}":
source => $source,
mode => $mode, owner => $owner, group => $group;
}
}
# alias for compatibility
define modules_file (
$source, $mode = 0644, $owner = root, $group = 0
)
$source, $mode = 0644, $owner = root, $group = 0
)
{
module_file { $name: source => $source, mode => $mode, owner => $owner, group => $group }
}

View file

@ -4,7 +4,7 @@
# Usage:
#
# replace { description:
# replace { description:
# file => "filename",
# pattern => "regexp",
# replacement => "replacement"
@ -14,17 +14,17 @@
# with a new port, but only disturbing the file when needed:
#
# replace { set_munin_node_port:
# file => "/etc/munin/munin-node.conf",
# pattern => "^port (?!$port)[0-9]*",
# replacement => "port $port"
# }
# file => "/etc/munin/munin-node.conf",
# pattern => "^port (?!$port)[0-9]*",
# replacement => "port $port"
# }
define replace($file, $pattern, $replacement) {
$pattern_no_slashes = slash_escape($pattern)
$replacement_no_slashes = slash_escape($replacement)
exec { "replace_${pattern}_${file}":
command => "/usr/bin/perl -pi -e 's/${pattern_no_slashes}/${replacement_no_slashes}/' '${file}'",
onlyif => "/usr/bin/perl -ne 'BEGIN { \$ret = 1; } \$ret = 0 if /${pattern_no_slashes}/ && ! /\\Q${replacement_no_slashes}\\E/; END { exit \$ret; }' '${file}'",
alias => "exec_$name",
}
$pattern_no_slashes = slash_escape($pattern)
$replacement_no_slashes = slash_escape($replacement)
exec { "replace_${pattern}_${file}":
command => "/usr/bin/perl -pi -e 's/${pattern_no_slashes}/${replacement_no_slashes}/' '${file}'",
onlyif => "/usr/bin/perl -ne 'BEGIN { \$ret = 1; } \$ret = 0 if /${pattern_no_slashes}/ && ! /\\Q${replacement_no_slashes}\\E/; END { exit \$ret; }' '${file}'",
alias => "exec_$name",
}
}