Giter Site home page Giter Site logo

sous-chefs / cron Goto Github PK

View Code? Open in Web Editor NEW
77.0 45.0 100.0 402 KB

Development repository for the cron cookbook

Home Page: https://supermarket.chef.io/cookbooks/cron

License: Apache License 2.0

Ruby 96.18% HTML 3.82%
chef hacktoberfest chef-cookbook chef-resource cron managed-by-terraform

cron's Introduction

cron Cookbook

Cookbook Version CI State OpenCollective OpenCollective License

Installs the cron package and starts the crond service.

Note: Chef 14.4 shipped with the cron_d and cron_access (cron_manage) resources. When Chef 15.4 ships in Aug 2019 these resources will be removed from this cookbook as all users should be on Chef 14.4 or later.

Maintainers

This cookbook is maintained by the Sous Chefs. The Sous Chefs are a community of Chef cookbook maintainers working together to maintain important cookbooks. If youโ€™d like to know more please visit sous-chefs.org or come chat with us on the Chef Community Slack in #sous-chefs.

Requirements

Platforms

  • RHEL family
  • Debian family
  • Solaris family
  • FreeBSD
  • SUSE family

Chef

  • Chef 12.7+

Resources

Contributors

This project exists thanks to all the people who contribute.

Backers

Thank you to all our backers!

https://opencollective.com/sous-chefs#backers

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website.

https://opencollective.com/sous-chefs/sponsor/0/website https://opencollective.com/sous-chefs/sponsor/1/website https://opencollective.com/sous-chefs/sponsor/2/website https://opencollective.com/sous-chefs/sponsor/3/website https://opencollective.com/sous-chefs/sponsor/4/website https://opencollective.com/sous-chefs/sponsor/5/website https://opencollective.com/sous-chefs/sponsor/6/website https://opencollective.com/sous-chefs/sponsor/7/website https://opencollective.com/sous-chefs/sponsor/8/website https://opencollective.com/sous-chefs/sponsor/9/website

cron's People

Contributors

bmhughes avatar brianhays avatar cwebberops avatar damacus avatar dcrosta avatar eherot avatar grimm26 avatar grosser avatar iennae avatar jeroenj avatar jordane avatar ketank-new avatar kitchen-porter avatar koodough avatar mark-from-usds avatar mfischer-zd avatar michaeldauria avatar nathenharvey avatar nkadel-skyhook avatar patcon avatar ramereth avatar renovate[bot] avatar rmoriz avatar sbotman avatar sethvargo avatar tas50 avatar tiaz avatar wfelipe avatar xorima avatar xorimabot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cron's Issues

* is not valid value for validate_numeric

Just for information:

==> default:   Default value "*" is invalid for property minute of resource cron_d. In Chef 13 this will become an error: undefined method `validate_numeric' for #<Class:0x00000003291820>. at 1 location:
==> default:     - /var/chef/cache/cookbooks/cron/resources/d.rb:27:in `class_from_file'
==> default:   Default value "*" is invalid for property hour of resource cron_d. In Chef 13 this will become an error: undefined method `validate_numeric' for #<Class:0x00000003291820>. at 1 location:
==> default:     - /var/chef/cache/cookbooks/cron/resources/d.rb:28:in `class_from_file'
==> default:   Default value "*" is invalid for property day of resource cron_d. In Chef 13 this will become an error: undefined method `validate_numeric' for #<Class:0x00000003291820>. at 1 location:
==> default:     - /var/chef/cache/cookbooks/cron/resources/d.rb:29:in `class_from_file'
==> default:   Default value "*" is invalid for property month of resource cron_d. In Chef 13 this will become an error: undefined method `validate_month' for #<Class:0x00000003291820>. at 1 location:
==> default:     - /var/chef/cache/cookbooks/cron/resources/d.rb:30:in `class_from_file'
==> default:   Default value "*" is invalid for property weekday of resource cron_d. In Chef 13 this will become an error: undefined method `validate_dow' for #<Class:0x00000003291820>. at 1 location:
==> default:     - /var/chef/cache/cookbooks/cron/resources/d.rb:31:in `class_from_file'

.DS_Store checked into 6.1.1 supermarket source

Hello,

After the same fashion as this issue: #68

I'm finding that a .DS_Store file is present in the supermarket source for cron cookbook version 6.1.1, prohibiting successful berks upload executions ( bundle exec berks upload --except=integration )

/Users/kyle.ian/Downloads/cron 
kyleian-mbp1:cron kyle.ian$ ls -haltr
total 72
-rw-r--r--@   1 kyle.ian  staff   5.1K May 11 19:19 metadata.json
-rw-r--r--@   1 kyle.ian  staff   4.0K May 11 19:19 README.md
-rw-r--r--@   1 kyle.ian  staff   111B May 11 19:19 CONTRIBUTING.md
-rw-r--r--@   1 kyle.ian  staff   7.2K May 11 19:19 CHANGELOG.md
drwxr-xr-x@   4 kyle.ian  staff   136B Jul 13 17:48 templates
drwxr-xr-x@   4 kyle.ian  staff   136B Jul 13 17:48 resources
drwxr-xr-x@   3 kyle.ian  staff   102B Jul 13 17:48 recipes
drwxr-xr-x@   3 kyle.ian  staff   102B Jul 13 17:48 libraries
drwxr-xr-x@   3 kyle.ian  staff   102B Jul 13 17:48 attributes
drwx------+ 368 kyle.ian  staff    12K Jul 13 17:48 ..
drwxr-xr-x@  12 kyle.ian  staff   408B Jul 13 17:48 .
-rw-r--r--@   1 kyle.ian  staff   6.0K Jul 13 17:48 .DS_Store

chef --version:

Chef Development Kit Version: 2.2.1
chef-client version: 13.3.42
delivery version: master (73ebb72a6c42b3d2ff5370c476be800fee7e5427)
berks version: 6.3.1
kitchen version: 1.17.0
inspec version: 1.35.1

Support Weekdays

In cron tab you can do something like 0-2 or mon-fri . It seems the validation doesn't allow for this. The field should follow:

 # โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ min (0 - 59) 
 # โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ hour (0 - 23)
 # โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ day of month (1 - 31)
 # โ”‚ โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ month (1 - 12)
 # โ”‚ โ”‚ โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ day of week (0 - 6) (0 to 6 are Sunday to Saturday, or use names; 7 is Sunday, the same as 0)
 # โ”‚ โ”‚ โ”‚ โ”‚ โ”‚
 # โ”‚ โ”‚ โ”‚ โ”‚ โ”‚
 # * * * * *  command to execute

cron_d month option not accepting integer.

Cookbook version

4.0.0

Chef-client version

12.19.36

Platform Details

CentOS 6.8 running on AWS

Scenario:

using auto-patch cookbook to set cron job for monthly patches. auot-patch::linux recipe uses cron_d resource to create a cron job and fails when trying to set month option to 3.

Steps to Reproduce:

setting month option for cron_d to 3

Expected Result:

cron job for march gets created.

Actual Result:

fails with error Option month's value 3 is not a month spec. It does work with "mar"

172.21.16.233 [2017-03-08T15:19:49-05:00] INFO: Auto patch scheduled for 2017-03-21 at 4:0
172.21.16.233
172.21.16.233 ================================================================================
172.21.16.233 Recipe Compile Error in /var/chef/cache/cookbooks/role-base-linux-nativex/recipes/default.rb
172.21.16.233 ================================================================================
172.21.16.233
172.21.16.233 Chef::Exceptions::ValidationFailed
172.21.16.233 ----------------------------------
172.21.16.233 Option month's value tue should be a valid month spec!
172.21.16.233
172.21.16.233 Cookbook Trace:
172.21.16.233 ---------------
172.21.16.233 /var/chef/cache/cookbooks/auto-patch/recipes/default.rb:99:in block in from_file' 172.21.16.233 /var/chef/cache/cookbooks/auto-patch/recipes/default.rb:94:in from_file'
172.21.16.233 /var/chef/cache/cookbooks/autopatch-nativex/recipes/linux.rb:94:in from_file' 172.21.16.233 /var/chef/cache/cookbooks/autopatch-nativex/recipes/default.rb:18:in from_file'
172.21.16.233 /var/chef/cache/cookbooks/role-base-linux-nativex/recipes/default.rb:171:in `from_file'
172.21.16.233
172.21.16.233 Relevant File Content:
172.21.16.233 ----------------------
172.21.16.233 /var/chef/cache/cookbooks/auto-patch/recipes/default.rb:
172.21.16.233
172.21.16.233 92: end
172.21.16.233 93:
172.21.16.233 94: cron_d 'auto-patch' do
172.21.16.233 95: hour node['auto-patch']['hour']
172.21.16.233 96: minute node['auto-patch']['minute']
172.21.16.233 97: weekday node['auto-patch']['weekday']
172.21.16.233 98: day node['auto-patch']['day']
172.21.16.233 99>> month 'tue'
172.21.16.233 100: command '/usr/local/sbin/auto-patch'
172.21.16.233 101: action :delete if node['auto-patch']['disable']
172.21.16.233 102: end
172.21.16.233 103:
172.21.16.233
172.21.16.233 Platform:
172.21.16.233 ---------
172.21.16.233 x86_64-linux
172.21.16.233
172.21.16.233
172.21.16.233 Running handlers:
172.21.16.233 [2017-03-08T15:19:49-05:00] ERROR: Running exception handlers
172.21.16.233 Running handlers complete
172.21.16.233 [2017-03-08T15:19:49-05:00] ERROR: Exception handlers complete
172.21.16.233 Chef Client failed. 2 resources updated in 07 seconds
172.21.16.233 [2017-03-08T15:19:49-05:00] INFO: Sending resource update report (run-id: e794d804-909c-4ad3-ad59-5f73975b1bfe)
172.21.16.233 [2017-03-08T15:19:49-05:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
172.21.16.233 [2017-03-08T15:19:49-05:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
172.21.16.233 [2017-03-08T15:19:49-05:00] ERROR: Option month's value tue should be a valid month spec!
172.21.16.233 [2017-03-08T15:19:49-05:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

ChefSpec: NoMethodError create_cron_d

Cookbook version

5.1.0

Chef-client version

chefdk 1.4.3

Platform Details

RHEL 7

Scenario:

When testing with ChefSpec, a NoMethodError is displayed for cron_d resources and action :create:

  6) cookbook::recipe this recipe creates cron_d "backup"
     Failure/Error: expect(chef_run).to create_cron_d('backup').with(minute: 45, hour: 5, command: '/usr/local/bin/backup 2>&1 >/var/log/backup.log', user: 'root')

     NoMethodError:
       undefined method `create_cron_d' for #<RSpec::ExampleGroups::CookbookRecipe::ThisRecipe:0x000000056b79c0>
       Did you mean?  create_cron
                      create_directory
                      create_group

I noticed that this cookbook updated from 5.0.1 to 5.1.0 3 days ago. When I pin to 5.0.1, this issue does not occur.

Steps to Reproduce:

Define a cron_d resource in a recipe like so:

  cron_d 'backup' do
    minute 45
    hour 5
    command '/usr/local/bin/backup 2>&1 >/var/log/backup.log'
    user 'root'
  end

