aboutsummaryrefslogtreecommitdiff
path: root/manifests/defines/line.pp
diff options
context:
space:
mode:
authorJerome Charaoui <jcharaoui@cmaisonneuve.qc.ca>2015-02-20 15:37:10 -0500
committerJerome Charaoui <jcharaoui@cmaisonneuve.qc.ca>2015-02-20 15:37:10 -0500
commitc6beeb1718608389e027d287c7a8ddd586313df2 (patch)
treee7c2d4161b529967079d20ff4f81e5c118cf1a67 /manifests/defines/line.pp
parentac5da1df281e636ecffe260b681e8119a1057e1d (diff)
parente9d8147584cf42dceec6d2cdd4314e8a85dc3aeb (diff)
downloadpuppet-common-c6beeb1718608389e027d287c7a8ddd586313df2.tar.gz
puppet-common-c6beeb1718608389e027d287c7a8ddd586313df2.tar.bz2
Merge branch 'master' of git://git.puppet.immerda.ch/module-common
Diffstat (limited to 'manifests/defines/line.pp')
-rw-r--r--manifests/defines/line.pp54
1 files changed, 0 insertions, 54 deletions
diff --git a/manifests/defines/line.pp b/manifests/defines/line.pp
deleted file mode 100644
index 44c52a0..0000000
--- a/manifests/defines/line.pp
+++ /dev/null
@@ -1,54 +0,0 @@
-# common/manifests/defines/line.pp -- a trivial mechanism to ensure a line exists in a file
-# 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",
-# 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];
-# }
-#
-# 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}'" ) }
- present: {
- exec { "echo '${line}' >> '${file}'":
- unless => "grep -qFx '${line}' '${file}'"
- }
- }
- absent: {
- $subst_line = regsubst($line,'(/|\.)','\\\1','G')
- exec { "sed -i '/${subst_line}/d' '${file}'":
- onlyif => "grep -qFx '${line}' '${file}'"
- }
- }
- }
-}