diff options
| author | Nick Lewis <nick@puppetlabs.com> | 2011-04-12 15:23:26 -0700 |
|---|---|---|
| committer | Nick Lewis <nick@puppetlabs.com> | 2011-04-12 15:23:26 -0700 |
| commit | 0c6f50cbc1409cb9e31f4f512a7ff27d4b4c5167 (patch) | |
| tree | 89a4411933ef54e847d7d64de96de9814604639f | |
| parent | 789aad8dd692e1bac5748e16e0acdfada2d197c7 (diff) | |
| download | puppet-0c6f50cbc1409cb9e31f4f512a7ff27d4b4c5167.tar.gz puppet-0c6f50cbc1409cb9e31f4f512a7ff27d4b4c5167.tar.xz puppet-0c6f50cbc1409cb9e31f4f512a7ff27d4b4c5167.zip | |
(#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
| -rwxr-xr-x | lib/puppet/provider/cron/crontab.rb | 8 | ||||
| -rwxr-xr-x | lib/puppet/type/cron.rb | 2 | ||||
| -rwxr-xr-x | spec/unit/type/cron_spec.rb | 10 |
3 files changed, 12 insertions, 8 deletions
diff --git a/lib/puppet/provider/cron/crontab.rb b/lib/puppet/provider/cron/crontab.rb index 8a347b331..a554363c8 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 4f6ea733c..5083ca556 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 75cc0d484..e98529c60 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 |
