diff options
Diffstat (limited to 'lib/chef/provider/cron.rb')
-rw-r--r-- | lib/chef/provider/cron.rb | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/chef/provider/cron.rb b/lib/chef/provider/cron.rb index 577876ccf2..aad59d1eba 100644 --- a/lib/chef/provider/cron.rb +++ b/lib/chef/provider/cron.rb @@ -25,11 +25,11 @@ class Chef provides :cron, os: ["!aix", "!solaris2"] - SPECIAL_TIME_VALUES = [:reboot, :yearly, :annually, :monthly, :weekly, :daily, :midnight, :hourly].freeze - CRON_ATTRIBUTES = [:minute, :hour, :day, :month, :weekday, :time, :command, :mailto, :path, :shell, :home, :environment].freeze - WEEKDAY_SYMBOLS = [:sunday, :monday, :tuesday, :wednesday, :thursday, :friday, :saturday].freeze + SPECIAL_TIME_VALUES = %i{reboot yearly annually monthly weekly daily midnight hourly}.freeze + CRON_ATTRIBUTES = %i{minute hour day month weekday time command mailto path shell home environment}.freeze + WEEKDAY_SYMBOLS = %i{sunday monday tuesday wednesday thursday friday saturday}.freeze - CRON_PATTERN = /\A([-0-9*,\/]+)\s([-0-9*,\/]+)\s([-0-9*,\/]+)\s([-0-9*,\/]+|[a-zA-Z]{3})\s([-0-9*,\/]+|[a-zA-Z]{3})\s(.*)/.freeze + CRON_PATTERN = %r{\A([-0-9*,/]+)\s([-0-9*,/]+)\s([-0-9*,/]+)\s([-0-9*,/]+|[a-zA-Z]{3})\s([-0-9*,/]+|[a-zA-Z]{3})\s(.*)}.freeze SPECIAL_PATTERN = /\A(@(#{SPECIAL_TIME_VALUES.join('|')}))\s(.*)/.freeze ENV_PATTERN = /\A(\S+)=(\S*)/.freeze ENVIRONMENT_PROPERTIES = %w{MAILTO PATH SHELL HOME}.freeze @@ -203,6 +203,7 @@ class Chef def read_crontab so = shell_out!("crontab -l -u #{new_resource.user}", returns: [0, 1]) return nil if so.exitstatus == 1 + so.stdout rescue => e raise Chef::Exceptions::Cron, "Error determining state of #{new_resource.name}, error: #{e}" @@ -218,7 +219,7 @@ class Chef def get_crontab_entry newcron = "" newcron << "# Chef Name: #{new_resource.name}\n" - [ :mailto, :path, :shell, :home ].each do |v| + %i{mailto path shell home}.each do |v| newcron << "#{v.to_s.upcase}=\"#{new_resource.send(v)}\"\n" if new_resource.send(v) end new_resource.environment.each do |name, value| |