[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch,	experimental, updated. debian/2.6.8-1-844-g7ec39d5
    Nick Lewis 
    nick at puppetlabs.com
       
    Tue May 10 08:13:02 UTC 2011
    
    
  
The following commit has been merged in the experimental branch:
commit 0c6f50cbc1409cb9e31f4f512a7ff27d4b4c5167
Author: Nick Lewis <nick at puppetlabs.com>
Date:   Tue Apr 12 15:23:26 2011 -0700
    (#775) Don't require command when removing cron entries
    
    Previously, if a cron entry had "ensure => absent" with no command specified
    and the crontab contained unmanaged entries, the entry would fail to be removed
    and every other cron entry in the catalog after it would be duplicated.
    
    Paired-With: Jesse Wolfe
diff --git a/lib/puppet/provider/cron/crontab.rb b/lib/puppet/provider/cron/crontab.rb
index 8a347b3..a554363 100755
--- a/lib/puppet/provider/cron/crontab.rb
+++ b/lib/puppet/provider/cron/crontab.rb
@@ -11,13 +11,7 @@ tab = case Facter.value(:operatingsystem)
 
 
 
-      Puppet::Type.type(:cron).provide(
-        :crontab,
-  :parent => Puppet::Provider::ParsedFile,
-  :default_target => ENV["USER"] || "root",
-        
-  :filetype => tab
-) do
+Puppet::Type.type(:cron).provide(:crontab, :parent => Puppet::Provider::ParsedFile, :default_target => ENV["USER"] || "root", :filetype => tab) do
   commands :crontab => "crontab"
 
   text_line :comment, :match => %r{^#}, :post_parse => proc { |record|
diff --git a/lib/puppet/type/cron.rb b/lib/puppet/type/cron.rb
index 4f6ea73..5083ca5 100755
--- a/lib/puppet/type/cron.rb
+++ b/lib/puppet/type/cron.rb
@@ -395,7 +395,7 @@ Puppet::Type.newtype(:cron) do
     unless ret
       case name
       when :command
-        devfail "No command, somehow"
+        devfail "No command, somehow" unless @parameters[:ensure].value == :absent
       when :special
         # nothing
       else
diff --git a/spec/unit/type/cron_spec.rb b/spec/unit/type/cron_spec.rb
index 75cc0d4..e98529c 100755
--- a/spec/unit/type/cron_spec.rb
+++ b/spec/unit/type/cron_spec.rb
@@ -478,4 +478,14 @@ describe Puppet::Type.type(:cron) do
     end
 
   end
+
+  it "should require a command when adding an entry" do
+    entry = @class.new(:name => "test_entry", :ensure => :present)
+    expect { entry.value(:command) }.should raise_error(/No command/)
+  end
+
+  it "should not require a command when removing an entry" do
+    entry = @class.new(:name => "test_entry", :ensure => :absent)
+    entry.value(:command).should == nil
+  end
 end
-- 
Puppet packaging for Debian
    
    
More information about the Pkg-puppet-devel
mailing list