2007-10-05 22:04:32 +02:00
|
|
|
# common/manifests/defines/config_file.pp -- create a config file with default permissions
|
2007-06-25 09:44:24 +02:00
|
|
|
# Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at>
|
|
|
|
# See LICENSE for the full license granted to you.
|
|
|
|
|
2009-05-31 21:14:37 +02:00
|
|
|
# A simple wrapper to give all configuration files common defaults.
|
|
|
|
#
|
2007-06-25 09:44:24 +02:00
|
|
|
# Usage:
|
2009-06-09 17:51:10 +02:00
|
|
|
# config_file { filename:
|
|
|
|
# content => "....\n",
|
|
|
|
# }
|
2007-10-05 22:04:32 +02:00
|
|
|
#
|
|
|
|
# Examples:
|
|
|
|
#
|
|
|
|
# To create the file /etc/vservers/${vs_name}/context with specific
|
|
|
|
# content:
|
|
|
|
#
|
2009-06-09 17:51:10 +02:00
|
|
|
# config_file {
|
|
|
|
# "/etc/vservers/${vs_name}/context":
|
|
|
|
# content => "${context}\n",
|
|
|
|
# notify => Exec["vs_restart_${vs_name}"],
|
|
|
|
# require => Exec["vs_create_${vs_name}"];
|
2007-10-05 22:04:32 +02:00
|
|
|
# }
|
|
|
|
#
|
|
|
|
# To create the file /etc/apache2/sites-available/munin-stats with the
|
|
|
|
# content pulled from a template:
|
|
|
|
#
|
2009-06-09 17:51:10 +02:00
|
|
|
# config_file {
|
|
|
|
# "/etc/apache2/sites-available/munin-stats":
|
|
|
|
# content => template("apache/munin-stats"),
|
|
|
|
# require => Package["apache2"],
|
|
|
|
# notify => Exec["reload-apache2"];
|
|
|
|
# }
|
2009-05-31 21:14:37 +02:00
|
|
|
define config_file (
|
|
|
|
$content = '',
|
|
|
|
$source = '',
|
|
|
|
$ensure = 'present')
|
|
|
|
{
|
2007-06-25 09:44:24 +02:00
|
|
|
file { $name:
|
2007-10-09 10:55:09 +02:00
|
|
|
ensure => $ensure,
|
2007-06-25 09:53:07 +02:00
|
|
|
# default permissions for config files
|
2008-02-14 18:24:44 +01:00
|
|
|
mode => 0644, owner => root, group => 0,
|
2007-06-25 09:53:07 +02:00
|
|
|
# really detect changes to this file
|
|
|
|
checksum => md5,
|
2007-06-25 09:44:24 +02:00
|
|
|
}
|
2007-11-13 10:44:07 +01:00
|
|
|
|
2008-02-29 16:49:59 +01:00
|
|
|
case $source {
|
|
|
|
'': { }
|
|
|
|
default: { File[$name] { source => $source } }
|
|
|
|
}
|
|
|
|
|
2007-11-13 10:44:07 +01:00
|
|
|
case $content {
|
2008-02-29 16:49:59 +01:00
|
|
|
'': { }
|
2007-11-13 10:44:07 +01:00
|
|
|
default: { File[$name] { content => $content } }
|
|
|
|
}
|
|
|
|
|
2007-06-25 09:44:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|