chef 18.9.4 → 18.11.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +16 -12
  3. data/README.md +0 -1
  4. data/Rakefile +21 -5
  5. data/chef-universal-mingw-ucrt.gemspec +4 -2
  6. data/chef.gemspec +17 -14
  7. data/lib/chef/application/apply.rb +1 -1
  8. data/lib/chef/application/base.rb +4 -4
  9. data/lib/chef/application/exit_code.rb +1 -1
  10. data/lib/chef/chef_fs/command_line.rb +4 -4
  11. data/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb +1 -1
  12. data/lib/chef/chef_fs/file_system/chef_server/cookbooks_dir.rb +2 -3
  13. data/lib/chef/client.rb +2 -3
  14. data/lib/chef/compliance/fetcher/chef_server.rb +1 -1
  15. data/lib/chef/compliance/reporter/cli.rb +2 -2
  16. data/lib/chef/compliance/runner.rb +19 -1
  17. data/lib/chef/dsl/chef_vault.rb +1 -1
  18. data/lib/chef/dsl/rest_resource.rb +223 -16
  19. data/lib/chef/encrypted_data_bag_item/decryptor.rb +1 -5
  20. data/lib/chef/environment.rb +1 -1
  21. data/lib/chef/exceptions.rb +1 -1
  22. data/lib/chef/file_cache.rb +1 -5
  23. data/lib/chef/formatters/error_description.rb +8 -1
  24. data/lib/chef/formatters/error_inspectors/compile_error_inspector.rb +1 -1
  25. data/lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb +1 -1
  26. data/lib/chef/formatters/error_inspectors/cookbook_sync_error_inspector.rb +1 -1
  27. data/lib/chef/group.rb +1 -1
  28. data/lib/chef/handler/slow_report.rb +1 -1
  29. data/lib/chef/http/authenticator.rb +25 -12
  30. data/lib/chef/mixin/api_version_request_handling.rb +1 -1
  31. data/lib/chef/mixin/powershell_type_coercions.rb +2 -2
  32. data/lib/chef/mixin/securable.rb +2 -2
  33. data/lib/chef/mixin/template.rb +25 -3
  34. data/lib/chef/mixin/versioned_api.rb +1 -1
  35. data/lib/chef/monkey_patches/net-http.rb +8 -8
  36. data/lib/chef/monkey_patches/reline-windows.rb +116 -0
  37. data/lib/chef/property.rb +1 -1
  38. data/lib/chef/provider/cron.rb +1 -1
  39. data/lib/chef/provider/directory.rb +11 -0
  40. data/lib/chef/provider/dsc_resource.rb +2 -2
  41. data/lib/chef/provider/file/content.rb +3 -2
  42. data/lib/chef/provider/file.rb +1 -1
  43. data/lib/chef/provider/git.rb +1 -1
  44. data/lib/chef/provider/ifconfig/debian.rb +1 -1
  45. data/lib/chef/provider/ifconfig/redhat.rb +1 -1
  46. data/lib/chef/provider/mount/linux.rb +1 -1
  47. data/lib/chef/provider/mount/windows.rb +4 -4
  48. data/lib/chef/provider/package/chocolatey.rb +78 -19
  49. data/lib/chef/provider/package/dnf/dnf_helper.py +355 -65
  50. data/lib/chef/provider/package/dnf/python_helper.rb +7 -4
  51. data/lib/chef/provider/package/dnf.rb +25 -6
  52. data/lib/chef/provider/package/homebrew.rb +3 -3
  53. data/lib/chef/provider/package/rubygems.rb +25 -2
  54. data/lib/chef/provider/package/snap.rb +1 -1
  55. data/lib/chef/provider/package/windows/exe.rb +1 -1
  56. data/lib/chef/provider/package/windows/msi.rb +1 -1
  57. data/lib/chef/provider/package/yum/rpm_utils.rb +2 -2
  58. data/lib/chef/provider/package/yum.rb +1 -1
  59. data/lib/chef/provider/powershell_script.rb +84 -84
  60. data/lib/chef/provider/service/debian.rb +2 -4
  61. data/lib/chef/provider/user/dscl.rb +1 -1
  62. data/lib/chef/provider/user/mac.rb +1 -1
  63. data/lib/chef/provider/windows_script.rb +1 -1
  64. data/lib/chef/resource/_rest_resource.rb +9 -7
  65. data/lib/chef/resource/alternatives.rb +41 -41
  66. data/lib/chef/resource/apt_package.rb +31 -31
  67. data/lib/chef/resource/apt_preference.rb +22 -22
  68. data/lib/chef/resource/apt_repository.rb +2 -2
  69. data/lib/chef/resource/archive_file.rb +52 -18
  70. data/lib/chef/resource/bash.rb +129 -129
  71. data/lib/chef/resource/bff_package.rb +15 -15
  72. data/lib/chef/resource/breakpoint.rb +44 -44
  73. data/lib/chef/resource/cab_package.rb +22 -22
  74. data/lib/chef/resource/chef_client_config.rb +251 -89
  75. data/lib/chef/resource/chef_client_cron.rb +18 -18
  76. data/lib/chef/resource/chef_client_launchd.rb +1 -1
  77. data/lib/chef/resource/chef_client_scheduled_task.rb +31 -31
  78. data/lib/chef/resource/chef_client_systemd_timer.rb +16 -16
  79. data/lib/chef/resource/chef_client_trusted_certificate.rb +28 -28
  80. data/lib/chef/resource/chef_handler.rb +107 -107
  81. data/lib/chef/resource/chef_vault_secret.rb +1 -1
  82. data/lib/chef/resource/chocolatey_config.rb +14 -14
  83. data/lib/chef/resource/chocolatey_feature.rb +1 -1
  84. data/lib/chef/resource/chocolatey_installer.rb +60 -42
  85. data/lib/chef/resource/chocolatey_package.rb +1 -1
  86. data/lib/chef/resource/chocolatey_source.rb +15 -15
  87. data/lib/chef/resource/cron/_cron_shared.rb +0 -2
  88. data/lib/chef/resource/cron/cron.rb +70 -70
  89. data/lib/chef/resource/csh.rb +5 -5
  90. data/lib/chef/resource/directory.rb +6 -6
  91. data/lib/chef/resource/dpkg_package.rb +3 -3
  92. data/lib/chef/resource/group.rb +28 -28
  93. data/lib/chef/resource/habitat/habitat_package.rb +80 -80
  94. data/lib/chef/resource/habitat/habitat_sup.rb +93 -95
  95. data/lib/chef/resource/habitat/habitat_sup_systemd.rb +10 -10
  96. data/lib/chef/resource/habitat/habitat_sup_windows.rb +3 -3
  97. data/lib/chef/resource/habitat_config.rb +13 -13
  98. data/lib/chef/resource/habitat_install.rb +17 -17
  99. data/lib/chef/resource/habitat_service.rb +1 -1
  100. data/lib/chef/resource/habitat_user_toml.rb +12 -12
  101. data/lib/chef/resource/helpers/cron_validations.rb +2 -2
  102. data/lib/chef/resource/homebrew_cask.rb +1 -1
  103. data/lib/chef/resource/homebrew_package.rb +20 -20
  104. data/lib/chef/resource/homebrew_tap.rb +1 -1
  105. data/lib/chef/resource/hostname.rb +2 -2
  106. data/lib/chef/resource/http_request.rb +2 -2
  107. data/lib/chef/resource/ifconfig.rb +34 -34
  108. data/lib/chef/resource/inspec_input.rb +37 -37
  109. data/lib/chef/resource/inspec_waiver.rb +63 -63
  110. data/lib/chef/resource/inspec_waiver_file_entry.rb +25 -25
  111. data/lib/chef/resource/ksh.rb +5 -5
  112. data/lib/chef/resource/launchd.rb +2 -2
  113. data/lib/chef/resource/link.rb +8 -8
  114. data/lib/chef/resource/locale.rb +6 -6
  115. data/lib/chef/resource/log.rb +4 -4
  116. data/lib/chef/resource/mdadm.rb +36 -36
  117. data/lib/chef/resource/mount.rb +3 -3
  118. data/lib/chef/resource/msu_package.rb +1 -1
  119. data/lib/chef/resource/ohai.rb +32 -32
  120. data/lib/chef/resource/ohai_hint.rb +24 -24
  121. data/lib/chef/resource/openssl_ec_private_key.rb +2 -2
  122. data/lib/chef/resource/openssl_ec_public_key.rb +2 -2
  123. data/lib/chef/resource/openssl_rsa_private_key.rb +1 -1
  124. data/lib/chef/resource/openssl_rsa_public_key.rb +2 -2
  125. data/lib/chef/resource/openssl_x509_certificate.rb +1 -1
  126. data/lib/chef/resource/openssl_x509_crl.rb +15 -15
  127. data/lib/chef/resource/openssl_x509_request.rb +2 -2
  128. data/lib/chef/resource/osx_profile.rb +54 -54
  129. data/lib/chef/resource/package.rb +6 -6
  130. data/lib/chef/resource/perl.rb +5 -5
  131. data/lib/chef/resource/plist.rb +4 -4
  132. data/lib/chef/resource/powershell_package_source.rb +12 -12
  133. data/lib/chef/resource/python.rb +4 -4
  134. data/lib/chef/resource/reboot.rb +5 -5
  135. data/lib/chef/resource/registry_key.rb +81 -81
  136. data/lib/chef/resource/remote_file.rb +72 -72
  137. data/lib/chef/resource/resource_notification.rb +4 -4
  138. data/lib/chef/resource/rhsm_errata_level.rb +1 -1
  139. data/lib/chef/resource/rhsm_register.rb +2 -2
  140. data/lib/chef/resource/scm/git.rb +79 -79
  141. data/lib/chef/resource/scm/subversion.rb +9 -9
  142. data/lib/chef/resource/script.rb +3 -3
  143. data/lib/chef/resource/selinux_boolean.rb +12 -12
  144. data/lib/chef/resource/selinux_fcontext.rb +21 -21
  145. data/lib/chef/resource/selinux_install.rb +18 -18
  146. data/lib/chef/resource/selinux_login.rb +11 -11
  147. data/lib/chef/resource/selinux_module.rb +16 -16
  148. data/lib/chef/resource/selinux_permissive.rb +9 -9
  149. data/lib/chef/resource/selinux_port.rb +16 -16
  150. data/lib/chef/resource/selinux_state.rb +28 -28
  151. data/lib/chef/resource/selinux_user.rb +14 -14
  152. data/lib/chef/resource/service.rb +5 -5
  153. data/lib/chef/resource/snap_package.rb +16 -16
  154. data/lib/chef/resource/ssh_known_hosts_entry.rb +10 -10
  155. data/lib/chef/resource/sudo.rb +68 -68
  156. data/lib/chef/resource/swap_file.rb +12 -12
  157. data/lib/chef/resource/sysctl.rb +42 -42
  158. data/lib/chef/resource/systemd_unit.rb +38 -38
  159. data/lib/chef/resource/timezone.rb +16 -16
  160. data/lib/chef/resource/user/mac_user.rb +3 -3
  161. data/lib/chef/resource/user.rb +6 -6
  162. data/lib/chef/resource/user_ulimit.rb +22 -22
  163. data/lib/chef/resource/windows_ad_join.rb +25 -25
  164. data/lib/chef/resource/windows_audit_policy.rb +34 -34
  165. data/lib/chef/resource/windows_auto_run.rb +8 -8
  166. data/lib/chef/resource/windows_certificate.rb +20 -20
  167. data/lib/chef/resource/windows_defender.rb +22 -22
  168. data/lib/chef/resource/windows_defender_exclusion.rb +17 -17
  169. data/lib/chef/resource/windows_env.rb +6 -6
  170. data/lib/chef/resource/windows_feature.rb +42 -42
  171. data/lib/chef/resource/windows_feature_dism.rb +8 -8
  172. data/lib/chef/resource/windows_feature_powershell.rb +20 -20
  173. data/lib/chef/resource/windows_firewall_profile.rb +28 -28
  174. data/lib/chef/resource/windows_firewall_rule.rb +47 -47
  175. data/lib/chef/resource/windows_font.rb +7 -7
  176. data/lib/chef/resource/windows_package.rb +59 -59
  177. data/lib/chef/resource/windows_pagefile.rb +29 -29
  178. data/lib/chef/resource/windows_path.rb +12 -12
  179. data/lib/chef/resource/windows_printer.rb +28 -28
  180. data/lib/chef/resource/windows_printer_port.rb +21 -21
  181. data/lib/chef/resource/windows_security_policy.rb +23 -23
  182. data/lib/chef/resource/windows_service.rb +108 -108
  183. data/lib/chef/resource/windows_share.rb +19 -19
  184. data/lib/chef/resource/windows_shortcut.rb +7 -7
  185. data/lib/chef/resource/windows_task.rb +105 -105
  186. data/lib/chef/resource/windows_uac.rb +14 -14
  187. data/lib/chef/resource/windows_update_settings.rb +27 -27
  188. data/lib/chef/resource/windows_user_privilege.rb +59 -59
  189. data/lib/chef/resource/windows_workgroup.rb +12 -12
  190. data/lib/chef/resource/yum_package.rb +1 -1
  191. data/lib/chef/resource/yum_repository.rb +36 -36
  192. data/lib/chef/resource.rb +1 -1
  193. data/lib/chef/resource_collection/resource_set.rb +2 -3
  194. data/lib/chef/resource_inspector.rb +1 -2
  195. data/lib/chef/run_context.rb +2 -2
  196. data/lib/chef/runner.rb +1 -1
  197. data/lib/chef/secret_fetcher/akeyless_vault.rb +0 -1
  198. data/lib/chef/secret_fetcher/hashi_vault.rb +0 -1
  199. data/lib/chef/shell/ext.rb +20 -20
  200. data/lib/chef/shell/shell_session.rb +1 -1
  201. data/lib/chef/shell.rb +7 -0
  202. data/lib/chef/version.rb +1 -1
  203. data/lib/chef/version_constraint.rb +1 -1
  204. data/lib/chef/win32/file/version_info.rb +1 -1
  205. metadata +63 -38
