summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xlib/puppet/type/cron.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/puppet/type/cron.rb b/lib/puppet/type/cron.rb
index cabe52a40..30d88237c 100755
--- a/lib/puppet/type/cron.rb
+++ b/lib/puppet/type/cron.rb
@@ -658,7 +658,7 @@ module Puppet
def self.tab(user)
Puppet.info "Writing cron tab for %s" % user
if @instances.include?(user)
- return self.header() + @instances[user].reject { |obj|
+ tab = @instances[user].reject { |obj|
if obj.is_a?(self) and obj.should(:ensure) == :absent
true
else
@@ -672,6 +672,16 @@ module Puppet
end
}.join("\n") + "\n"
+ # Apparently Freebsd will "helpfully" add a new TZ line to every
+ # single cron line, but not in all cases (e.g., it doesn't do it
+ # on my machine. This is my attempt to fix it so the TZ lines don't
+ # multiply.
+ if tab =~ /^TZ=.+$/
+ return tab.sub(/\n/, "\n" + self.header)
+ else
+ return self.header() + tab
+ end
+
else
Puppet.notice "No cron instances for %s" % user
end
@@ -782,7 +792,6 @@ module Puppet
if @states.include?(name)
ret = @states[name].should_to_s
- #if ret == :absent or ret.nil?
if ret.nil?
ret = @states[name].is_to_s
end