Create a test/expectation like so:

    it 'creates cron_d "backup"' do
      expect(chef_run).to create_cron_d('backup').with(minute: 45, hour: 5, command: '/usr/local/bin/backup 2>&1 >/var/log/backup.log', user: 'root')
    end

Expected Result:

My tests should pass ;)

Actual Result:

Using version 5.1.0 of this cookbook, the test should fail as ChefSpec doesn't seem able to find the create_cron_d method.

Provider cron_d doesn't handle multiple command

Hey everyone,

Apparently there is no way to specified multiple command line into the cron_d provider, do you think this is a wrong pattern? If not, could be possible then to specify a template file?

Regards,
JM

Validation doesn't accept commas or lists of parameters

While the README says:

minute, hour, day, month, weekday - schedule your cron job. These correspond exactly to their equivalents in the crontab file. All default to "*".

In actual crontab files, I can do something like 1,2,3,4 in the hour field. This cookbook does not accept that syntax, so it's not an exact equivalence. Just wanted to call that out in case someone else runs into it.

No metadata.rb or metadata.json found for cookbook cron

Cookbook version

cron version 4.0.0.

Chef-client version

Chef Client, version 12.19.33

Platform Details

ubuntu 14.04

Scenario:

install cron

Steps to Reproduce:

knife cookbook site install cron

Installing cron to /root/code/chef/cookbooks
Checking out the master branch.
Pristine copy branch (chef-vendor-cron) exists, switching to it.
Downloading cron from Supermarket at version 4.0.0 to /root/code/chef/cookbooks/cron.tar.gz
Cookbook saved: /root/code/chef/cookbooks/cron.tar.gz
Removing pre-existing version.
Uncompressing cron version 4.0.0.
Removing downloaded tarball
No changes made to cron
Checking out the master branch.
ERROR: Chef::Exceptions::MetadataNotFound: No metadata.rb or metadata.json found for cookbook cron in /root/code/chef/cookbooks

Actual Result:

ERROR: Chef::Exceptions::MetadataNotFound: No metadata.rb or metadata.json found for cookbook cron in /root/code/chef/cookbooks

cron_d LWRP should except key:value pair list for environment variables

Currently the LWRP allows you to set HOME, MAILTO, SHELL, and PATH environment variables. Beyond that there isn't any way to set additional environment variables using LWRP attributes. In my case I wanted to set the TERM environment variable and only way I can see of doing is setting environment variable inside the command.

cron_d 'blah_cron_job'
  command '/usr/bin/env TERM=xterm ... <rest of command>'
end

My preference would be the LWRP except key:value pair list for environment variables and the template (cron.d.erb) loops through list and sets them all.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

github-actions
.github/workflows/ci.yml
  • sous-chefs/.github 3.1.1
  • actions/checkout v4
  • actionshub/chef-install 3.0.0
  • actionshub/test-kitchen 3.0.0
.github/workflows/stale.yml
  • actions/stale v9

  • Check this box to trigger a request for Renovate to run again on this repository

empty or nil environment values cause cron errors

Cookbook version

1.7 ... but same code in latest https://github.com/chef-cookbooks/cron/blob/2ca55eb02a5425d780bb41aae38ecfa3f7d126e0/templates/default/cron.d.erb#L14

Chef-client version

latest

Platform Details

Ubuntu 12.04.5 LTS

Scenario:

use empty or nil env vars or env var with \n

Steps to Reproduce:

environment foo: "", bar: nil

Expected Result:

foo=""
bar=""

Actual Result:

foo=
bar=
...

which results in

Error: bad minute; while reading /etc/cron.d/env_test

Add "RANDOM_DELAY" option.

Cookbook version

cron (1.7.6)

Chef-client version

[Version of chef-client in your environment]
chef-client version: 12.10.24

Platform Details

CentOS 6 and CentOS 7

Scenario:

Randomize start times for /etc/cron.d/ managed tasks, using "RANDOM_DELAY" feature of contemporary versions of "cronie"

Steps to Reproduce:

No options to publish or manage "RANDOM_DELAY" features are in templates/default/cron.d.erb.

Expected Result:

Setting RANDOM_DELAY as an LWRP attribute should activate features documented at http://man7.org/linux/man-pages/man5/crontab.5.html

Actual Result:

Feature is unavailable.

Seeing issue with the deployment on chef 12.22.1 after recent update to this cookbook

๐Ÿ—ฃ๏ธ Foreword

Thank for taking the time to fill this bug report fully. Without it we may not be able to fix the bug, and the issue may be closed without resolution.

๐Ÿ‘ป Brief Description

A clear and concise description of what the bug is.

Getting NoMethod Error -----> unified_mode true

๐Ÿฅž Cookbook version

Version of the cookbook where you are encountering the issue. 7.0.0

๐Ÿ‘ฉโ€๐Ÿณ Chef-Infra Version

Version of chef-client in your environment. - 12.22.1

๐ŸŽฉ Platform details

Operating system distribution and release version. Cloud provider if running in the cloud.

chef_version=12.22.1
platform=amazon
platform_version=2018.03

Steps To Reproduce

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

๐Ÿš“ Expected behavior

A clear and concise description of what you expected to happen.

โž• Additional context

Getting this error from this morning

================================================================================
Recipe Compile Error in /var/chef/cache/cookbooks/cron/resources/access.rb

NoMethodError

undefined method `unified_mode' for #Class:0x0000000004d93790
Cookbook Trace:

/var/chef/cache/cookbooks/cron/resources/access.rb:24:in `class_from_file'
Relevant File Content:

/var/chef/cache/cookbooks/cron/resources/access.rb:
17: # Unless required by applicable law or agreed to in writing, software
18: # distributed under the License is distributed on an "AS IS" BASIS,
19: # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20: # See the License for the specific language governing permissions and
21: # limitations under the License.
22: #
23:
24>> unified_mode true
25:
26: property :user, String,
27: name_property: true
28:
29: action :allow do
30: with_run_context :root do
31: edit_resource(:template, '/etc/cron.allow') do |new_resource|
32: source 'cron_manage.erb'
33: cookbook 'cron'

Exception is raised on Windows during compile phase

Cookbook version

latest

Chef-client version

12.16.42

Platform Details

Windows any

Scenario:

We have a recipe which supports both Linux and Windows. That recipe uses the cron_d resource, but has a guard clause to ensure it converges only on Linux. This exception is raised in the compile phase on our Windows nodes:

https://github.com/chef-cookbooks/cron/blob/master/resources/d.rb#L53-L55

Steps to Reproduce:

# This raises the exception
cron_d scheduled_job_name do
  user    'root'
  minute  '*'
  hour    '*'
  command 'echo hello github'

  not_if { node['platform_family'] == 'windows' }
end

# This does not
unless node['platform_family'] == 'windows'
  cron_d scheduled_job_name do
    user    'root'
    minute  '*'
    hour    '*'
    command 'echo hello github'
  end
end

Expected Result:

A guard clause should not cause the exception to be raised.

Actual Result:

The exception is raised.

Default value "*" is invalid for property [...] of resource cron_d. In Chef 13 this will become an error:

Cookbook version

1.7.6

Chef-client version

12.10.24

Platform Details

Ubuntu 16.04

Scenario:

[What you are trying to achieve and you can't?]

Steps to Reproduce:

file '/var/run/chef.running' do
    action      :touch
    user        'root'
    group       'root'
    mode        '0644'
end

Expected Result:

No deprecation warnings

Actual Result:

  Default value "*" is invalid for property minute of resource cron_d. In Chef 13 this will become an error: undefined method `validate_numeric' for #<Class:0x000000023cbbd8>. at 1 location:
    - /var/chef/cache/cookbooks/cron/resources/d.rb:26:in `class_from_file'
  Default value "*" is invalid for property hour of resource cron_d. In Chef 13 this will become an error: undefined method `validate_numeric' for #<Class:0x000000023cbbd8>. at 1 location:
    - /var/chef/cache/cookbooks/cron/resources/d.rb:27:in `class_from_file'
  Default value "*" is invalid for property day of resource cron_d. In Chef 13 this will become an error: undefined method `validate_numeric' for #<Class:0x000000023cbbd8>. at 1 location:
    - /var/chef/cache/cookbooks/cron/resources/d.rb:28:in `class_from_file'
  Default value "*" is invalid for property month of resource cron_d. In Chef 13 this will become an error: undefined method `validate_month' for #<Class:0x000000023cbbd8>. at 1 location:
    - /var/chef/cache/cookbooks/cron/resources/d.rb:29:in `class_from_file'
  Default value "*" is invalid for property weekday of resource cron_d. In Chef 13 this will become an error: undefined method `validate_dow' for #<Class:0x000000023cbbd8>. at 1 location:
    - /var/chef/cache/cookbooks/cron/resources/d.rb:30:in `class_from_file'

CIS friendly permissions

Cookbook version

5.0.1

Chef-client version

13.6.4

Platform Details

RHEL 7.4.1708

Scenario:

Use cron cookbook in CIS hardened systems

Steps to Reproduce:

Use any cookbook with CRON as a dependency or directly on a CIS system

Expected Result:

Allow permissions of various cron elements to be set (not reset) CIS requirements

Actual Result:

Enforces prescribed permissions


Per CIS guidelines, the following rules are violated in this cookbook:

  • 5.1.2 Ensure permissions on /etc/crontab are configured (Scored) recommended chown root:root /etc/crontab; chmod og-rwx /etc/crontab
  • 5.1.3 Ensure permissions on /etc/cron.hourly are configured (Scored) recommended chown root:root /etc/cron.hourly ; chmod og-rwx /etc/cron.hourly
  • 5.1.4 Ensure permissions on /etc/cron.daily are configured (Scored) recommended chown root:root /etc/cron.daily ; chmod og-rwx /etc/cron.daily
  • 5.1.5 Ensure permissions on /etc/cron.weekly are configured (Scored) recommended chown root:root /etc/cron.weekly ; chmod og-rwx /etc/cron.weekly
  • 5.1.6 Ensure permissions on /etc/cron.monthly are configured (Scored) recommended chown root:root /etc/cron.monthly ; chmod og-rwx /etc/cron.monthly
  • 5.1.7 Ensure permissions on /etc/cron.d are configured (Scored) recommended chown root:root /etc/cron.d ; chmod og-rwx /etc/cron.d

Allowing a permissions set for the above resources would allow the system to be compliant and allow cookbook usage in CIS scenarios

Chef cron - Every N hours past specified hour fails

Chef-client version

  • Chef: 12.18.31

Platform Details

  • OS: Linux **** 4.14.114-105.126.amzn2.x86_64 **** x86_64 x86_64 x86_64 GNU/Linux

Scenario:

I want to run a command at every 8 hours past 2AM, for which the crontab is 0 2/8 * * *.

Steps to Reproduce:

if hour is mentioned as */8, it works fine but when we specify and numeric value like 2/8. It results in an exception.

Sample code:

cron "testing1" do
  action                          :create
  minute                          "0"
  hour                            "2/8"
  user                            "root"
  home                            "/test-dir"
  command                         "echo testing"
  shell                            "/bin/bash"
end

Expected Result:

The cron should be set as following

SHELL="/bin/bash"
HOME="/test-dir"
0 2/8 * * * echo testing

Actual Result:

Chef stacktrace

Generated at 2019-07-02 06:35:29 +0000
Chef::Exceptions::Cron: cron[testing1] (testing_cookbook::configure line 29) had an error: Chef::Exceptions::Cron: Error updating state of testing1, exit: 1
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/provider/cron.rb:231:in `write_crontab'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/provider/cron.rb:148:in `block in action_create'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/mixin/why_run.rb:52:in `add_action'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/provider.rb:176:in `converge_by'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/provider/cron.rb:147:in `action_create'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/provider.rb:145:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/resource.rb:622:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/runner.rb:69:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/runner.rb:97:in `block (2 levels) in converge'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/runner.rb:97:in `each'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/runner.rb:97:in `block in converge'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/resource_collection/resource_list.rb:94:in `block in execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/resource_collection/stepable_iterator.rb:114:in `call_iterator_block'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/resource_collection/stepable_iterator.rb:103:in `iterate'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/resource_collection/resource_list.rb:92:in `execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/runner.rb:96:in `converge'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/client.rb:670:in `block in converge'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/client.rb:665:in `catch'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/client.rb:665:in `converge'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/client.rb:704:in `converge_and_save'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/client.rb:284:in `run'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/application.rb:295:in `block in fork_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/application.rb:283:in `fork'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/application.rb:283:in `fork_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/application.rb:248:in `block in run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/local_mode.rb:44:in `with_server_connectivity'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/application.rb:236:in `run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/application/client.rb:464:in `sleep_then_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/application/client.rb:451:in `block in interval_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/application/client.rb:450:in `loop'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/application/client.rb:450:in `interval_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/application/client.rb:434:in `run_application'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/application.rb:59:in `run'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/bin/chef-client:26:in `<top (required)>'
/opt/chef/bin/chef-client:57:in `load'
/opt/chef/bin/chef-client:57:in `<main>'

>>>> Caused by Chef::Exceptions::Cron: Error updating state of testing1, exit: 1
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/provider/cron.rb:231:in `write_crontab'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/provider/cron.rb:148:in `block in action_create'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/mixin/why_run.rb:52:in `add_action'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/provider.rb:176:in `converge_by'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/provider/cron.rb:147:in `action_create'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/provider.rb:145:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/resource.rb:622:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/runner.rb:69:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/runner.rb:97:in `block (2 levels) in converge'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/runner.rb:97:in `each'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/runner.rb:97:in `block in converge'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/resource_collection/resource_list.rb:94:in `block in execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/resource_collection/stepable_iterator.rb:114:in `call_iterator_block'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/resource_collection/stepable_iterator.rb:103:in `iterate'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/resource_collection/resource_list.rb:92:in `execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/runner.rb:96:in `converge'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/client.rb:670:in `block in converge'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/client.rb:665:in `catch'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/client.rb:665:in `converge'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/client.rb:704:in `converge_and_save'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/client.rb:284:in `run'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/application.rb:295:in `block in fork_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/application.rb:283:in `fork'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/application.rb:283:in `fork_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/application.rb:248:in `block in run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/local_mode.rb:44:in `with_server_connectivity'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/application.rb:236:in `run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/application/client.rb:464:in `sleep_then_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/application/client.rb:451:in `block in interval_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/application/client.rb:450:in `loop'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/application/client.rb:450:in `interval_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/application/client.rb:434:in `run_application'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/lib/chef/application.rb:59:in `run'
/opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.18.31/bin/chef-client:26:in `<top (required)>'
/opt/chef/bin/chef-client:57:in `load'

Service enable - no implicit conversion of false into Array

I get this error about half the time I build a new box. (chef-client 12.4.1, centos7). I am unable to recreate in test kitchen.

 * yum_package[cron] action install (up to date)
 * service[cron] action enable
================================================================================
   Error executing action `enable` on resource 'service[cron]'
   ================================================================================

   TypeError
   ---------
   no implicit conversion of false into Array

   Resource Declaration:
   ---------------------
   # In /var/chef/cache/cookbooks/cron/recipes/default.rb

    31: service 'cron' do
    32:   service_name 'crond' if platform_family?('rhel', 'fedora')
    33:   service_name 'vixie-cron' if platform_family?('gentoo')
    34:   action [:enable, :start]
    35: end

   Compiled Resource:
   ------------------
   # Declared in /var/chef/cache/cookbooks/cron/recipes/default.rb:31:in `from_file'

   service("cron") do
     action [:enable, :start]
     supports {:restart=>false, :reload=>false, :status=>false}
     retries 0
     retry_delay 2
     default_guard_interpreter :default
     service_name "crond"
     pattern "cron"
     declared_type :service
     cookbook_name "cron"
     recipe_name "default"
   end

cookbook not working

Hello, trying the cookbook for our crons,
as a test Im trying something simple.
but it does not create a file on /etc/cron.d/
nor creates the cron.allow
is not neither on crontab -u www-data -l
non crontrab -l

this is ubuntu 16.04
version is the latest from chef supermarket

package node['cron']['package_name']

service 'cron' do
  service_name node['cron']['service_name']
  action [:enable, :start]
end

cron_access 'www-data' do
  action :allow
end

cron_d 'this-is-a-test' do
  cron_name 'this-is-a-test'
  minute  0
  hour    23
  command '/bin/ls'
  user    'www-data'
end

Permissions on cron.allow and cron.deny prohibit /usr/bin/crontab from reading when the binary is setgid rather than setuid

Cookbook version

6.3.0

Chef-client version

15.8.23

Platform Details

Ubuntu 18.04

Scenario:

The mode on /usr/bin/crontab is this:

vagrant@default-ubuntu-1804:~$ stat -c '%U:%G %A' /usr/bin/crontab
root:crontab -rwxr-sr-x

The cron.allow and cron.deny files are set with mode 0600, prohibiting group members from reading them. Since Ubuntu installs the crontab binary with setgid rather than setuid, the files are unreadable. When the crontab binary cannot read the files, they are ignored. This permits all users to have a crontab even if prohibited by these files.

Steps to Reproduce:

Use this cookbook on an Ubuntu 18.04 host
Deny all non-root users by using:

cron_manage 'root' do
  action :allow
end
cron_manage 'ALL' do
  action :deny
end

Expected Result:

The user should be denied the ability to install a crontab

Actual Result:

non-root users are permitted to install a crontab

Add file mode attribute

Some crontab files contain sensitive information (e.g. secret environment variables) and should not be world-readable. Allow the user to specify file modes in crontabs created by this LWRP.

.DS_Store file in supermarket source for version 1.7.2

Hello,

In cron-1.7.2 there is a file at templates/.DS_Store which prevents the cookbook from being uploaded into Chef Server via berks upload. I don't see that file here in the github repo, so I'm not sure how it's getting introduced but I thought I should report it in any case.

Thanks,
Vito

chef-client 13 now sets amazon linux machines platform_family to amazon instead of rhel

Cookbook version

4.1.0

Chef-client version

13.0.113

Platform Details

Amazon linux 2016.09 running in AWS cloud

Scenario:

converge with cron cookbook enabled

Steps to Reproduce:

create an amazon linux instance with cron::default in it's runlist

Expected Result:

convergence

Actual Result:

chef-client run errors due to wrong service name on service resource.

Convert provider to inline resources

We have some pretty confusing code to maintain compatibility with Chef 10. This should be converted to inline resources which would simplify things greatly.

Release v4.1.0 not tagged

Cookbook version

4.1.0

Scenario:

Would like to use v4.1.0 which I think removes Chef 13 deprecation warnings, there's a commit for v4.1.0 in master but no tag/release on github so we have to manually specify commit reference in order to use it. Could you hit the release button, please? Thanks!

Ubuntu 16.04 support

Cookbook version

1.7.6

Chef-client version

12.7.2

Platform Details

Ubuntu 16.04 LTS amd64

Scenario:

cron::default

Steps to Reproduce:

Run cron::default recipe at Ubuntu 16.04 kitchen

Expected Result:

it should work

Actual Result:

       Recipe: cron::default
         * apt_package[cron] action install
           - install version 3.0pl1-128ubuntu2 of package cron
         * service[cron] action enable

           ================================================================================
           Error executing action `enable` on resource 'service[cron]'
           ================================================================================

           Errno::ENOENT
           -------------
           No such file or directory - /sbin/status

           Resource Declaration:
           ---------------------
           # In /tmp/kitchen/cache/cookbooks/cron/recipes/default.rb

            24: service 'cron' do
            25:   service_name node['cron']['service_name'] unless node['cron']['service_name'].nil?
            26:   action [:enable, :start]
            27: end
            28:

           Compiled Resource:
           ------------------
           # Declared in /tmp/kitchen/cache/cookbooks/cron/recipes/default.rb:24:in `from_file'

           service("cron") do
             action [:enable, :start]
             supports {:restart=>nil, :reload=>nil, :status=>nil}
             retries 0
             retry_delay 2
             default_guard_interpreter :default
             service_name "cron"
             pattern "cron"
             declared_type :service
             cookbook_name "cron"
             recipe_name "default"
           end


       Running handlers:
       [2016-05-10T14:40:02+00:00] ERROR: Running exception handlers
       Running handlers complete
       [2016-05-10T14:40:02+00:00] ERROR: Exception handlers complete
       Chef Client failed. 4 resources updated in 14 seconds
       [2016-05-10T14:40:02+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
       [2016-05-10T14:40:02+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
       [2016-05-10T14:40:02+00:00] ERROR: service[cron] (cron::default line 24) had an error: Errno::ENOENT: No such file or directory - /sbin/status
       [2016-05-10T14:40:04+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

Unclean exit when duplicate resource names

If you accidentally create two LWRP's with the same name, you get a cryptic message that is hard to troubleshoot.

It would be nice if the LWRP could detect the duplicate name, and error gracefully.

cron_d "foo" do
  minute '0'
  hour '1'
  command 'echo foo'
end

cron_d "foo" do
  minute '0'
  hour '1'
  command 'echo foo'
end
           ================================================================================
           Error executing action `create` on resource 'template[/etc/cron.d/compresss_kafka_controller_log]'
           ================================================================================

           Chef::Exceptions::ChecksumMismatch
           ----------------------------------
           Checksum on resource (cb551a) does not match checksum on content (9a41a2)

           Resource Declaration:
           ---------------------
           # In /tmp/kitchen/cookbooks/cron/providers/d.rb

            36:   t = template "/etc/cron.d/#{new_resource.name}" do
            37:     cookbook new_resource.cookbook
            38:     source 'cron.d.erb'

            40:     variables(
            41:                 :name => new_resource.name,
            42:                 :predefined_value => new_resource.predefined_value,
            43:                 :minute => new_resource.minute,
            44:                 :hour => new_resource.hour,
            45:                 :day => new_resource.day,
            46:                 :month => new_resource.month,
            47:                 :weekday => new_resource.weekday,
            48:                 :command => new_resource.command,
            49:                 :user => new_resource.user,
            50:                 :mailto => new_resource.mailto,
            51:                 :path => new_resource.path,
            52:                 :home => new_resource.home,
            53:                 :shell => new_resource.shell,
            54:                 :comment => new_resource.comment,
            55:                 :environment => new_resource.environment
            56:       )
            57:     action :create
            58:   end
            59:   new_resource.updated_by_last_action(t.updated_by_last_action?)

           Compiled Resource:
           ------------------
           # Declared in /tmp/kitchen/cookbooks/cron/providers/d.rb:36:in `block in class_from_file'

           template("/etc/cron.d/compresss_kafka_controller_log") do
             action [:create]
             updated true
             retries 0
             retry_delay 2
             default_guard_interpreter :default
             path "/etc/cron.d/compresss_kafka_controller_log"
             backup 5
             atomic_update true
             source "cron.d.erb"
             cookbook "cron"
             variables {:name=>"compresss_kafka_controller_log", :predefined_value=>nil, :minute=>"6", :hour=>"1", :day=>"*", :month=>"*", :weekday=>"*", :command=>"/usr/bin/find /var/log/kafka -type f -name \"kafka-controller.log.*.tar.gz\" -mtime +30 -exec /bin/rm {} \\;", :user=>"root", :mailto=>nil, :path=>nil, :home=>nil, :shell=>nil, :comment=>nil, :environment=>{}}
             declared_type :template
             cookbook_name :"ND-Kafka"
             mode "0644"
             checksum "cb551a64fc961957b39ad6f2c5fbaabe1bfecb9de8955c95dd9195764058b7fe"
             owner "root"

           end


       Running handlers:
       [2015-06-01T22:52:36+00:00] ERROR: Running exception handlers
       Running handlers complete

       [2015-06-01T22:52:36+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
       Chef Client failed. 4 resources updated in 1.078846308 seconds
       [2015-06-01T22:52:36+00:00] ERROR: template[/etc/cron.d/compresss_kafka_controller_log] (/tmp/kitchen/cookbooks/cron/providers/d.rb line 36) had an error: Chef::Exceptions::ChecksumMismatch: Checksum on resource (cb551a) does not match checksum on content (9a41a2)
       [2015-06-01T22:52:36+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

predefined_value @daily does not work

I use predefined_value @daily in cron_d, and it generates * * * * * in the cron file.

Recipes:

cron_d 'hello-world' do
    predefined_value @daily
    command 'echo hello world'
end

Result:

# Crontab for hello-world managed by Chef. Changes will be overwritten.

* * * * * root echo hello world

cron.deny template rendering fails

Cookbook version

6.1.1

Chef-client version

12.22.3

Platform Details

CentOS 7

Scenario:

cron_manage deny fails because the first username is passed as nil.

Steps to Reproduce:

Use mulitple cron_manage statements

Expected Result:

A working chef run with a cron.deny file

Actual Result:

       ================================================================================
       Error executing action `create` on resource 'template[/etc/cron.deny]'
       ================================================================================
       
       Chef::Mixin::Template::TemplateError
       ------------------------------------
       comparison of NilClass with String failed
       
       Resource Declaration:
       ---------------------
       # In /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.22.3/lib/chef/dsl/declare_resource.rb
       
       158:         declare_resource(type, name, created_at, run_context: run_context, &resource_attrs_block)
       159:       end
       
       Compiled Resource:
       ------------------
       # Declared in /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/chef-12.22.3/lib/chef/dsl/declare_resource.rb:158:in `rescue in edit_resource'
       
       template("/etc/cron.deny") do
         action [:nothing]
         retries 0
         retry_delay 2
         default_guard_interpreter :default
         source "cron_manage.erb"
         cookbook "cron"
         variables {"users"=>[nil, "pdezoete", "rhuyerma"]}
         declared_type :template
         cookbook_name "matrixreloaded"
         owner nil
         group nil
         mode "0600"
         path "/etc/cron.deny"
         verifications []
       end
       
       Template Context:
       -----------------
       on line #2
         1: # Generated by Chef. Changes will be overwritten.
         2: <% @users.sort.uniq.each do |user| -%>
         3: <%= user %>
         4: <% end -%>
       
       System Info:
       ------------
       chef_version=12.22.3
       platform=centos
       platform_version=7.4.1708
       ruby=ruby 2.3.6p384 (2017-12-14 revision 61254) [x86_64-linux]
       program_name=chef-client worker: ppid=1401;start=09:39:23;
       executable=/opt/chef/bin/chef-client

Provider does not create cron.d files when run from a ruby_block that it self was run as a :delayed notification

If the CronD resource is created and run from a ruby_block that was itself run as a :delayed notification from yet another resource, then the internal template and file providers (for :create and :delete actions, respectively) never trigger.

Chef-client reports the cron_d resource as up to date, but there is no corresponding /etc/cron.d file. This is because the update_by_last_action is false as the internal file or template resource has not yet run.

Attaching a simple fix via pull request shortly.

7.0.0 don't run on chef 12.X

๐Ÿ‘ป Brief Description

cron cookbook after upgrade to 7.0 stop working on chef 12.X

๐Ÿฅž Cookbook version

7.0.0

๐Ÿ‘ฉโ€๐Ÿณ Chef-Infra Version

12.21.26

๐ŸŽฉ Platform details

linux

Steps To Reproduce

Steps to reproduce the behavior:

install cron cookbook 7.0 on chef 12.X. Run chef-client. Exception:

Compiling Cookbooks...

================================================================================
Recipe Compile Error in /var/chef/cache/cookbooks/cron/resources/access.rb
================================================================================

NoMethodError
-------------
undefined method `unified_mode' for #<Class:0x0000000004c374a0>

Cookbook Trace:
---------------
  /var/chef/cache/cookbooks/cron/resources/access.rb:24:in `class_from_file'

Relevant File Content:
----------------------
/var/chef/cache/cookbooks/cron/resources/access.rb:

 17:  # Unless required by applicable law or agreed to in writing, software
 18:  # distributed under the License is distributed on an "AS IS" BASIS,
 19:  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 20:  # See the License for the specific language governing permissions and
 21:  # limitations under the License.
 22:  #
 23:  
 24>> unified_mode true
 25:  
 26:  property :user, String,
 27:            name_property: true
 28:  
 29:  action :allow do
 30:    with_run_context :root do
 31:      edit_resource(:template, '/etc/cron.allow') do |new_resource|
 32:        source 'cron_manage.erb'
 33:        cookbook 'cron'

System Info:
------------
chef_version=12.21.26
platform=debian
platform_version=8.11
ruby=ruby 2.3.5p376 (2017-09-14 revision 59905) [x86_64-linux]
program_name=chef-client worker: ppid=10676;start=14:42:23;
executable=/opt/chef/bin/chef-client

๐Ÿš“ Expected behavior

chef is ok

โž• Additional context

Add any other context about the problem here. e.g. related issues or existing pull requests.

Travis CI?

Please set up travis.ci for this cookbook. Thanks

No resource or method named `create_template'

Cookbook version

[Version of the cookbook where you are encountering the issue]
Using cron (4.0.0)

Chef-client version

[Version of chef-client in your environment]
Using chef-client (5.0.0)

Platform Details

[Operating system distribution and release version. Cloud provider if running in the cloud]
Debian Jessie running on ec2

Scenario:

[What you are trying to achieve and you can't?]
I am trying add resource for cron_d

	minute "0"
	hour "23"
	user "root"
	command "/opt/backup.sh >> /var/log/backup.log 2>&1"
end```
### Steps to Reproduce:
[If you are filing an issue what are the things we need to do in order to repro your problem? How are you using this cookbook or any resources it includes?]
  Try to apply the resource.

### Expected Result:
[What are you expecting to happen as the consequence of above reproduction steps?]
 The resource is created.

### Actual Result:
[What actually happens after the reproduction steps? Include the error output or a link to a gist if possible.]

        ```   Error executing action `create` on resource 'cron_d[backup_files]'
           ================================================================================

           NoMethodError
           -------------
           No resource or method named `create_template' for `LWRP resource cron_d from cookbook cron action provider "backup_files"'

           Cookbook Trace:
           ---------------
           /tmp/kitchen/cache/cookbooks/cron/resources/d.rb:43:in `block in class_from_file'
           /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:78:in `run_action'
           /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in `block (2 levels) in converge'
           /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in `each'
           /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in `block in converge'
           /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:105:in `converge'

           Resource Declaration:
           ---------------------
           # In /tmp/kitchen/cache/cookbooks/recipes/backup.rb

            75: cron_d "backup_files" do
            76: 	minute "0"
            77: 	hour "23"
            78: 	user "root"
            79: 	command "/opt/backup.sh >> /var/log/backup.log 2>&1"
            80:
            81: end
            82:

           Compiled Resource:
           ------------------
           # Declared in /tmp/kitchen/cache/cookbooks/recipes/backup.rb:75:in `from_file'

           cron_d("backup_files") do
             action [:create]
             retries 0
             retry_delay 2
             default_guard_interpreter :default
             declared_type :cron_d
             cookbook_name 
             recipe_name "backup"
             minute "0"
             hour "23"
             user "root"
             command "/opt/backup.sh >> /var/log/backup.log 2>&1"
           end```

1.4.2 breaks chef-client's cron_d support

After uploading the new cron cookbook the chef-client cookbook fails with the following error when configured with the following attributes

attributes/default

normal[:chef_client] = {
  :init_style   => "none",
  :cron => { :use_cron_d => true,
             :minute     => "00",
             :hour       => "19",
  },
}


Error

  * cron_d[chef-client] action create

    ================================================================================
    Error executing action `create` on resource 'cron_d[chef-client]'
    ================================================================================

    Chef::Exceptions::ValidationFailed
    ----------------------------------
    Option month's value * should be a valid month spec!

    Cookbook Trace:
    ---------------
    /var/chef/cache/cookbooks/cron/providers/d.rb:46:in `block (2 levels) in class_from_file'
    /var/chef/cache/cookbooks/cron/providers/d.rb:36:in `block in class_from_file'

    Resource Declaration:
    ---------------------
    # In /var/chef/cache/cookbooks/chef-client/recipes/cron.rb

     88:   cron_d 'chef-client' do
     89:     minute  node['chef_client']['cron']['minute']
     90:     hour    node['chef_client']['cron']['hour']
     91:     path    node['chef_client']['cron']['path'] if node['chef_client']['cron']['path']
     92:     mailto  node['chef_client']['cron']['mailto'] if node['chef_client']['cron']['mailto']
     93:     user    'root'
     94:     cmd = ''
     94:     cmd = ''
     95:     cmd << "/bin/sleep #{sleep_time}; " if sleep_time
     96:     cmd << "#{env} #{client_bin} > #{log_file} 2>&1"
     97:     command cmd
     98:   end
     99: else

    Compiled Resource:
    ------------------
    # Declared in /var/chef/cache/cookbooks/chef-client/recipes/cron.rb:88:in `from_file'

    cron_d("chef-client") do
      action :create
      retries 0
      retry_delay 2
      guard_interpreter :default
      cookbook_name "chef-client"
      recipe_name "cron"
      minute "00"
      hour "23"
      user "root"
      command "/bin/sleep 44;  /usr/bin/chef-client > /dev/null 2>&1"
      cookbook "cron"
      day "*"
    end


Running handlers:
[2014-09-08T20:00:30-07:00] ERROR: Running exception handlers
Running handlers complete
[2014-09-08T20:00:30-07:00] ERROR: Exception handlers complete
[2014-09-08T20:00:30-07:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 1 resources updated in 19.588783447 seconds
[2014-09-08T20:00:30-07:00] ERROR: cron_d[chef-client] (chef-client::cron line 88) had an error: Chef::Exceptions::ValidationFailed: Option month's value * should be a valid month s
pec!
[2014-09-08T20:00:31-07:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.