@@ -39,111 +39,111 @@ class Chef
39
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
  examples <<~DOC
42
- **Starting Services**
43
-
44
- Start a service with a `manual` startup type:
45
-
46
- ```ruby
47
- windows_service 'BITS' do
48
- action :configure_startup
49
- startup_type :manual
50
- end
51
- ```
52
-
53
- **Creating Services**
54
-
55
- Create a service named chef-client:
56
-
57
- ```ruby
58
- windows_service 'chef-client' do
59
- action :create
60
- binary_path_name "C:\\opscode\\chef\\bin"
61
- end
62
- ```
63
-
64
- Create a service with `service_name` and `display_name`:
65
-
66
- ```ruby
67
- windows_service 'Setup chef-client as a service' do
68
- action :create
69
- display_name 'CHEF-CLIENT'
70
- service_name 'chef-client'
71
- binary_path_name "C:\\opscode\\chef\\bin"
72
- end
73
- ```
74
-
75
- Create a service with the `manual` startup type:
76
-
77
- ```ruby
78
- windows_service 'chef-client' do
79
- action :create
80
- binary_path_name "C:\\opscode\\chef\\bin"
81
- startup_type :manual
82
- end
83
- ```
84
-
85
- Create a service with the `disabled` startup type:
86
-
87
- ```ruby
88
- windows_service 'chef-client' do
89
- action :create
90
- binary_path_name "C:\\opscode\\chef\\bin"
91
- startup_type :disabled
92
- end
93
- ```
94
-
95
- Create a service with the `automatic` startup type and delayed start enabled:
96
-
97
- ```ruby
98
- windows_service 'chef-client' do
99
- action :create
100
- binary_path_name "C:\\opscode\\chef\\bin"
101
- startup_type :automatic
102
- delayed_start true
103
- end
104
- ```
105
-
106
- Create a service with a description:
107
-
108
- ```ruby
109
- windows_service 'chef-client' do
110
- action :create
111
- binary_path_name "C:\\opscode\\chef\\bin"
112
- startup_type :automatic
113
- description "Chef client as service"
114
- end
115
- ```
116
-
117
- **Deleting Services**
118
-
119
- Delete a service named chef-client:
120
-
121
- ```ruby
122
- windows_service 'chef-client' do
123
- action :delete
124
- end
125
- ```
126
-
127
- Delete a service with the `service_name` property:
128
-
129
- ```ruby
130
- windows_service 'Delete chef client' do
131
- action :delete
132
- service_name 'chef-client'
133
- end
134
- ```
135
-
136
- **Configuring Services**
137
-
138
- Change an existing service from automatic to manual startup:
139
-
140
- ```ruby
141
- windows_service 'chef-client' do
142
- action :configure
143
- binary_path_name "C:\\opscode\\chef\\bin"
144
- startup_type :manual
145
- end
146
- ```
42
+ **Starting Services**
43
+
44
+ Start a service with a `manual` startup type:
45
+
46
+ ```ruby
47
+ windows_service 'BITS' do
48
+ action :configure_startup
49
+ startup_type :manual
50
+ end
51
+ ```
52
+
53
+ **Creating Services**
54
+
55
+ Create a service named chef-client:
56
+
57
+ ```ruby
58
+ windows_service 'chef-client' do
59
+ action :create
60
+ binary_path_name "C:\\opscode\\chef\\bin"
61
+ end
62
+ ```
63
+
64
+ Create a service with `service_name` and `display_name`:
65
+
66
+ ```ruby
67
+ windows_service 'Setup chef-client as a service' do
68
+ action :create
69
+ display_name 'CHEF-CLIENT'
70
+ service_name 'chef-client'
71
+ binary_path_name "C:\\opscode\\chef\\bin"
72
+ end
73
+ ```
74
+
75
+ Create a service with the `manual` startup type:
76
+
77
+ ```ruby
78
+ windows_service 'chef-client' do
79
+ action :create
80
+ binary_path_name "C:\\opscode\\chef\\bin"
81
+ startup_type :manual
82
+ end
83
+ ```
84
+
85
+ Create a service with the `disabled` startup type:
86
+
87
+ ```ruby
88
+ windows_service 'chef-client' do
89
+ action :create
90
+ binary_path_name "C:\\opscode\\chef\\bin"
91
+ startup_type :disabled
92
+ end
93
+ ```
94
+
95
+ Create a service with the `automatic` startup type and delayed start enabled:
96
+
97
+ ```ruby
98
+ windows_service 'chef-client' do
99
+ action :create
100
+ binary_path_name "C:\\opscode\\chef\\bin"
101
+ startup_type :automatic
102
+ delayed_start true
103
+ end
104
+ ```
105
+
106
+ Create a service with a description:
107
+
108
+ ```ruby
109
+ windows_service 'chef-client' do
110
+ action :create
111
+ binary_path_name "C:\\opscode\\chef\\bin"
112
+ startup_type :automatic
113
+ description "Chef client as service"
114
+ end
115
+ ```
116
+
117
+ **Deleting Services**
118
+
119
+ Delete a service named chef-client:
120
+
121
+ ```ruby
122
+ windows_service 'chef-client' do
123
+ action :delete
124
+ end
125
+ ```
126
+
127
+ Delete a service with the `service_name` property:
128
+
129
+ ```ruby
130
+ windows_service 'Delete chef client' do
131
+ action :delete
132
+ service_name 'chef-client'
133
+ end
134
+ ```
135
+
136
+ **Configuring Services**
137
+
138
+ Change an existing service from automatic to manual startup:
139
+
140
+ ```ruby
141
+ windows_service 'chef-client' do
142
+ action :configure
143
+ binary_path_name "C:\\opscode\\chef\\bin"
144
+ startup_type :manual
145
+ end
146
+ ```
147
147
  DOC
