From: Silvio Rhatto Date: Mon, 14 Feb 2011 14:11:35 +0000 (-0200) Subject: Merge branch 'master' of git://labs.riseup.net/shared-common X-Git-Url: https://gitweb.fluxo.info/?a=commitdiff_plain;h=0b03f41b32e8423bbbfa3c8a6b02dbf17c04f4c1;p=puppet-common.git Merge branch 'master' of git://labs.riseup.net/shared-common Conflicts: lib/puppet/parser/functions/gsub.rb lib/puppet/parser/functions/prefix_with.rb lib/puppet/parser/functions/slash_escape.rb lib/puppet/parser/functions/split.rb lib/puppet/parser/functions/substitute.rb manifests/classes/lsb_release.pp manifests/defines/concatenated_file.pp manifests/defines/config_file.pp manifests/defines/line.pp manifests/defines/module_dir.pp manifests/defines/module_file.pp manifests/defines/replace.pp manifests/init.pp --- 0b03f41b32e8423bbbfa3c8a6b02dbf17c04f4c1 diff --cc manifests/defines/config_file.pp index 781e9ec,2272558..375e25c --- a/manifests/defines/config_file.pp +++ b/manifests/defines/config_file.pp @@@ -2,14 -2,12 +2,14 @@@ # Copyright (C) 2007 David Schmitt # 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", - # } + # config_file { filename: + # content => "....\n", + # } # - # Examples: + # Examples: # # To create the file /etc/vservers/${vs_name}/context with specific # content: diff --cc manifests/defines/line.pp index 832382f,7ca3191..44c52a0 --- a/manifests/defines/line.pp +++ b/manifests/defines/line.pp @@@ -2,48 -2,33 +2,46 @@@ # Copyright (C) 2007 David Schmitt # 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", - # line => "content", - # ensure => {absent,*present*} + # line { description: + # file => "filename", + # line => "content", + # ensure => {absent,*present*} # } # # 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}" ) } + default : { err ( "unknown ensure value '${ensure}'" ) } present: { - exec { "/bin/echo '${line}' >> '${file}'": - unless => "/bin/grep -qFx '${line}' '${file}'", - require => File["${file}"], + exec { "echo '${line}' >> '${file}'": + unless => "grep -qFx '${line}' '${file}'" } } absent: { diff --cc manifests/defines/replace.pp index c9a98bd,7dabe59..f7da3b4 --- a/manifests/defines/replace.pp +++ b/manifests/defines/replace.pp @@@ -2,19 -2,9 +2,19 @@@ # Copyright (C) 2007 David Schmitt # 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: + # replace { description: # file => "filename", # pattern => "regexp", # replacement => "replacement"