diff options
Diffstat (limited to 'manifests')
-rw-r--r-- | manifests/defines/append_if_no_such_line.pp | 14 | ||||
-rw-r--r-- | manifests/defines/concatenated_file.pp | 2 | ||||
-rw-r--r-- | manifests/defines/config_file.pp | 11 | ||||
-rw-r--r-- | manifests/defines/delete_lines.pp | 5 | ||||
-rw-r--r-- | manifests/defines/line.pp | 37 | ||||
-rw-r--r-- | manifests/defines/replace.pp | 10 |
6 files changed, 62 insertions, 17 deletions
diff --git a/manifests/defines/append_if_no_such_line.pp b/manifests/defines/append_if_no_such_line.pp new file mode 100644 index 0000000..6ccf9f9 --- /dev/null +++ b/manifests/defines/append_if_no_such_line.pp @@ -0,0 +1,14 @@ +# +# This define is only for "CFEngine compatability". It is only a light +# wrapper around the "line" define, which is equally dangerous, but at +# least named according to a proper resource model. +# +define append_if_no_such_line($file, $line) { + line { + $name: + ensure => present, + file => $file, + line => $line; + } +} + diff --git a/manifests/defines/concatenated_file.pp b/manifests/defines/concatenated_file.pp index 5f1c275..fc2c7a3 100644 --- a/manifests/defines/concatenated_file.pp +++ b/manifests/defines/concatenated_file.pp @@ -4,6 +4,8 @@ # Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at> # See LICENSE for the full license granted to you. +module_dir { "common/cf": } + # TODO: # * create the directory in _part too diff --git a/manifests/defines/config_file.pp b/manifests/defines/config_file.pp index 2272558..375e25c 100644 --- a/manifests/defines/config_file.pp +++ b/manifests/defines/config_file.pp @@ -2,6 +2,8 @@ # Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at> # See LICENSE for the full license granted to you. +# A simple wrapper to give all configuration files common defaults. +# # Usage: # config_file { filename: # content => "....\n", @@ -12,10 +14,11 @@ # To create the file /etc/vservers/${vs_name}/context with specific # content: # -# config_file { "/etc/vservers/${vs_name}/context": -# content => "${context}\n", -# notify => Exec["vs_restart_${vs_name}"], -# require => Exec["vs_create_${vs_name}"]; +# config_file { +# "/etc/vservers/${vs_name}/context": +# content => "${context}\n", +# notify => Exec["vs_restart_${vs_name}"], +# require => Exec["vs_create_${vs_name}"]; # } # # To create the file /etc/apache2/sites-available/munin-stats with the diff --git a/manifests/defines/delete_lines.pp b/manifests/defines/delete_lines.pp new file mode 100644 index 0000000..28d2362 --- /dev/null +++ b/manifests/defines/delete_lines.pp @@ -0,0 +1,5 @@ +define delete_lines($file, $pattern) { + exec { "/bin/sed -i -r -e '/$pattern/d' $file": + onlyif => "/bin/grep -E '$pattern' '$file'", + } +} diff --git a/manifests/defines/line.pp b/manifests/defines/line.pp index 7ca3191..44c52a0 100644 --- a/manifests/defines/line.pp +++ b/manifests/defines/line.pp @@ -2,6 +2,17 @@ # Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at> # See LICENSE for the full license granted to you. +# Ensures that a specific line is present or absent in a file. This can +# be very brittle, since even small changes can throw this off. +# +# If the line is not present yet, it will be appended to the file. +# +# The name of the define is not used. Just keep it (globally) unique and +# descriptive. +# +# Use this only for very trivial stuff. Usually replacing the whole file +# is a more stable solution with less maintenance headaches afterwards. +# # Usage: # line { description: # file => "filename", @@ -10,19 +21,21 @@ # } # # Example: -# The following ensures that the line "allow ^$munin_host$" exists -# in /etc/munin/munin-node.conf, and if there are any changes notify the service for -# a restart -# -# line { allow_munin_host: -# file => "/etc/munin/munin-node.conf", -# line => "allow ^$munin_host$", -# ensure => present, -# notify => Service[munin-node], -# require => Package[munin-node], -# } +# The following ensures that the line "allow ^$munin_host$" exists in +# /etc/munin/munin-node.conf, and if there are any changes notify the +# service for a restart # +# line { +# allow_munin_host: +# file => "/etc/munin/munin-node.conf", +# line => "allow ^$munin_host$", +# ensure => present, +# notify => Service[munin-node], +# require => Package[munin-node]; +# } # +# Code with fixes gathered at +# http://reductivelabs.com/trac/puppet/wiki/Recipes/SimpleText define line($file, $line, $ensure = 'present') { case $ensure { default : { err ( "unknown ensure value '${ensure}'" ) } @@ -39,5 +52,3 @@ define line($file, $line, $ensure = 'present') { } } } - - diff --git a/manifests/defines/replace.pp b/manifests/defines/replace.pp index 7dabe59..f7da3b4 100644 --- a/manifests/defines/replace.pp +++ b/manifests/defines/replace.pp @@ -2,6 +2,16 @@ # Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at> # See LICENSE for the full license granted to you. +# A hack to replace all ocurrances of a regular expression in a file with a +# specified string. Sometimes it can be less effort to replace only a single +# value in a huge config file instead of creating a template out of it. Still, +# creating a template is often better than this hack. +# +# This define uses perl regular expressions. +# +# Use this only for very trivial stuff. Usually replacing the whole file is a +# more stable solution with less maintenance headaches afterwards. +# # Usage: # # replace { description: |