summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-09-05 22:41:32 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-09-05 22:41:32 +0000
commitf8254c6a1a080c89608ca98b7fe8e6231a9d213f (patch)
tree01a1d2fde0c5c9c8a5e04bb8fc2564ba13c130d3 /lib
parentfa16a92ff96d37d6b0d443536218d9d46d56eadd (diff)
downloadpuppet-f8254c6a1a080c89608ca98b7fe8e6231a9d213f.tar.gz
puppet-f8254c6a1a080c89608ca98b7fe8e6231a9d213f.tar.xz
puppet-f8254c6a1a080c89608ca98b7fe8e6231a9d213f.zip
Fixing #230. If the first line in the cron tab, before the header, starts with TZ= then the header will be inserted after the TZ line.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1566 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
-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