Skip to main content

Chef/Modernize/CronDFileOrTemplate

Cookstyle cops page

The Cookstyle cops department: Chef/Modernize

Enabled by defaultSupports autocorrectionTarget Chef Version
EnabledNo14.4+

Use the cron_d resource that ships with Chef Infra Client 14.4+ instead of manually creating the file with template, file, or cookbook_file resources.

Examples

incorrect

template '/etc/cron.d/backup' do
  source 'cron_backup_job.erb'
  owner 'root'
  group 'root'
  mode '644'
end

cookbook_file '/etc/cron.d/backup' do
  owner 'root'
  group 'root'
  mode '644'
end

file '/etc/cron.d/backup' do
  content '*/30 * * * * backup /usr/local/bin/backup_script.sh'
  owner 'root'
  group 'root'
  mode '644'
end

file '/etc/cron.d/blogs' do
  action :delete
end

file "/etc/cron.d/#{job_name}" do
  action :delete
end

file File.join('/etc/cron.d', job) do
  action :delete
end

file 'delete old cron job' do
  path '/etc/cron.d/backup'
  action :delete
end

file 'delete old cron job' do
  path "/etc/cron.d/#{job}"
  action :delete
end

file 'delete old cron job' do
  path ::File.join('/etc/cron.d', job)
  action :delete
end

correct

cron_d 'backup' do
  minute '1'
  hour '1'
  mailto 'sysadmins@example.com'
  command '/usr/local/bin/backup_script.sh'
end

cron_d 'blogs' do
  action :delete
end

Configurable attributes

NameDefault valueConfigurable values
Version Added6.13.0String
Include
    Array

    Thank you for your feedback!

    ×









    Search Results