From fee5116c3ac544d48d3ba5d6b434ce953d6330b0 Mon Sep 17 00:00:00 2001 From: luke Date: Thu, 28 Sep 2006 16:34:07 +0000 Subject: Fixing reported problem of crons rewriting every time when the environment is set git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1701 980ebf18-57e1-0310-9a29-db15c13687c0 --- lib/puppet/type/cron.rb | 12 +++++++++--- test/types/cron.rb | 4 ++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/puppet/type/cron.rb b/lib/puppet/type/cron.rb index ae12f4adf..8f8e9cae6 100755 --- a/lib/puppet/type/cron.rb +++ b/lib/puppet/type/cron.rb @@ -252,7 +252,11 @@ module Puppet unmanaged environment setting is associated with a given cron job. If you already have cron jobs with environment settings, then Puppet will keep those settings in the same place in the file, - but will not associate them with a specific job." + but will not associate them with a specific job. + + Settings should be specified exactly as they should appear in + the crontab, e.g., 'PATH=/bin:/usr/bin:/usr/sbin'. Multiple + settings should be specified as an array." validate do |value| unless value =~ /^\s*(\w+)\s*=\s*(.+)\s*$/ @@ -265,7 +269,7 @@ module Puppet if @is.is_a? Array return @is.sort == @should.sort else - return @is == @should[0] + return @is == @should end end @@ -573,7 +577,9 @@ module Puppet end unless envs.empty? - hash[:environment] = envs + # We have to dup here so that we don't remove the settings + # in @is on the object. + hash[:environment] = envs.dup end hash[:user] = user diff --git a/test/types/cron.rb b/test/types/cron.rb index 2794ec358..28b80ca5e 100755 --- a/test/types/cron.rb +++ b/test/types/cron.rb @@ -481,6 +481,7 @@ class TestCron < Test::Unit::TestCase } assert_apply(cron) + cron.retrieve vals = cron.is(:environment) @@ -491,6 +492,9 @@ class TestCron < Test::Unit::TestCase assert(vals.include?(env1), "Missing first env setting") assert(vals.include?(env2), "Missing second env setting") + # Now do it again and make sure there are no changes + assert_events([], cron) + end def test_divisionnumbers -- cgit