148
148
 
149
149
  allowed_actions :configure_startup, :create, :delete, :configure
@@ -165,7 +165,7 @@ class Chef
165
165
 
166
166
  # https://github.com/chef/win32-service/blob/ffi/lib/win32/windows/constants.rb#L31-L41
167
167
  property :service_type, Integer, default: SERVICE_WIN32_OWN_PROCESS,
168
- introduced: "14.0"
168
+ introduced: "14.0"
169
169
 
170
170
  # Valid options:
171
171
  # - :automatic
@@ -226,9 +226,9 @@ class Chef
226
226
  property :run_as_user, String,
227
227
  description: "The user under which a Microsoft Windows service runs.",
228
228
  default: "localsystem",
229
- coerce: proc { |x| x.downcase }
229
+ coerce: proc(&:downcase)
230
230
 
231
- property :run_as_password, String,
231
+ property :run_as_password, String, sensitive: true,
232
232
  description: "The password for the user specified by `run_as_user`.",
233
233
  default: ""
234
234
  end
@@ -31,24 +31,24 @@ class Chef
31
31
  description "Use the **windows_share** resource to create, modify and remove Windows shares."
32
32
  introduced "14.7"
33
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
- ```
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
44
 
45
- **Delete a share**:
45
+ **Delete a share**:
46
46
 
47
- ```ruby
48
- windows_share 'foo' do
49
- action :delete
50
- end
51
- ```
47
+ ```ruby
48
+ windows_share 'foo' do
49
+ action :delete
50
+ end
51
+ ```
52
52
  DOC
53
53
 
54
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.
@@ -69,17 +69,17 @@ class Chef
69
69
  # Specifies which accounts are granted full permission to access the share. Use a comma-separated list to specify multiple accounts. An account may not be specified more than once in the FullAccess, ChangeAccess, or ReadAccess parameter lists, but may be specified once in the FullAccess, ChangeAccess, or ReadAccess parameter list and once in the NoAccess parameter list.
70
70
  property :full_users, Array,
71
71
  description: "The users that should have 'Full control' permissions on the share in domain\\username format.",
72
- default: [], coerce: proc { |u| u.sort }
72
+ default: [], coerce: proc(&:sort)
73
73
 
74
74
  # Specifies which users are granted modify permission to access the share
75
75
  property :change_users, Array,
76
76
  description: "The users that should have 'modify' permission on the share in domain\\username format.",
77
- default: [], coerce: proc { |u| u.sort }
77
+ default: [], coerce: proc(&:sort)
78
78
 
79
79
  # Specifies which users are granted read permission to access the share. Multiple users can be specified by supplying a comma-separated list.
80
80
  property :read_users, Array,
81
81
  description: "The users that should have 'read' permission on the share in domain\\username format.",
82
- default: [], coerce: proc { |u| u.sort }
82
+ default: [], coerce: proc(&:sort)
83
83
 
84
84
  # Specifies the lifetime of the new SMB share. A temporary share does not persist beyond the next restart of the computer. By default, new SMB shares are persistent, and non-temporary.
85
85
  property :temporary, [TrueClass, FalseClass],
@@ -27,14 +27,14 @@ class Chef
27
27
  description "Use the **windows_shortcut** resource to create shortcut files on Windows."
28
28
  introduced "14.0"
29
29
  examples <<~DOC
30
- **Create a shortcut with a description**:
30
+ **Create a shortcut with a description**:
31
31
 
32
- ```ruby
33
- windows_shortcut 'C:\\shortcut_dir.lnk' do
34
- target 'C:\\original_dir'
35
- description 'Make a shortcut to C:\\original_dir'
36
- end
37
- ```
32
+ ```ruby
33
+ windows_shortcut 'C:\\shortcut_dir.lnk' do
34
+ target 'C:\\original_dir'
35
+ description 'Make a shortcut to C:\\original_dir'
36
+ end
37
+ ```
38
38
  DOC
39
39
 
40
40
  property :shortcut_name, String,
@@ -33,118 +33,118 @@ class Chef
33
33
  description "Use the **windows_task** resource to create, delete or run a Windows scheduled task."
34
34
  introduced "13.0"
35
35
  examples <<~DOC
36
- **Create a scheduled task to run every 15 minutes as the Administrator user**:
37
-
38
- ```ruby
39
- windows_task 'chef-client' do
40
- user 'Administrator'
41
- password 'password'
42
- command 'chef-client'
43
- run_level :highest
44
- frequency :minute
45
- frequency_modifier 15
46
- end
47
- ```
36
+ **Create a scheduled task to run every 15 minutes as the Administrator user**:
37
+
38
+ ```ruby
39
+ windows_task 'chef-client' do
40
+ user 'Administrator'
41
+ password 'password'
42
+ command 'chef-client'
43
+ run_level :highest
44
+ frequency :minute
45
+ frequency_modifier 15
46
+ end
47
+ ```
48
48
 
49
- **Create a scheduled task to run every 2 days**:
49
+ **Create a scheduled task to run every 2 days**:
50
50
 
51
- ```ruby
52
- windows_task 'chef-client' do
53
- command 'chef-client'
54
- run_level :highest
55
- frequency :daily
56
- frequency_modifier 2
57
- end
58
- ```
51
+ ```ruby
52
+ windows_task 'chef-client' do
53
+ command 'chef-client'
54
+ run_level :highest
55
+ frequency :daily
56
+ frequency_modifier 2
57
+ end
58
+ ```
59
59
 
60
- **Create a scheduled task to run on specific days of the week**:
60
+ **Create a scheduled task to run on specific days of the week**:
61
61
 
62
- ```ruby
63
- windows_task 'chef-client' do
64
- command 'chef-client'
65
- run_level :highest
66
- frequency :weekly
67
- day 'Mon, Thu'
68
- end
69
- ```
62
+ ```ruby
63
+ windows_task 'chef-client' do
64
+ command 'chef-client'
65
+ run_level :highest
66
+ frequency :weekly
67
+ day 'Mon, Thu'
68
+ end
69
+ ```
70
70
 
71
- **Create a scheduled task to run only once**:
71
+ **Create a scheduled task to run only once**:
72
72
 
73
- ```ruby
74
- windows_task 'chef-client' do
75
- command 'chef-client'
76
- run_level :highest
77
- frequency :once
78
- start_time '16:10'
79
- end
80
- ```
73
+ ```ruby
74
+ windows_task 'chef-client' do
75
+ command 'chef-client'
76
+ run_level :highest
77
+ frequency :once
78
+ start_time '16:10'
79
+ end
80
+ ```
81
81
 
82
- **Create a scheduled task to run on current day every 3 weeks and delay upto 1 min**:
82
+ **Create a scheduled task to run on current day every 3 weeks and delay upto 1 min**:
83
83
 
84
- ```ruby
85
- windows_task 'chef-client' do
86
- command 'chef-client'
87
- run_level :highest
88
- frequency :weekly
89
- frequency_modifier 3
90
- random_delay '60'
91
- end
92
- ```
84
+ ```ruby
85
+ windows_task 'chef-client' do
86
+ command 'chef-client'
87
+ run_level :highest
88
+ frequency :weekly
89
+ frequency_modifier 3
90
+ random_delay '60'
91
+ end
92
+ ```
93
93
 
94
- **Create a scheduled task to run weekly starting on Dec 28th 2018**:
94
+ **Create a scheduled task to run weekly starting on Dec 28th 2018**:
95
95
 
96
- ```ruby
97
- windows_task 'chef-client 8' do
98
- command 'chef-client'
99
- run_level :highest
100
- frequency :weekly
101
- start_day '12/28/2018'
102
- end
103
- ```
96
+ ```ruby
97
+ windows_task 'chef-client 8' do
98
+ command 'chef-client'
99
+ run_level :highest
100
+ frequency :weekly
101
+ start_day '12/28/2018'
102
+ end
103
+ ```
104
104
 
105
- **Create a scheduled task to run every Monday, Friday every 2 weeks**:
105
+ **Create a scheduled task to run every Monday, Friday every 2 weeks**:
106
106
 
107
- ```ruby
108
- windows_task 'chef-client' do
109
- command 'chef-client'
110
- run_level :highest
111
- frequency :weekly
112
- frequency_modifier 2
113
- day 'Mon, Fri'
114
- end
115
- ```
107
+ ```ruby
108
+ windows_task 'chef-client' do
109
+ command 'chef-client'
110
+ run_level :highest
111
+ frequency :weekly
112
+ frequency_modifier 2
113
+ day 'Mon, Fri'
114
+ end
115
+ ```
116
116
 
117
- **Create a scheduled task to run when computer is idle with idle duration 20 min**:
117
+ **Create a scheduled task to run when computer is idle with idle duration 20 min**:
118
118
 
119
- ```ruby
120
- windows_task 'chef-client' do
121
- command 'chef-client'
122
- run_level :highest
123
- frequency :on_idle
124
- idle_time 20
125
- end
126
- ```
119
+ ```ruby
120
+ windows_task 'chef-client' do
121
+ command 'chef-client'
122
+ run_level :highest
123
+ frequency :on_idle
124
+ idle_time 20
125
+ end
126
+ ```
127
127
 
128
- **Delete a task named "old task"**:
129
- ```ruby
130
- windows_task 'old task' do
131
- action :delete
132
- end
133
- ```
128
+ **Delete a task named "old task"**:
129
+ ```ruby
130
+ windows_task 'old task' do
131
+ action :delete
132
+ end
133
+ ```
134
134
 
135
- **Enable a task named "chef-client"**:
136
- ```ruby
137
- windows_task 'chef-client' do
138
- action :enable
139
- end
140
- ```
135
+ **Enable a task named "chef-client"**:
136
+ ```ruby
137
+ windows_task 'chef-client' do
138
+ action :enable
139
+ end
140
+ ```
141
141
 
142
- **Disable a task named "ProgramDataUpdater" with TaskPath "\\Microsoft\\Windows\\Application Experience\\ProgramDataUpdater"**
143
- ```ruby
144
- windows_task '\\Microsoft\\Windows\\Application Experience\\ProgramDataUpdater' do
145
- action :disable
146
- end
147
- ```
142
+ **Disable a task named "ProgramDataUpdater" with TaskPath "\\Microsoft\\Windows\\Application Experience\\ProgramDataUpdater"**
143
+ ```ruby
144
+ windows_task '\\Microsoft\\Windows\\Application Experience\\ProgramDataUpdater' do
145
+ action :disable
146
+ end
147
+ ```
148
148
  DOC
149
149
 
150
150
  allowed_actions :create, :delete, :run, :end, :enable, :disable, :change
@@ -164,7 +164,7 @@ class Chef
164
164
  default: lazy { Chef::ReservedNames::Win32::Security::SID.LocalSystem.account_simple_name if ChefUtils.windows_ruby? },
165
165
  default_description: "The localized SYSTEM user for the node."
166
166
 
167
- property :password, String,
167
+ property :password, String, sensitive: true,
168
168
  description: "The user's password. The user property must be set if using this property."
169
169
 
170
170
  property :run_level, Symbol, equal_to: %i{highest limited},
@@ -202,13 +202,13 @@ class Chef
202
202
  description: "Specifies the start time to run the task, in **HH:mm** format."
203
203
 
204
204
  property :day, [String, Integer],
205
- description: <<~DOCS
206
- The day(s) on which the task runs.
207
- * Use this property when setting `frequency` to `:monthly` or `:weekly`.
208
- * Valid values with frequency `:weekly` are `MON`-`SUN` or `*`.
209
- * Valid values with frequency `:monthly` are `1-31`, `MON`-`SUN`, and `LASTDAY`.
210
- * Use `MON`-`SUN` or `LASTDAY` if you are setting `frequency_modifier` as "FIRST, SECOND, THIRD etc." else use 1-31.
211
- * Multiple days should be comma separated. e.g `1, 2, 3` or `MON, WED, FRI`.
205
+ description: <<~DOCS
206
+ The day(s) on which the task runs.
207
+ * Use this property when setting `frequency` to `:monthly` or `:weekly`.
208
+ * Valid values with frequency `:weekly` are `MON`-`SUN` or `*`.
209
+ * Valid values with frequency `:monthly` are `1-31`, `MON`-`SUN`, and `LASTDAY`.
210
+ * Use `MON`-`SUN` or `LASTDAY` if you are setting `frequency_modifier` as "FIRST, SECOND, THIRD etc." else use 1-31.
211
+ * Multiple days should be comma separated. e.g `1, 2, 3` or `MON, WED, FRI`.
212
212
  DOCS
213
213
 
214
214
  property :months, String,
@@ -233,7 +233,7 @@ class Chef
233
233
 
234
234
  property :priority, Integer,
235
235
  description: "Use to set Priority Levels range from 0 to 10.",
236
- default: 7, callbacks: { "should be in range of 0 to 10" => proc { |v| v >= 0 && v <= 10 } }
236
+ default: 7, callbacks: { "should be in range of 0 to 10" => proc { |v| v.between?(0, 10) } }
237
237
 
238
238
  property :disallow_start_if_on_batteries, [TrueClass, FalseClass],
239
239
  introduced: "14.4", default: false,
@@ -300,7 +300,7 @@ class Chef
300
300
 
301
301
  # Validate the passed value is numeric values only if it is a string
302
302
  def numeric_value_in_string?(val)
303
- return true if Integer(val)
303
+ true if Integer(val)
304
304
  rescue ArgumentError
305
305
  false
306
306
  end
@@ -26,23 +26,23 @@ class Chef
26
26
  description 'The *windows_uac* resource configures UAC on Windows hosts by setting registry keys at `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System`'
27
27
  introduced "15.0"
28
28
  examples <<~DOC
29
- **Disable UAC prompts for the admin**:
29
+ **Disable UAC prompts for the admin**:
30
30
 
31
- ```ruby
32
- windows_uac 'Disable UAC prompts for the admin' do
33
- enable_uac true
34
- prompt_on_secure_desktop false
35
- consent_behavior_admins :no_prompt
36
- end
37
- ```
31
+ ```ruby
32
+ windows_uac 'Disable UAC prompts for the admin' do
33
+ enable_uac true
34
+ prompt_on_secure_desktop false
35
+ consent_behavior_admins :no_prompt
36
+ end
37
+ ```
38
38
 
39
- **Disable UAC entirely**:
39
+ **Disable UAC entirely**:
40
40
 
41
- ```ruby
42
- windows_uac 'Disable UAC entirely' do
43
- enable_uac false
44
- end
45
- ```
41
+ ```ruby
42
+ windows_uac 'Disable UAC entirely' do
43
+ enable_uac false
44
+ end
45
+ ```
46
46
  DOC
47
47
 
48
48
  # https://docs.microsoft.com/en-us/windows/security/identity-protection/user-account-control/user-account-control-group-policy-and-registry-key-settings#user-account-control-virtualize-file-and-registry-write-failures-to-per-user-locations