Commit aaa75ede authored by Tim Smith's avatar Tim Smith
Browse files

Add a name_property if you want a more descriptive resource name

Signed-off-by: default avatarTim Smith <>
parent 107fd11f
......@@ -30,6 +30,7 @@ The `cron_d` custom resource can be used to manage files in `/etc/cron.d`. It su
#### Properties
- `cron_name` - Set the name of the cron job. If this isn't specified we'll use the resource name.
- `minute`, `hour`, `day`, `month`, `weekday` - schedule your cron job. These correspond exactly to their equivalents in the crontab file. All default to "*".
- `predefined_value` - schedule your cron job with one of the special predefined value instead of _**_ * pattern. This correspond to `"@reboot"`, `"@yearly"`, `"@annually"`, `"@monthly"`, `"@weekly"`, `"@daily"`, `"@midnight"` or `"@hourly"`.
- `command` - the command to run. Required.
......@@ -49,6 +50,16 @@ cron_d 'daily-usage-report' do
cron_d 'Setup the daily usage cron job' do
cron_name 'daily-usage-report'
minute 0
hour 23
command '/srv/app/scripts/daily_report'
user 'appuser'
## Definitions
### `cron_manage`
......@@ -19,6 +19,7 @@
require 'shellwords'
property :cron_name, name_property: true
property :cookbook, String, default: 'cron'
property :predefined_value, String, equal_to: %w( @reboot @yearly @annually @monthly @weekly @daily @midnight @hourly )
property :minute, [Integer, String], default: '*', callbacks: {
......@@ -60,7 +61,7 @@ end
action :delete do
# cleanup the legacy named job if it exists
file 'legacy named cron.d file' do
path "/etc/cron.d/#{}"
path "/etc/cron.d/#{new_resource.cron_name}"
action :delete
......@@ -71,15 +72,15 @@ end
action_class do
def sanitized_name'.', '-')'.', '-')
def create_template(create_action)
# cleanup the legacy named job if it exists
file "#{} legacy named cron.d file" do
path "/etc/cron.d/#{}"
file "#{new_resource.cron_name} legacy named cron.d file" do
path "/etc/cron.d/#{new_resource.cron_name}"
action :delete
only_if { != sanitized_name }
only_if { new_resource.cron_name != sanitized_name }
template "/etc/cron.d/#{sanitized_name}" do
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment