chef 16.0.257-universal-mingw32 → 16.0.275-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +30 -16
  3. data/chef.gemspec +1 -1
  4. data/lib/chef/knife/environment_compare.rb +1 -1
  5. data/lib/chef/knife/list.rb +1 -1
  6. data/lib/chef/knife/supermarket_install.rb +1 -1
  7. data/lib/chef/knife/yaml_convert.rb +2 -2
  8. data/lib/chef/provider/execute.rb +1 -1
  9. data/lib/chef/provider/package/freebsd/base.rb +2 -1
  10. data/lib/chef/provider/package/homebrew.rb +1 -1
  11. data/lib/chef/provider/package/macports.rb +0 -2
  12. data/lib/chef/provider/package/windows.rb +26 -51
  13. data/lib/chef/provider/user/dscl.rb +1 -1
  14. data/lib/chef/resource/alternatives.rb +65 -4
  15. data/lib/chef/resource/apt_package.rb +31 -2
  16. data/lib/chef/resource/apt_preference.rb +34 -5
  17. data/lib/chef/resource/apt_repository.rb +22 -15
  18. data/lib/chef/resource/apt_update.rb +6 -4
  19. data/lib/chef/resource/archive_file.rb +5 -4
  20. data/lib/chef/resource/bash.rb +1 -1
  21. data/lib/chef/resource/batch.rb +1 -1
  22. data/lib/chef/resource/bff_package.rb +1 -1
  23. data/lib/chef/resource/breakpoint.rb +1 -1
  24. data/lib/chef/resource/build_essential.rb +8 -4
  25. data/lib/chef/resource/cab_package.rb +1 -1
  26. data/lib/chef/resource/chef_client_cron.rb +12 -9
  27. data/lib/chef/resource/chef_client_scheduled_task.rb +9 -6
  28. data/lib/chef/resource/chef_client_systemd_timer.rb +10 -7
  29. data/lib/chef/resource/chef_gem.rb +6 -2
  30. data/lib/chef/resource/chef_handler.rb +1 -1
  31. data/lib/chef/resource/chef_sleep.rb +7 -4
  32. data/lib/chef/resource/chef_vault_secret.rb +3 -3
  33. data/lib/chef/resource/chocolatey_config.rb +5 -3
  34. data/lib/chef/resource/chocolatey_feature.rb +5 -3
  35. data/lib/chef/resource/chocolatey_package.rb +5 -3
  36. data/lib/chef/resource/chocolatey_source.rb +5 -3
  37. data/lib/chef/resource/cookbook_file.rb +3 -2
  38. data/lib/chef/resource/cron.rb +15 -15
  39. data/lib/chef/resource/cron_access.rb +7 -4
  40. data/lib/chef/resource/cron_d.rb +37 -23
  41. data/lib/chef/resource/csh.rb +1 -1
  42. data/lib/chef/resource/directory.rb +1 -1
  43. data/lib/chef/resource/dmg_package.rb +18 -15
  44. data/lib/chef/resource/dnf_package.rb +1 -1
  45. data/lib/chef/resource/dpkg_package.rb +1 -1
  46. data/lib/chef/resource/execute.rb +2 -2
  47. data/lib/chef/resource/file.rb +5 -4
  48. data/lib/chef/resource/freebsd_package.rb +1 -1
  49. data/lib/chef/resource/gem_package.rb +6 -6
  50. data/lib/chef/resource/group.rb +1 -1
  51. data/lib/chef/resource/homebrew_cask.rb +1 -1
  52. data/lib/chef/resource/homebrew_package.rb +1 -1
  53. data/lib/chef/resource/homebrew_tap.rb +1 -1
  54. data/lib/chef/resource/hostname.rb +4 -4
  55. data/lib/chef/resource/http_request.rb +1 -1
  56. data/lib/chef/resource/ifconfig.rb +7 -7
  57. data/lib/chef/resource/ips_package.rb +1 -1
  58. data/lib/chef/resource/kernel_module.rb +1 -1
  59. data/lib/chef/resource/ksh.rb +1 -1
  60. data/lib/chef/resource/launchd.rb +1 -1
  61. data/lib/chef/resource/link.rb +4 -4
  62. data/lib/chef/resource/locale.rb +1 -1
  63. data/lib/chef/resource/log.rb +1 -1
  64. data/lib/chef/resource/macos_userdefaults.rb +1 -1
  65. data/lib/chef/resource/macosx_service.rb +1 -1
  66. data/lib/chef/resource/macports_package.rb +1 -1
  67. data/lib/chef/resource/mdadm.rb +1 -1
  68. data/lib/chef/resource/mount.rb +1 -1
  69. data/lib/chef/resource/msu_package.rb +1 -1
  70. data/lib/chef/resource/ohai.rb +1 -1
  71. data/lib/chef/resource/ohai_hint.rb +1 -1
  72. data/lib/chef/resource/openbsd_package.rb +1 -1
  73. data/lib/chef/resource/openssl_dhparam.rb +1 -1
  74. data/lib/chef/resource/openssl_ec_private_key.rb +1 -1
  75. data/lib/chef/resource/openssl_ec_public_key.rb +1 -1
  76. data/lib/chef/resource/openssl_rsa_private_key.rb +1 -1
  77. data/lib/chef/resource/openssl_rsa_public_key.rb +1 -1
  78. data/lib/chef/resource/openssl_x509_certificate.rb +1 -1
  79. data/lib/chef/resource/openssl_x509_crl.rb +1 -1
  80. data/lib/chef/resource/openssl_x509_request.rb +1 -1
  81. data/lib/chef/resource/osx_profile.rb +1 -1
  82. data/lib/chef/resource/package.rb +1 -1
  83. data/lib/chef/resource/pacman_package.rb +1 -1
  84. data/lib/chef/resource/paludis_package.rb +1 -1
  85. data/lib/chef/resource/perl.rb +1 -1
  86. data/lib/chef/resource/plist.rb +1 -1
  87. data/lib/chef/resource/portage_package.rb +1 -1
  88. data/lib/chef/resource/powershell_package.rb +1 -1
  89. data/lib/chef/resource/powershell_package_source.rb +1 -1
  90. data/lib/chef/resource/powershell_script.rb +1 -1
  91. data/lib/chef/resource/python.rb +1 -1
  92. data/lib/chef/resource/reboot.rb +1 -1
  93. data/lib/chef/resource/registry_key.rb +1 -1
  94. data/lib/chef/resource/remote_directory.rb +1 -1
  95. data/lib/chef/resource/remote_file.rb +1 -2
  96. data/lib/chef/resource/rhsm_errata.rb +1 -3
  97. data/lib/chef/resource/rhsm_errata_level.rb +1 -1
  98. data/lib/chef/resource/rhsm_register.rb +1 -2
  99. data/lib/chef/resource/rhsm_repo.rb +1 -2
  100. data/lib/chef/resource/rhsm_subscription.rb +1 -3
  101. data/lib/chef/resource/route.rb +1 -1
  102. data/lib/chef/resource/rpm_package.rb +5 -2
  103. data/lib/chef/resource/ruby.rb +1 -1
  104. data/lib/chef/resource/ruby_block.rb +1 -4
  105. data/lib/chef/resource/scm/_scm.rb +4 -3
  106. data/lib/chef/resource/scm/git.rb +1 -1
  107. data/lib/chef/resource/scm/subversion.rb +2 -2
  108. data/lib/chef/resource/script.rb +1 -1
  109. data/lib/chef/resource/service.rb +1 -1
  110. data/lib/chef/resource/smartos_package.rb +1 -1
  111. data/lib/chef/resource/snap_package.rb +1 -1
  112. data/lib/chef/resource/solaris_package.rb +1 -1
  113. data/lib/chef/resource/ssh_known_hosts_entry.rb +1 -1
  114. data/lib/chef/resource/sudo.rb +4 -4
  115. data/lib/chef/resource/swap_file.rb +2 -2
  116. data/lib/chef/resource/sysctl.rb +61 -2
  117. data/lib/chef/resource/systemd_unit.rb +2 -2
  118. data/lib/chef/resource/timezone.rb +1 -1
  119. data/lib/chef/resource/user.rb +2 -2
  120. data/lib/chef/resource/user_ulimit.rb +24 -22
  121. data/lib/chef/resource/windows_ad_join.rb +1 -1
  122. data/lib/chef/resource/windows_auto_run.rb +2 -2
  123. data/lib/chef/resource/windows_certificate.rb +1 -1
  124. data/lib/chef/resource/windows_dfs_folder.rb +1 -1
  125. data/lib/chef/resource/windows_dfs_namespace.rb +1 -1
  126. data/lib/chef/resource/windows_dfs_server.rb +1 -1
  127. data/lib/chef/resource/windows_env.rb +10 -1
  128. data/lib/chef/resource/windows_feature.rb +57 -2
  129. data/lib/chef/resource/windows_feature_dism.rb +15 -2
  130. data/lib/chef/resource/windows_feature_powershell.rb +29 -2
  131. data/lib/chef/resource/windows_firewall_rule.rb +9 -5
  132. data/lib/chef/resource/windows_font.rb +10 -1
  133. data/lib/chef/resource/windows_package.rb +63 -3
  134. data/lib/chef/resource/windows_pagefile.rb +30 -2
  135. data/lib/chef/resource/windows_path.rb +18 -1
  136. data/lib/chef/resource/windows_printer.rb +25 -5
  137. data/lib/chef/resource/windows_printer_port.rb +29 -1
  138. data/lib/chef/resource/windows_security_policy.rb +1 -1
  139. data/lib/chef/resource/windows_service.rb +1 -1
  140. data/lib/chef/resource/windows_share.rb +21 -1
  141. data/lib/chef/resource/windows_shortcut.rb +13 -2
  142. data/lib/chef/resource/windows_task.rb +122 -8
  143. data/lib/chef/resource/windows_uac.rb +20 -1
  144. data/lib/chef/resource/windows_workgroup.rb +19 -3
  145. data/lib/chef/resource/yum_package.rb +88 -6
  146. data/lib/chef/resource/yum_repository.rb +28 -11
  147. data/lib/chef/resource/zypper_package.rb +29 -3
  148. data/lib/chef/resource/zypper_repository.rb +17 -5
  149. data/lib/chef/resource_inspector.rb +1 -1
  150. data/lib/chef/scan_access_control.rb +1 -1
  151. data/lib/chef/version.rb +1 -1
  152. data/spec/functional/resource/link_spec.rb +3 -3
  153. data/spec/functional/resource/remote_file_spec.rb +1 -1
  154. data/spec/integration/knife/raw_spec.rb +4 -4
  155. data/spec/integration/knife/redirection_spec.rb +2 -2
  156. data/spec/support/platform_helpers.rb +0 -13
  157. data/spec/support/shared/functional/http.rb +2 -2
  158. data/spec/support/shared/unit/mock_shellout.rb +1 -1
  159. data/spec/unit/file_access_control_spec.rb +1 -1
  160. data/spec/unit/mixin/shell_out_spec.rb +25 -31
  161. data/spec/unit/provider/apt_repository_spec.rb +27 -27
  162. data/spec/unit/provider/zypper_repository_spec.rb +17 -17
  163. data/spec/unit/provider_resolver_spec.rb +2 -2
  164. metadata +10 -10
@@ -24,8 +24,17 @@ class Chef
24
24
 
25
25
  provides(:windows_font) { true }
26
26
 
27
- description "Use the windows_font resource to install font files on Windows. By default, the font is sourced from the cookbook using the resource, but a URI source can be specified as well."
27
+ description "Use the **windows_font** resource to install font files on Windows. By default, the font is sourced from the cookbook using the resource, but a URI source can be specified as well."
28
28
  introduced "14.0"
29
+ examples <<~DOC
30
+ **Install a font from a https source**:
31
+
32
+ ```ruby
33
+ windows_font 'Custom.otf' do
34
+ source "https://example.com/Custom.otf"
35
+ end
36
+ ```
37
+ DOC
29
38
 
30
39
  property :font_name, String,
31
40
  description: "An optional property to set the name of the font to install if it differs from the resource block's name.",
@@ -30,8 +30,68 @@ class Chef
30
30
  provides(:windows_package) { true }
31
31
  provides :package, os: "windows"
32
32
 
33
- description "Use the windows_package resource to manage packages on the Microsoft Windows platform. The windows_package resource supports these installer formats:\n\n Microsoft Installer Package (MSI)\n Nullsoft Scriptable Install System (NSIS)\n Inno Setup (inno)\n Wise\n InstallShield\n Custom installers such as installing a non-.msi file that embeds an .msi-based installer\n"
33
+ description "Use the **windows_package** resource to manage packages on the Microsoft Windows platform. The windows_package resource supports these installer formats:\n\n Microsoft Installer Package (MSI)\n Nullsoft Scriptable Install System (NSIS)\n Inno Setup (inno)\n Wise\n InstallShield\n Custom installers such as installing a non-.msi file that embeds an .msi-based installer\n"
34
34
  introduced "11.12"
35
+ examples <<~DOC
36
+ **Install a package**:
37
+
38
+ ```ruby
39
+ windows_package '7zip' do
40
+ action :install
41
+ source 'C:\\7z920.msi'
42
+ end
43
+ ```
44
+
45
+ **Specify a URL for the source attribute**:
46
+
47
+ ```ruby
48
+ windows_package '7zip' do
49
+ source 'http://www.7-zip.org/a/7z938-x64.msi'
50
+ end
51
+ ```
52
+
53
+ **Specify path and checksum**:
54
+
55
+ ```ruby
56
+ windows_package '7zip' do
57
+ source 'http://www.7-zip.org/a/7z938-x64.msi'
58
+ checksum '7c8e873991c82ad9cfc123415254ea6101e9a645e12977dcd518979e50fdedf3'
59
+ end
60
+ ```
61
+
62
+ **Modify remote_file resource attributes**:
63
+
64
+ The windows_package resource may specify a package at a remote location using the remote_file_attributes property. This uses the remote_file resource to download the contents at the specified URL and passes in a Hash that modifies the properties of the remote_file resource.
65
+
66
+ ```ruby
67
+ windows_package '7zip' do
68
+ source 'http://www.7-zip.org/a/7z938-x64.msi'
69
+ remote_file_attributes ({
70
+ :path => 'C:\\7zip.msi',
71
+ :checksum => '7c8e873991c82ad9cfc123415254ea6101e9a645e12977dcd518979e50fdedf3'
72
+ })
73
+ end
74
+ ```
75
+
76
+ **Download a nsis (Nullsoft) package resource**:
77
+
78
+ ```ruby
79
+ windows_package 'Mercurial 3.6.1 (64-bit)' do
80
+ source 'http://mercurial.selenic.com/release/windows/Mercurial-3.6.1-x64.exe'
81
+ checksum 'febd29578cb6736163d232708b834a2ddd119aa40abc536b2c313fc5e1b5831d'
82
+ end
83
+ ```
84
+
85
+ **Download a custom package**:
86
+
87
+ ```ruby
88
+ windows_package 'Microsoft Visual C++ 2005 Redistributable' do
89
+ source 'https://download.microsoft.com/download/6/B/B/6BB661D6-A8AE-4819-B79F-236472F6070C/vcredist_x86.exe'
90
+ installer_type :custom
91
+ options '/Q'
92
+ end
93
+ ```
94
+ DOC
35
95
 
36
96
  allowed_actions :install, :remove
37
97
 
@@ -75,11 +135,11 @@ class Chef
75
135
  end
76
136
  end),
77
137
  default_description: "The resource block's name", # this property is basically a name_property but not really so we need to spell it out
78
- description: "The path to a package in the local file system. The location of the package may be at a URL. \n"
138
+ description: "The path to a package in the local file system. The location of the package may be at a URL."
79
139
 
80
140
  property :checksum, String,
81
141
  desired_state: false, coerce: (proc { |c| c.downcase }),
82
- description: "The SHA-256 checksum of the file. Use to prevent a file from being re-downloaded. When the local file matches the checksum, #{Chef::Dist::PRODUCT} does not download it. Use when a URL is specified by the source property."
142
+ description: "The SHA-256 checksum of the file. Use to prevent a file from being re-downloaded. When the local file matches the checksum, #{Chef::Dist::PRODUCT} does not download it. Use when a URL is specified by the `source` property."
83
143
 
84
144
  property :remote_file_attributes, Hash,
85
145
  desired_state: false,
@@ -22,8 +22,36 @@ class Chef
22
22
  class WindowsPagefile < Chef::Resource
23
23
  provides(:windows_pagefile) { true }
24
24
 
25
- description "Use the windows_pagefile resource to configure pagefile settings on Windows."
25
+ description "Use the **windows_pagefile** resource to configure pagefile settings on Windows."
26
26
  introduced "14.0"
27
+ examples <<~DOC
28
+ **Set the system to manage pagefiles**:
29
+
30
+ ```ruby
31
+ windows_pagefile 'Enable automatic management of pagefiles' do
32
+ automatic_managed true
33
+ end
34
+ ```
35
+
36
+ **Delete a pagefile**:
37
+
38
+ ```ruby
39
+ windows_pagefile 'Delete the pagefile' do
40
+ path 'C:\pagefile.sys'
41
+ action :delete
42
+ end
43
+ ```
44
+
45
+ **Create a pagefile with an initial and maximum size**:
46
+
47
+ ```ruby
48
+ windows_pagefile 'create the pagefile' do
49
+ path 'C:\pagefile.sys'
50
+ initial_size 100
51
+ maximum_size 200
52
+ end
53
+ ```
54
+ DOC
27
55
 
28
56
  property :path, String,
29
57
  coerce: proc { |x| x.tr("/", '\\') },
@@ -34,7 +62,7 @@ class Chef
34
62
  description: "Configures whether the system manages the pagefile size."
35
63
 
36
64
  property :automatic_managed, [TrueClass, FalseClass],
37
- description: "Enable automatic management of pagefile initial and maximum size. Setting this to true ignores 'initial_size' and 'maximum_size' properties.",
65
+ description: "Enable automatic management of pagefile initial and maximum size. Setting this to true ignores `initial_size` and `maximum_size` properties.",
38
66
  default: false
39
67
 
40
68
  property :initial_size, Integer,
@@ -23,8 +23,25 @@ class Chef
23
23
  class WindowsPath < Chef::Resource
24
24
  provides(:windows_path) { true }
25
25
 
26
- description "Use the windows_path resource to manage the path environment variable on Microsoft Windows."
26
+ description "Use the **windows_path** resource to manage the path environment variable on Microsoft Windows."
27
27
  introduced "13.4"
28
+ examples <<~DOC
29
+ **Add Sysinternals to the system path**:
30
+
31
+ ```ruby
32
+ windows_path 'C:\\Sysinternals' do
33
+ action :add
34
+ end
35
+ ```
36
+
37
+ **Remove 7-Zip from the system path**:
38
+
39
+ ```ruby
40
+ windows_path 'C:\\7-Zip' do
41
+ action :remove
42
+ end
43
+ ```
44
+ DOC
28
45
 
29
46
  allowed_actions :add, :remove
30
47
  default_action :add
@@ -26,11 +26,31 @@ class Chef
26
26
 
27
27
  provides(:windows_printer) { true }
28
28
 
29
- description "Use the windows_printer resource to setup Windows printers. Note that this doesn't currently install a printer driver. You must already have the driver installed on the system."
29
+ description "Use the **windows_printer** resource to setup Windows printers. Note that this doesn't currently install a printer driver. You must already have the driver installed on the system."
30
30
  introduced "14.0"
31
+ examples <<~DOC
32
+ **Create a printer**:
33
+
34
+ ```ruby
35
+ windows_printer 'HP LaserJet 5th Floor' do
36
+ driver_name 'HP LaserJet 4100 Series PCL6'
37
+ ipv4_address '10.4.64.38'
38
+ end
39
+ ```
40
+
41
+ **Delete a printer**:
42
+
43
+ Note: this doesn't delete the associated printer port. See windows_printer_port above for how to delete the port.
44
+
45
+ ```ruby
46
+ windows_printer 'HP LaserJet 5th Floor' do
47
+ action :delete
48
+ end
49
+ ```
50
+ DOC
31
51
 
32
52
  property :device_id, String,
33
- description: "An optional property to set the printer queue name if it differs from the resource block's name. Example: 'HP LJ 5200 in fifth floor copy room'.",
53
+ description: "An optional property to set the printer queue name if it differs from the resource block's name. Example: `HP LJ 5200 in fifth floor copy room`.",
34
54
  name_property: true
35
55
 
36
56
  property :comment, String,
@@ -45,7 +65,7 @@ class Chef
45
65
  required: true
46
66
 
47
67
  property :location, String,
48
- description: "Printer location, such as 'Fifth floor copy room'."
68
+ description: "Printer location, such as `Fifth floor copy room`."
49
69
 
50
70
  property :shared, [TrueClass, FalseClass],
51
71
  description: "Determines whether or not the printer is shared.",
@@ -55,8 +75,8 @@ class Chef
55
75
  description: "The name used to identify the shared printer."
56
76
 
57
77
  property :ipv4_address, String,
58
- description: "The IPv4 address of the printer, such as '10.4.64.23'",
59
- validation_message: "The ipv4_address property must be in the IPv4 format of WWW.XXX.YYY.ZZZ",
78
+ description: "The IPv4 address of the printer, such as `10.4.64.23`",
79
+ validation_message: "The ipv4_address property must be in the IPv4 format of `WWW.XXX.YYY.ZZZ`",
60
80
  regex: Resolv::IPv4::Regex
61
81
 
62
82
  property :exists, [TrueClass, FalseClass],
@@ -26,8 +26,36 @@ class Chef
26
26
 
27
27
  provides(:windows_printer_port) { true }
28
28
 
29
- description "Use the windows_printer_port resource to create and delete TCP/IPv4 printer ports on Windows."
29
+ description "Use the **windows_printer_port** resource to create and delete TCP/IPv4 printer ports on Windows."
30
30
  introduced "14.0"
31
+ examples <<~DOC
32
+ **Delete a printer port**
33
+
34
+ ```ruby
35
+ windows_printer_port '10.4.64.37' do
36
+ action :delete
37
+ end
38
+ ```
39
+
40
+ **Delete a port with a custom port_name**
41
+
42
+ ```ruby
43
+ windows_printer_port '10.4.64.38' do
44
+ port_name 'My awesome port'
45
+ action :delete
46
+ end
47
+ ```
48
+
49
+ **Create a port with more options**
50
+
51
+ ```ruby
52
+ windows_printer_port '10.4.64.39' do
53
+ port_name 'My awesome port'
54
+ snmp_enabled true
55
+ port_protocol 2
56
+ end
57
+ ```
58
+ DOC
31
59
 
32
60
  property :ipv4_address, String,
33
61
  name_property: true,
@@ -40,7 +40,7 @@ class Chef
40
40
  EnableAdminAccount
41
41
  EnableGuestAccount
42
42
  }
43
- description "Use the windows_security_policy resource to set a security policy on the Microsoft Windows platform."
43
+ description "Use the **windows_security_policy** resource to set a security policy on the Microsoft Windows platform."
44
44
  introduced "16.0"
45
45
 
46
46
  property :secoption, String, name_property: true, required: true, equal_to: policy_names,
@@ -36,7 +36,7 @@ class Chef
36
36
  provides(:windows_service) { true }
37
37
  provides :service, os: "windows"
38
38
 
39
- description "Use the windows_service resource to create, delete, or manage a service on the Microsoft Windows platform."
39
+ description "Use the **windows_service** resource to create, delete, or manage a service on the Microsoft Windows platform."
40
40
  introduced "12.0"
41
41
 
42
42
  allowed_actions :configure_startup, :create, :delete, :configure
@@ -28,8 +28,28 @@ class Chef
28
28
  class WindowsShare < Chef::Resource
29
29
  provides :windows_share
30
30
 
31
- description "Use the windows_share resource to create, modify and remove Windows shares."
31
+ description "Use the **windows_share** resource to create, modify and remove Windows shares."
32
32
  introduced "14.7"
33
+ examples <<~DOC
34
+ **Create a share**:
35
+
36
+ ```ruby
37
+ windows_share 'foo' do
38
+ action :create
39
+ path 'C:\\foo'
40
+ full_users ['DOMAIN_A\\some_user', 'DOMAIN_B\\some_other_user']
41
+ read_users ['DOMAIN_C\\Domain users']
42
+ end
43
+ ```
44
+
45
+ **Delete a share**:
46
+
47
+ ```ruby
48
+ windows_share 'foo' do
49
+ action :delete
50
+ end
51
+ ```
52
+ DOC
33
53
 
34
54
  # Specifies a name for the SMB share. The name may be composed of any valid file name characters, but must be less than 80 characters long. The names pipe and mailslot are reserved for use by the computer.
35
55
  property :share_name, String,
@@ -23,8 +23,19 @@ class Chef
23
23
  class WindowsShortcut < Chef::Resource
24
24
  provides(:windows_shortcut) { true }
25
25
 
26
- description "Use the windows_shortcut resource to create shortcut files on Windows."
26
+ description "Use the **windows_shortcut** resource to create shortcut files on Windows."
27
27
  introduced "14.0"
28
+ examples <<~DOC
29
+ **Create a shortcut with a description**:
30
+
31
+ ```ruby
32
+ windows_shortcut 'C:\\shortcut_dir.lnk' do
33
+ target 'C:\\original_dir'
34
+ description 'Make a shortcut to C:\\original_dir'
35
+ end
36
+ ```
37
+
38
+ DOC
28
39
 
29
40
  property :shortcut_name, String,
30
41
  description: "An optional property to set the shortcut name if it differs from the resource block's name.",
@@ -43,7 +54,7 @@ class Chef
43
54
  description: "Working directory to use when the target is executed."
44
55
 
45
56
  property :iconlocation, String,
46
- description: "Icon to use for the shortcut. Accepts the format of 'path, index', where index is the icon file to use. See https://msdn.microsoft.com/en-us/library/3s9bx7at.aspx for details"
57
+ description: "Icon to use for the shortcut. Accepts the format of `path, index`, where index is the icon file to use. See Microsoft's [documentation](https://msdn.microsoft.com/en-us/library/3s9bx7at.aspx) for details"
47
58
 
48
59
  load_current_value do |desired|
49
60
  require "win32ole" if RUBY_PLATFORM =~ /mswin|mingw32|windows/
@@ -24,14 +24,127 @@ class Chef
24
24
  class WindowsTask < Chef::Resource
25
25
  provides(:windows_task) { true }
26
26
 
27
- description "Use the windows_task resource to create, delete or run a Windows scheduled task. Requires Windows Server 2008 or later due to API usage."
27
+ description "Use the **windows_task** resource to create, delete or run a Windows scheduled task."
28
28
  introduced "13.0"
29
+ examples <<~DOC
30
+ **Create a scheduled task to run every 15 minutes as the Administrator user**:
31
+
32
+ ```ruby
33
+ windows_task 'chef-client' do
34
+ user 'Administrator'
35
+ password 'password'
36
+ command 'chef-client'
37
+ run_level :highest
38
+ frequency :minute
39
+ frequency_modifier 15
40
+ end
41
+ ```
42
+
43
+ **Create a scheduled task to run every 2 days**:
44
+
45
+ ``` ruby
46
+ windows_task 'chef-client' do
47
+ command 'chef-client'
48
+ run_level :highest
49
+ frequency :daily
50
+ frequency_modifier 2
51
+ end
52
+ ```
53
+
54
+ **Create a scheduled task to run on specific days of the week**:
55
+
56
+ ```ruby
57
+ windows_task 'chef-client' do
58
+ command 'chef-client'
59
+ run_level :highest
60
+ frequency :weekly
61
+ day 'Mon, Thu'
62
+ end
63
+ ```
64
+
65
+ **Create a scheduled task to run only once**:
66
+
67
+ ```ruby
68
+ windows_task 'chef-client' do
69
+ command 'chef-client'
70
+ run_level :highest
71
+ frequency :once
72
+ start_time "16:10"
73
+ end
74
+ ```
75
+
76
+ **Create a scheduled task to run on current day every 3 weeks and delay upto 1 min**:
77
+
78
+ ```ruby
79
+ windows_task 'chef-client' do
80
+ command 'chef-client'
81
+ run_level :highest
82
+ frequency :weekly
83
+ frequency_modifier 3
84
+ random_delay '60'
85
+ end
86
+ ```
87
+
88
+ **Create a scheduled task to run weekly starting on Dec 28th 2018**:
89
+
90
+ ```ruby
91
+ windows_task 'chef-client 8' do
92
+ command 'chef-client'
93
+ run_level :highest
94
+ frequency :weekly
95
+ start_day '12/28/2018'
96
+ end
97
+ ```
98
+
99
+ **Create a scheduled task to run every Monday, Friday every 2 weeks**:
100
+
101
+ ```ruby
102
+ windows_task 'chef-client' do
103
+ command 'chef-client'
104
+ run_level :highest
105
+ frequency :weekly
106
+ frequency_modifier 2
107
+ day 'Mon, Fri'
108
+ end
109
+ ```
110
+
111
+ **Create a scheduled task to run when computer is idle with idle duration 20 min**:
112
+ ```ruby
113
+ windows_task 'chef-client' do
114
+ command 'chef-client'
115
+ run_level :highest
116
+ frequency :on_idle
117
+ idle_time 20
118
+ end
119
+ ```
120
+
121
+ **Delete a task named "old task"**:
122
+ ```ruby
123
+ windows_task 'old task' do
124
+ action :delete
125
+ end
126
+ ```
127
+
128
+ **Enable a task named "chef-client"**:
129
+ ```ruby
130
+ windows_task 'chef-client' do
131
+ action :enable
132
+ end
133
+ ```
134
+
135
+ **Disable a task named "ProgramDataUpdater" with TaskPath "\\Microsoft\\Windows\\Application Experience\\ProgramDataUpdater"**
136
+ ```ruby
137
+ windows_task '\\Microsoft\\Windows\\Application Experience\\ProgramDataUpdater' do
138
+ action :disable
139
+ end
140
+ ```
141
+ DOC
29
142
 
30
143
  allowed_actions :create, :delete, :run, :end, :enable, :disable, :change
31
144
  default_action :create
32
145
 
33
146
  property :task_name, String, regex: [%r{\A[^/\:\*\?\<\>\|]+\z}],
34
- description: "An optional property to set the task name if it differs from the resource block's name. Example: 'Task Name' or '/Task Name'",
147
+ description: "An optional property to set the task name if it differs from the resource block's name. Example: `Task Name` or `/Task Name`",
35
148
  name_property: true
36
149
 
37
150
  property :command, String,
@@ -46,10 +159,10 @@ class Chef
46
159
  default_description: "The localized SYSTEM user for the node."
47
160
 
48
161
  property :password, String,
49
- description: "The users password. The user property must be set if using this property."
162
+ description: "The user's password. The user property must be set if using this property."
50
163
 
51
164
  property :run_level, Symbol, equal_to: %i{highest limited},
52
- description: "Run with ':limited' or ':highest' privileges.",
165
+ description: "Run with `:limited` or `:highest` privileges.",
53
166
  default: :limited
54
167
 
55
168
  property :force, [TrueClass, FalseClass],
@@ -86,17 +199,18 @@ class Chef
86
199
  description: "The day(s) on which the task runs."
87
200
 
88
201
  property :months, String,
89
- description: "The Months of the year on which the task runs, such as: 'JAN, FEB' or '\*'. Multiple months should be comma delimited. e.g. 'Jan, Feb, Mar, Dec'."
202
+ description: "The Months of the year on which the task runs, such as: `JAN, FEB` or `*`. Multiple months should be comma delimited. e.g. `Jan, Feb, Mar, Dec`."
90
203
 
91
204
  property :idle_time, Integer,
92
- description: "For :on_idle frequency, the time (in minutes) without user activity that must pass to trigger the task, from 1 - 999."
205
+ description: "For `:on_idle` frequency, the time (in minutes) without user activity that must pass to trigger the task, from `1` - `999`."
93
206
 
94
207
  property :random_delay, [String, Integer],
95
208
  description: "Delays the task up to a given time (in seconds)."
96
209
 
97
210
  property :execution_time_limit, [String, Integer],
98
- description: "The maximum time (in seconds) the task will run.",
99
- default: "PT72H" # 72 hours in ISO8601 duration format
211
+ description: "The maximum time the task will run. This field accepts either seconds or an ISO8601 duration value.",
212
+ default: "PT72H",
213
+ default_description: "PT72H (72 hours in ISO8601 duration format)"
100
214
 
101
215
  property :minutes_duration, [String, Integer],
102
216
  description: ""