chef 15.3.14 → 15.4.45

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/chef.gemspec +2 -2
  3. data/lib/chef/application/solo.rb +1 -1
  4. data/lib/chef/event_dispatch/dispatcher.rb +9 -2
  5. data/lib/chef/formatters/doc.rb +3 -3
  6. data/lib/chef/knife.rb +13 -3
  7. data/lib/chef/knife/bootstrap.rb +28 -4
  8. data/lib/chef/knife/bootstrap/templates/chef-full.erb +7 -8
  9. data/lib/chef/knife/data_bag_secret_options.rb +11 -4
  10. data/lib/chef/knife/download.rb +2 -2
  11. data/lib/chef/knife/exec.rb +9 -1
  12. data/lib/chef/knife/ssh.rb +1 -1
  13. data/lib/chef/knife/ssl_check.rb +1 -1
  14. data/lib/chef/knife/supermarket_list.rb +19 -7
  15. data/lib/chef/knife/supermarket_search.rb +3 -2
  16. data/lib/chef/node/attribute.rb +2 -0
  17. data/lib/chef/node/attribute_collections.rb +8 -0
  18. data/lib/chef/node/immutable_collections.rb +12 -0
  19. data/lib/chef/node/mixin/immutablize_array.rb +1 -0
  20. data/lib/chef/node/mixin/immutablize_hash.rb +1 -0
  21. data/lib/chef/provider.rb +14 -8
  22. data/lib/chef/provider/package/chocolatey.rb +11 -3
  23. data/lib/chef/provider/package/dnf/python_helper.rb +8 -3
  24. data/lib/chef/provider/package/windows/exe.rb +2 -2
  25. data/lib/chef/provider/package/windows/msi.rb +3 -3
  26. data/lib/chef/provider/package/yum/python_helper.rb +8 -3
  27. data/lib/chef/provider/service/windows.rb +1 -1
  28. data/lib/chef/resource/apt_repository.rb +19 -13
  29. data/lib/chef/resource/apt_update.rb +15 -1
  30. data/lib/chef/resource/archive_file.rb +10 -1
  31. data/lib/chef/resource/build_essential.rb +14 -1
  32. data/lib/chef/resource/chocolatey_config.rb +17 -1
  33. data/lib/chef/resource/chocolatey_feature.rb +15 -0
  34. data/lib/chef/resource/chocolatey_package.rb +31 -1
  35. data/lib/chef/resource/chocolatey_source.rb +17 -1
  36. data/lib/chef/resource/cookbook_file.rb +1 -1
  37. data/lib/chef/resource/cron_access.rb +22 -1
  38. data/lib/chef/resource/cron_d.rb +46 -1
  39. data/lib/chef/resource/dmg_package.rb +28 -0
  40. data/lib/chef/resource/kernel_module.rb +61 -0
  41. data/lib/chef/resource/sudo.rb +2 -2
  42. data/lib/chef/resource/windows_ad_join.rb +72 -3
  43. data/lib/chef/resource/windows_service.rb +1 -1
  44. data/lib/chef/resource/windows_share.rb +2 -1
  45. data/lib/chef/shell.rb +4 -4
  46. data/lib/chef/shell/ext.rb +2 -2
  47. data/lib/chef/train_transport.rb +1 -1
  48. data/lib/chef/version.rb +1 -1
  49. data/spec/functional/resource/ifconfig_spec.rb +0 -2
  50. data/spec/functional/resource/mount_spec.rb +0 -4
  51. data/spec/functional/util/powershell/cmdlet_spec.rb +2 -2
  52. data/spec/integration/knife/chef_repo_path_spec.rb +4 -2
  53. data/spec/integration/recipes/resource_converge_if_changed_spec.rb +19 -19
  54. data/spec/spec_helper.rb +2 -0
  55. data/spec/unit/formatters/doc_spec.rb +18 -0
  56. data/spec/unit/knife/bootstrap_spec.rb +46 -10
  57. data/spec/unit/knife/supermarket_list_spec.rb +70 -0
  58. data/spec/unit/knife/supermarket_search_spec.rb +85 -0
  59. data/spec/unit/node/attribute_spec.rb +22 -0
  60. data/spec/unit/node/immutable_collections_spec.rb +72 -144
  61. data/spec/unit/provider/package/chocolatey_spec.rb +50 -35
  62. data/spec/unit/provider/package/windows/exe_spec.rb +1 -1
  63. data/spec/unit/provider/service/windows_spec.rb +23 -3
  64. data/spec/unit/resource/chocolatey_package_spec.rb +17 -2
  65. data/spec/unit/resource/windows_ad_join_spec.rb +4 -0
  66. data/spec/unit/resource/windows_service_spec.rb +5 -0
  67. data/spec/unit/resource/windows_share_spec.rb +7 -0
  68. data/tasks/docs.rb +4 -1
  69. metadata +10 -8
@@ -210,7 +210,7 @@ class Chef
210
210
  # @return [String] options from new_resource or empty string
211
211
  def cmd_args(include_source: true)
212
212
  cmd_args = [ new_resource.options ]
213
- cmd_args.push([ "-source", new_resource.source ]) if new_resource.source && include_source
213
+ cmd_args += common_options(include_source: include_source)
214
214
  cmd_args
215
215
  end
216
216
 
@@ -227,8 +227,8 @@ class Chef
227
227
  available_versions =
228
228
  begin
229
229
  cmd = [ "list", "-r", pkg ]
230
- cmd.push( [ "-source", new_resource.source ] ) if new_resource.source
231
- cmd.push( new_resource.options ) if new_resource.options
230
+ cmd += common_options
231
+ cmd.push( new_resource.list_options ) if new_resource.list_options
232
232
 
233
233
  raw = parse_list_output(*cmd)
234
234
  raw.keys.each_with_object({}) do |name, available|
@@ -272,6 +272,14 @@ class Chef
272
272
  def lowercase_names(names)
273
273
  names.map(&:downcase)
274
274
  end
275
+
276
+ def common_options(include_source: true)
277
+ args = []
278
+ args.push( [ "-source", new_resource.source ] ) if new_resource.source && include_source
279
+ args.push( [ "--user", new_resource.user ] ) if new_resource.user
280
+ args.push( [ "--password", new_resource.password ]) if new_resource.password
281
+ args
282
+ end
275
283
  end
276
284
  end
277
285
  end
@@ -38,9 +38,14 @@ class Chef
38
38
 
39
39
  def dnf_command
40
40
  # platform-python is used for system tools on RHEL 8 and is installed under /usr/libexec
41
- @dnf_command ||= which("platform-python", "python", "python3", "python2", "python2.7", extra_path: "/usr/libexec") do |f|
42
- shell_out("#{f} -c 'import dnf'").exitstatus == 0
43
- end + " #{DNF_HELPER}"
41
+ @dnf_command ||= begin
42
+ cmd = which("platform-python", "python", "python3", "python2", "python2.7", extra_path: "/usr/libexec") do |f|
43
+ shell_out("#{f} -c 'import dnf'").exitstatus == 0
44
+ end
45
+ raise Chef::Exceptions::Package, "cannot find dnf libraries, you may need to use yum_package" unless cmd
46
+
47
+ "#{cmd} #{DNF_HELPER}"
48
+ end
44
49
  end
45
50
 
46
51
  def start
@@ -64,7 +64,7 @@ class Chef
64
64
  unattended_flags,
65
65
  expand_options(new_resource.options),
66
66
  "& exit %%%%ERRORLEVEL%%%%",
67
- ].join(" "), timeout: new_resource.timeout, returns: new_resource.returns, sensitive: new_resource.sensitive
67
+ ].join(" "), default_env: false, timeout: new_resource.timeout, returns: new_resource.returns, sensitive: new_resource.sensitive
68
68
  )
69
69
  end
70
70
 
@@ -73,7 +73,7 @@ class Chef
73
73
  uninstall_entries.select { |entry| [uninstall_version].flatten.include?(entry.display_version) }
74
74
  .map(&:uninstall_string).uniq.each do |uninstall_string|
75
75
  logger.trace("Registry provided uninstall string for #{new_resource} is '#{uninstall_string}'")
76
- shell_out!(uninstall_command(uninstall_string), timeout: new_resource.timeout, returns: new_resource.returns)
76
+ shell_out!(uninstall_command(uninstall_string), default_env: false, timeout: new_resource.timeout, returns: new_resource.returns)
77
77
  end
78
78
  end
79
79
 
@@ -70,14 +70,14 @@ class Chef
70
70
  def install_package
71
71
  # We could use MsiConfigureProduct here, but we'll start off with msiexec
72
72
  logger.trace("#{new_resource} installing MSI package '#{new_resource.source}'")
73
- shell_out!("msiexec /qn /i \"#{new_resource.source}\" #{expand_options(new_resource.options)}", timeout: new_resource.timeout, returns: new_resource.returns)
73
+ shell_out!("msiexec /qn /i \"#{new_resource.source}\" #{expand_options(new_resource.options)}", default_env: false, timeout: new_resource.timeout, returns: new_resource.returns)
74
74
  end
75
75
 
76
76
  def remove_package
77
77
  # We could use MsiConfigureProduct here, but we'll start off with msiexec
78
78
  if !new_resource.source.nil? && ::File.exist?(new_resource.source)
79
79
  logger.trace("#{new_resource} removing MSI package '#{new_resource.source}'")
80
- shell_out!("msiexec /qn /x \"#{new_resource.source}\" #{expand_options(new_resource.options)}", timeout: new_resource.timeout, returns: new_resource.returns)
80
+ shell_out!("msiexec /qn /x \"#{new_resource.source}\" #{expand_options(new_resource.options)}", default_env: false, timeout: new_resource.timeout, returns: new_resource.returns)
81
81
  else
82
82
  uninstall_version = new_resource.version || installed_version
83
83
  uninstall_entries.select { |entry| [uninstall_version].flatten.include?(entry.display_version) }
@@ -86,7 +86,7 @@ class Chef
86
86
  uninstall_string += expand_options(new_resource.options)
87
87
  uninstall_string += " /q" unless uninstall_string.downcase =~ %r{ /q}
88
88
  logger.trace("#{new_resource} removing MSI package version using '#{uninstall_string}'")
89
- shell_out!(uninstall_string, timeout: new_resource.timeout, returns: new_resource.returns)
89
+ shell_out!(uninstall_string, default_env: false, timeout: new_resource.timeout, returns: new_resource.returns)
90
90
  end
91
91
  end
92
92
  end
@@ -40,9 +40,14 @@ class Chef
40
40
  YUM_HELPER = ::File.expand_path(::File.join(::File.dirname(__FILE__), "yum_helper.py")).freeze
41
41
 
42
42
  def yum_command
43
- @yum_command ||= which("platform-python", "python", "python2", "python2.7", extra_path: "/usr/libexec") do |f|
44
- shell_out("#{f} -c 'import yum'").exitstatus == 0
45
- end + " #{YUM_HELPER}"
43
+ @yum_command ||= begin
44
+ cmd = which("platform-python", "python", "python2", "python2.7", extra_path: "/usr/libexec") do |f|
45
+ shell_out("#{f} -c 'import yum'").exitstatus == 0
46
+ end
47
+ raise Chef::Exceptions::Package, "cannot find yum libraries, you may need to use dnf_package" unless cmd
48
+
49
+ "#{cmd} #{YUM_HELPER}"
50
+ end
46
51
  end
47
52
 
48
53
  def start
@@ -273,7 +273,7 @@ class Chef::Provider::Service::Windows < Chef::Provider::Service
273
273
  Win32::Service.configure(new_config)
274
274
  logger.info "#{new_resource} configured."
275
275
 
276
- grant_service_logon(new_resource.run_as_user) if new_resource.run_as_user.casecmp("localsystem") != 0
276
+ grant_service_logon(new_resource.run_as_user) if new_resource.run_as_user != "localsystem"
277
277
  end
278
278
 
279
279
  #
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Thom May (<thom@chef.io>)
3
- # Copyright:: 2016-2017, Chef Software, Inc.
3
+ # Copyright:: 2016-2019, Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -35,8 +35,9 @@ class Chef
35
35
  components ['nginx']
36
36
  end
37
37
  ```
38
- Enable Ubuntu multiverse repositories
39
- ```ruby
38
+
39
+ Enable Ubuntu multiverse repositories
40
+ ```ruby
40
41
  apt_repository 'security-ubuntu-multiverse' do
41
42
  uri 'http://security.ubuntu.com/ubuntu'
42
43
  distribution 'trusty-security'
@@ -44,14 +45,16 @@ class Chef
44
45
  deb_src true
45
46
  end
46
47
  ```
47
- Add the Nginx PPA, autodetect the key and repository url
48
- ```ruby
48
+
49
+ Add the Nginx PPA, autodetect the key and repository url
50
+ ```ruby
49
51
  apt_repository 'nginx-php' do
50
52
  uri 'ppa:nginx/stable'
51
53
  end
52
54
  ```
53
- Add the JuJu PPA, grab the key from the keyserver, and add source repo
54
- ```ruby
55
+
56
+ Add the JuJu PPA, grab the key from the keyserver, and add source repo
57
+ ```ruby
55
58
  apt_repository 'juju' do
56
59
  uri 'http://ppa.launchpad.net/juju/stable/ubuntu'
57
60
  components ['main']
@@ -62,8 +65,9 @@ class Chef
62
65
  deb_src true
63
66
  end
64
67
  ```
65
- Add repository that requires multiple keys to authenticate packages
66
- ```ruby
68
+
69
+ Add repository that requires multiple keys to authenticate packages
70
+ ```ruby
67
71
  apt_repository 'rundeck' do
68
72
  uri 'https://dl.bintray.com/rundeck/rundeck-deb'
69
73
  distribution '/'
@@ -72,8 +76,9 @@ class Chef
72
76
  action :add
73
77
  end
74
78
  ```
75
- Add the Cloudera Repo of CDH4 packages for Ubuntu 12.04 on AMD64
76
- ```ruby
79
+
80
+ Add the Cloudera Repo of CDH4 packages for Ubuntu 12.04 on AMD64
81
+ ```ruby
77
82
  apt_repository 'cloudera' do
78
83
  uri 'http://archive.cloudera.com/cdh4/ubuntu/precise/amd64/cdh'
79
84
  arch 'amd64'
@@ -82,8 +87,9 @@ class Chef
82
87
  key 'http://archive.cloudera.com/debian/archive.key'
83
88
  end
84
89
  ```
85
- Remove a repository from the list
86
- ```ruby
90
+
91
+ Remove a repository from the list
92
+ ```ruby
87
93
  apt_repository 'zenoss' do
88
94
  action :remove
89
95
  end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Thom May (<thom@chef.io>)
3
- # Copyright:: Copyright (c) 2016-2017, Chef Software Inc.
3
+ # Copyright:: Copyright (c) 2016-2019, Chef Software Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -26,6 +26,20 @@ class Chef
26
26
 
27
27
  description "Use the apt_update resource to manage APT repository updates on Debian and Ubuntu platforms."
28
28
  introduced "12.7"
29
+ examples <<~DOC
30
+ Update the Apt repository at a specified interval
31
+ ```ruby
32
+ apt_update 'all platforms' do
33
+ frequency 86400
34
+ action :periodic
35
+ end
36
+ ```
37
+
38
+ Update the Apt repository at the start of a Chef Infra Client run
39
+ ```ruby
40
+ apt_update 'update'
41
+ ```
42
+ DOC
29
43
 
30
44
  # allow bare apt_update with no name
31
45
  property :name, String, default: ""
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright 2017-2018, Chef Software Inc.
2
+ # Copyright:: Copyright 2017-2019, Chef Software Inc.
3
3
  # Author:: Jamie Winsor (<jamie@vialstudios.com>)
4
4
  # Author:: Tim Smith (<tsmith@chef.io>)
5
5
  #
@@ -30,6 +30,15 @@ class Chef
30
30
 
31
31
  introduced "15.0"
32
32
  description "Use the archive_file resource to extract archive files to disk. This resource uses the libarchive library to extract multiple archive formats including tar, gzip, bzip, and zip formats."
33
+ examples <<~DOC
34
+ Extract a zip file to a specified directory
35
+ ```ruby
36
+ archive_file 'Precompiled.zip' do
37
+ path '/tmp/Precompiled.zip'
38
+ destination '/srv/files'
39
+ end
40
+ ```
41
+ DOC
33
42
 
34
43
  property :path, String,
35
44
  name_property: true,
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: 2008-2018, Chef Software, Inc.
2
+ # Copyright:: 2008-2019, Chef Software, Inc.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -24,6 +24,19 @@ class Chef
24
24
 
25
25
  description "Use the build_essential resource to install packages required for compiling C software from source."
26
26
  introduced "14.0"
27
+ examples <<~DOC
28
+ Install compilation packages
29
+ ```ruby
30
+ build_essential
31
+ ```
32
+
33
+ Install compilation packages during the compilation phase
34
+ ```ruby
35
+ build_essential 'Install compilation tools' do
36
+ compile_time true
37
+ end
38
+ ```
39
+ DOC
27
40
 
28
41
  # this allows us to use build_essential without setting a name
29
42
  property :name, String, default: ""
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: 2018, Chef Software, Inc.
2
+ # Copyright:: 2018-2019, Chef Software, Inc.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -21,6 +21,22 @@ class Chef
21
21
 
22
22
  description "Use the chocolatey_config resource to add or remove Chocolatey configuration keys."
23
23
  introduced "14.3"
24
+ examples <<~DOC
25
+ Set the Chocolatey cacheLocation config
26
+ ```ruby
27
+ chocolatey_config 'Set cacheLocation config' do
28
+ config_key 'cacheLocation'
29
+ value 'C:\temp\choco'
30
+ end
31
+ ```
32
+
33
+ Unset a Chocolatey config
34
+ ```ruby
35
+ chocolatey_config 'BogusConfig' do
36
+ action :unset
37
+ end
38
+ ```
39
+ DOC
24
40
 
25
41
  property :config_key, String, name_property: true,
26
42
  description: "An optional property to set the config key name if it differs from the resource block's name."
@@ -21,6 +21,21 @@ class Chef
21
21
 
22
22
  description "Use the chocolatey_feature resource to enable and disable Chocolatey features."
23
23
  introduced "15.1"
24
+ examples <<~DOC
25
+ Enable the checksumFiles Chocolatey feature
26
+ ```ruby
27
+ chocolatey_feature 'checksumFiles' do
28
+ action :enable
29
+ end
30
+ ```
31
+
32
+ Disable the checksumFiles Chocolatey feature
33
+ ```ruby
34
+ chocolatey_feature 'checksumFiles' do
35
+ action :disable
36
+ end
37
+ ```
38
+ DOC
24
39
 
25
40
  property :feature_name, String, name_property: true,
26
41
  description: "The name of the Chocolatey feature to enable or disable."
@@ -26,6 +26,22 @@ class Chef
26
26
 
27
27
  description "Use the chocolatey_package resource to manage packages using Chocolatey on the Microsoft Windows platform."
28
28
  introduced "12.7"
29
+ examples <<~DOC
30
+ Install a Chocolatey package
31
+ ```ruby
32
+ chocolatey_package 'name of package' do
33
+ action :install
34
+ end
35
+ ```
36
+
37
+ Install a package with options with Chocolatey's ``--checksum`` option
38
+ ```ruby
39
+ chocolatey_package 'name of package' do
40
+ options '--checksum 1234567890'
41
+ action :install
42
+ end
43
+ ```
44
+ DOC
29
45
 
30
46
  allowed_actions :install, :upgrade, :remove, :purge, :reconfig
31
47
 
@@ -33,6 +49,18 @@ class Chef
33
49
  property :options, [String, Array],
34
50
  description: "One (or more) additional options that are passed to the command."
35
51
 
52
+ property :list_options, String,
53
+ introduced: "15.3",
54
+ description: "One (or more) additional list options that are passed to the command."
55
+
56
+ property :user, String,
57
+ introduced: "15.3",
58
+ description: "The username to authenticate feeds."
59
+
60
+ property :password, String,
61
+ introduced: "15.3",
62
+ description: "The password to authenticate to the source."
63
+
36
64
  property :package_name, [String, Array],
37
65
  description: "The name of the package. Default value: the name of the resource block.",
38
66
  coerce: proc { |x| [x].flatten }
@@ -41,9 +69,11 @@ class Chef
41
69
  description: "The version of a package to be installed or upgraded.",
42
70
  coerce: proc { |x| [x].flatten }
43
71
 
72
+ # In the choco if we have the feature useEnhancedExitCodes turned on, then choco will provide enhanced exit codes(2: no results).
73
+ # Choco exit codes https://chocolatey.org/docs/commandsinfo#exit-codes
44
74
  property :returns, [Integer, Array],
45
75
  description: "The exit code(s) returned a chocolatey package that indicate success.",
46
- default: [ 0 ], desired_state: false,
76
+ default: [ 0, 2 ], desired_state: false,
47
77
  introduced: "12.18"
48
78
  end
49
79
  end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: 2018, Chef Software, Inc.
2
+ # Copyright:: 2018-2019, Chef Software, Inc.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -21,6 +21,22 @@ class Chef
21
21
 
22
22
  description "Use the chocolatey_source resource to add, remove, enable, or disable Chocolatey sources."
23
23
  introduced "14.3"
24
+ examples <<~DOC
25
+ Add a Chocolatey source
26
+ ```ruby
27
+ chocolatey_source 'MySource' do
28
+ source 'http://example.com/something'
29
+ action :add
30
+ end
31
+ ```
32
+
33
+ Remove a Chocolatey source
34
+ ```ruby
35
+ chocolatey_source 'MySource' do
36
+ action :remove
37
+ end
38
+ ```
39
+ DOC
24
40
 
25
41
  property :source_name, String, name_property: true,
26
42
  description: "An optional property to set the source name if it differs from the resource block's name."
@@ -30,7 +30,7 @@ class Chef
30
30
 
31
31
  resource_name :cookbook_file
32
32
 
33
- description "Use the cookbook_file resource to transfer files from a sub-directory of COOKBOOK_NAME/files/ to a specified path located on a host that is running the #{Chef::Dist::CLIENT}. The file is selected according to file specificity, which allows different source files to be used based on the hostname, host platform (operating system, distro, or as appropriate), or platform version. Files that are located in the COOKBOOK_NAME/files/default sub-directory may be used on any platform.\n\nDuring a #{Chef::Dist::CLIENT} run, the checksum for each local file is calculated and then compared against the checksum for the same file as it currently exists in the cookbook on the Chef server. A file is not transferred when the checksums match. Only files that require an update are transferred from the Chef server to a node."
33
+ description "Use the cookbook_file resource to transfer files from a sub-directory of COOKBOOK_NAME/files/ to a specified path located on a host that is running the #{Chef::Dist::CLIENT}. The file is selected according to file specificity, which allows different source files to be used based on the hostname, host platform (operating system, distro, or as appropriate), or platform version. Files that are located in the COOKBOOK_NAME/files/default sub-directory may be used on any platform.\n\nDuring a #{Chef::Dist::CLIENT} run, the checksum for each local file is calculated and then compared against the checksum for the same file as it currently exists in the cookbook on the #{Chef::Dist::SERVER_PRODUCT}. A file is not transferred when the checksums match. Only files that require an update are transferred from the #{Chef::Dist::SERVER_PRODUCT} to a node."
34
34
 
35
35
  property :source, [ String, Array ],
36
36
  description: "The name of the file in COOKBOOK_NAME/files/default or the path to a file located in COOKBOOK_NAME/files. The path must include the file name and its extension. This can be used to distribute specific files depending upon the platform used.",
@@ -3,7 +3,7 @@
3
3
  # Author:: Tim Smith <tsmith@chef.io>
4
4
  #
5
5
  # Copyright:: 2014-2018, Sander Botman
6
- # Copyright:: 2018, Chef Software, Inc.
6
+ # Copyright:: 2018-2019, Chef Software, Inc.
7
7
  #
8
8
  # Licensed under the Apache License, Version 2.0 (the "License");
9
9
  # you may not use this file except in compliance with the License.
@@ -28,6 +28,27 @@ class Chef
28
28
 
29
29
  introduced "14.4"
30
30
  description "Use the cron_access resource to manage the /etc/cron.allow and /etc/cron.deny files."
31
+ examples <<~DOC
32
+ Add the mike user to cron.allow
33
+ ```ruby
34
+ cron_access 'mike'
35
+ ```
36
+
37
+ Add the mike user to cron.deny
38
+ ```ruby
39
+ cron_access 'mike' do
40
+ action :deny
41
+ end
42
+ ```
43
+
44
+ Specify the username with the user property
45
+ ```ruby
46
+ cron_access 'Deny the tomcat access to cron for security purposes' do
47
+ user 'jenkins'
48
+ action :deny
49
+ end
50
+ ```
51
+ DOC
31
52
 
32
53
  property :user, String,
33
54
  description: "An optional property to set the user name if it differs from the resource block's name.",