diff options
-rw-r--r-- | manifests/defines/line.pp | 27 | ||||
-rw-r--r-- | manifests/init.pp | 9 |
2 files changed, 34 insertions, 2 deletions
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 <david@schmitt.edv-bus.at> +# 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 <david@schmitt.edv-bus.at> # 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" |