From 9e6cb5d208770c22708cf1960af1362cd4fdf323 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Thu, 16 Jul 2009 15:08:49 -0300 Subject: Avoiding exec error Trying to force path so puppet doesn't issue the following error: Could not create true # require_lsbdistcodename: 'true # require_lsbdistcodename' is both unqualifed and specified no search path at /etc/puppet/modules/common/manifests/classes/lsb_release.pp:40 --- manifests/classes/lsb_release.pp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manifests/classes/lsb_release.pp b/manifests/classes/lsb_release.pp index 5745072..c08b8c2 100644 --- a/manifests/classes/lsb_release.pp +++ b/manifests/classes/lsb_release.pp @@ -33,11 +33,11 @@ class assert_lsbdistcodename { err("lsb_release was unable to report your distcodename; please set facter_lsbdistcodename in the environment of $fqdn") } } - exec { "false # assert_lsbdistcodename": alias => assert_lsbdistcodename, loglevel => err } + exec { "/bin/false # assert_lsbdistcodename": alias => assert_lsbdistcodename, loglevel => err } } default: { - exec { "true # assert_lsbdistcodename": alias => assert_lsbdistcodename, loglevel => debug } - exec { "true # require_lsbdistcodename": alias => require_lsbdistcodename, loglevel => debug } + exec { "/bin/true # assert_lsbdistcodename": alias => assert_lsbdistcodename, loglevel => debug } + exec { "/bin/true # require_lsbdistcodename": alias => require_lsbdistcodename, loglevel => debug } } } -- cgit v1.2.3 From 485929e529e1e662249344faeedb643d2e7b9de8 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Wed, 29 Jul 2009 16:48:09 -0300 Subject: Trying to fix line defintion --- manifests/defines/line.pp | 49 ++++++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/manifests/defines/line.pp b/manifests/defines/line.pp index be5ec31..534fd7c 100644 --- a/manifests/defines/line.pp +++ b/manifests/defines/line.pp @@ -34,24 +34,33 @@ # notify => Service[munin-node], # require => Package[munin-node]; # } -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: { - exec { "perl -ni -e 'print if \$_ ne \"${line}\n\";' '${file}'": - onlyif => "grep -qFx '${line}' '${file}'" - } - } - } +# +# 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 { "/bin/echo '${line}' >> '${file}'": + unless => "/bin/grep -qFx '${line}' '${file}'", + require => File["${file}"], + } + } + absent: { + exec { "/usr/bin/perl -ni -e 'print unless /^\\Q${line}\\E\$/' '${file}'": + onlyif => "/bin/grep -qFx '${line}' '${file}'", + } + } + uncomment: { + exec { "/bin/sed -i -e'/${line}/s/^#\+//' '${file}'": + onlyif => "/bin/grep '${line}' '${file}' | /bin/grep '^#' | /usr/bin/wc -l" + } + } + comment: { + exec { "/bin/sed -i -e'/${line}/s/^\(.\+\)$/#\1/' '${file}'": + onlyif => "/usr/bin/test `/bin/grep '${line}' '${file}' | /bin/grep -v '^#' | /usr/bin/wc -l` -ne 0", + require => File["${file}"], + } + } + } } - - -- cgit v1.2.3 From a25d1e44c24ba52885a2b795387fe733798f85ed Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Fri, 25 Dec 2009 22:33:24 -0200 Subject: Adding delete_lines --- manifests/defines/delete_lines.pp | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 manifests/defines/delete_lines.pp 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'", + } +} -- cgit v1.2.3 From 3f3d08d12a6d8ecd6dac522f34ab60613548f3ab Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sun, 27 Dec 2009 23:13:42 -0200 Subject: Workaround for puppet issue #2786 --- manifests/defines/module_dir.pp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/manifests/defines/module_dir.pp b/manifests/defines/module_dir.pp index def5c94..c4f5b77 100644 --- a/manifests/defines/module_dir.pp +++ b/manifests/defines/module_dir.pp @@ -33,6 +33,8 @@ define module_dir ( ignore => '\.ignore', recurse => true, purge => true, force => true, mode => $mode, owner => $owner, group => $group; + # TODO: remove after 0.25.2 is released, see http://projects.reductivelabs.com/issues/2786: + backup => false, } } } -- cgit v1.2.3 From ee51719e23d29da0f8755a90fd0fbfed826f3e80 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sun, 27 Dec 2009 23:17:23 -0200 Subject: Workaround for puppet issue #2786 (2) --- manifests/defines/module_dir.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/defines/module_dir.pp b/manifests/defines/module_dir.pp index c4f5b77..00e2a72 100644 --- a/manifests/defines/module_dir.pp +++ b/manifests/defines/module_dir.pp @@ -32,7 +32,7 @@ define module_dir ( # ignore the placeholder ignore => '\.ignore', recurse => true, purge => true, force => true, - mode => $mode, owner => $owner, group => $group; + mode => $mode, owner => $owner, group => $group, # TODO: remove after 0.25.2 is released, see http://projects.reductivelabs.com/issues/2786: backup => false, } -- cgit v1.2.3 From 0411a1b9644f9011d63de1f7456327af8a892691 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sun, 27 Dec 2009 23:39:46 -0200 Subject: Workaround for puppet issue #2786 (3) --- manifests/defines/module_dir.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/defines/module_dir.pp b/manifests/defines/module_dir.pp index 00e2a72..b48331e 100644 --- a/manifests/defines/module_dir.pp +++ b/manifests/defines/module_dir.pp @@ -28,7 +28,7 @@ define module_dir ( file { $dir: source => [ "puppet://$server/modules/${name}/module_dir", "puppet://$server/modules/common/empty"], - checksum => mtime, + #checksum => mtime, # ignore the placeholder ignore => '\.ignore', recurse => true, purge => true, force => true, -- cgit v1.2.3 From e0080adb1ca115ee98bf97c9cfb91fccbfeddaac Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sun, 27 Dec 2009 23:48:06 -0200 Subject: Reverting last changes: workaround doesn't work --- manifests/defines/module_dir.pp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/manifests/defines/module_dir.pp b/manifests/defines/module_dir.pp index b48331e..def5c94 100644 --- a/manifests/defines/module_dir.pp +++ b/manifests/defines/module_dir.pp @@ -28,13 +28,11 @@ define module_dir ( file { $dir: source => [ "puppet://$server/modules/${name}/module_dir", "puppet://$server/modules/common/empty"], - #checksum => mtime, + checksum => mtime, # ignore the placeholder ignore => '\.ignore', recurse => true, purge => true, force => true, - mode => $mode, owner => $owner, group => $group, - # TODO: remove after 0.25.2 is released, see http://projects.reductivelabs.com/issues/2786: - backup => false, + mode => $mode, owner => $owner, group => $group; } } } -- cgit v1.2.3 From a15e2be608ddb01ea8b7720a95d1886267bc6975 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Mon, 14 Feb 2011 13:23:54 -0200 Subject: Removing duplicate module_dir definition --- manifests/defines/concatenated_file.pp | 2 -- 1 file changed, 2 deletions(-) diff --git a/manifests/defines/concatenated_file.pp b/manifests/defines/concatenated_file.pp index fc2c7a3..5f1c275 100644 --- a/manifests/defines/concatenated_file.pp +++ b/manifests/defines/concatenated_file.pp @@ -4,8 +4,6 @@ # Copyright (C) 2007 David Schmitt # See LICENSE for the full license granted to you. -module_dir { "common/cf": } - # TODO: # * create the directory in _part too -- cgit v1.2.3 From 3ac7106d38966452757d10dcff0f84c6e0a90409 Mon Sep 17 00:00:00 2001 From: Jamie McClelland Date: Thu, 24 Mar 2011 11:58:06 -0400 Subject: $alias is a metaparam - using it as a variable name results in: remote: warning: alias is a metaparam; this value will inherit to all contained resources When running puppet with --verbose --- manifests/defines/module_file.pp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/manifests/defines/module_file.pp b/manifests/defines/module_file.pp index 43b3c48..44f3968 100644 --- a/manifests/defines/module_file.pp +++ b/manifests/defines/module_file.pp @@ -14,7 +14,7 @@ define module_file ( $source, $ensure = present, - $alias = undef, + $m_alias = undef, $mode = 0644, $owner = root, $group = 0 ) { @@ -23,7 +23,7 @@ define module_file ( "${common::moduledir::module_dir_path}/${name}": source => $source, ensure => $ensure, - alias => $alias, + alias => $m_alias, mode => $mode, owner => $owner, group => $group; } } @@ -32,14 +32,14 @@ define module_file ( define modules_file ( $source, $ensure = present, - $alias = undef, + $m_alias = undef, $mode = 0644, $owner = root, $group = 0 ) { module_file { $name: source => $source, ensure => $ensure, - alias => $alias, + alias => $m_alias, mode => $mode, owner => $owner, group => $group } } -- cgit v1.2.3 -- cgit v1.2.3