From: david Date: Mon, 25 Jun 2007 07:31:47 +0000 (+0000) Subject: first steps with the common module X-Git-Url: https://gitweb.fluxo.info/?a=commitdiff_plain;h=86638cf2c1379b0b03433a037a14b84bb8410b57;p=puppet-common.git first steps with the common module git-svn-id: http://club.black.co.at:82/svn/manifests/trunk@53 f03ff2f1-f02d-0410-970d-b9634babeaa1 --- diff --git a/manifests/defines/line.pp b/manifests/defines/line.pp new file mode 100644 index 0000000..2d2e886 --- /dev/null +++ b/manifests/defines/line.pp @@ -0,0 +1,27 @@ +# common/manifests/defines/line.pp -- a trivial puppet lined +# Copyright (C) 2007 David Schmitt +# See LICENSE for the full license granted to you. + +# Usage: +# line { description: +# file => "filename", +# line => "content", +# ensure => {absent,present} +# } +define line($file, $line, $ensure) { + case $ensure { + default : { err ( "unknown ensure value $ensure" ) } + present: { + exec { "/bin/echo '$line' >> '$file'": + unless => "/bin/grep -Fx '$line' '$file'" + } + } + absent: { + exec { "/usr/bin/perl -ni -e 'print unless /^\\Q$line\\E$/' '$file'": + onlyif => "/bin/grep -Fx '$line' '$file'" + } + } + } +} + + diff --git a/manifests/init.pp b/manifests/init.pp index 0a57299..90dae0e 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -2,11 +2,16 @@ # Copyright (C) 2007 David Schmitt # See LICENSE for the full license granted to you. -# Module programmers can use /var/lib/puppet/modules/$modulename to -# save module-local data, e.g. for constructing config files file { + # Module programmers can use /var/lib/puppet/modules/$modulename to save + # module-local data, e.g. for constructing config files "/var/lib/puppet/modules": ensure => directory, mode => 0755, owner => root, group => root; + # prepare directories to drop various puppet enhancements + [ "$rubysitedir/puppet", "$rubysitedir/facter" ]: + ensure => directory, + mode => 0755, owner => root, group => root; } +import "defines/*.pp"