chef 17.10.163 → 18.7.10

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 (400) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +25 -21
  3. data/README.md +7 -7
  4. data/Rakefile +3 -22
  5. data/{chef-universal-mingw32.gemspec → chef-universal-mingw-ucrt.gemspec} +7 -6
  6. data/chef.gemspec +33 -27
  7. data/lib/chef/api_client_v1.rb +9 -1
  8. data/lib/chef/application/base.rb +20 -2
  9. data/lib/chef/application/exit_code.rb +3 -3
  10. data/lib/chef/chef_fs/file_pattern.rb +1 -1
  11. data/lib/chef/chef_fs/file_system.rb +21 -7
  12. data/lib/chef/chef_fs/path_utils.rb +7 -9
  13. data/lib/chef/client.rb +186 -2
  14. data/lib/chef/compliance/default_attributes.rb +2 -2
  15. data/lib/chef/compliance/input.rb +1 -1
  16. data/lib/chef/compliance/profile.rb +1 -1
  17. data/lib/chef/compliance/profile_collection.rb +0 -1
  18. data/lib/chef/compliance/runner.rb +6 -1
  19. data/lib/chef/compliance/waiver.rb +1 -1
  20. data/lib/chef/cookbook/chefignore.rb +4 -1
  21. data/lib/chef/cookbook/cookbook_version_loader.rb +1 -1
  22. data/lib/chef/cookbook/metadata.rb +1 -1
  23. data/lib/chef/cookbook/remote_file_vendor.rb +1 -3
  24. data/lib/chef/cookbook/synchronizer.rb +21 -3
  25. data/lib/chef/cookbook/syntax_check.rb +2 -2
  26. data/lib/chef/cookbook_manifest.rb +2 -2
  27. data/lib/chef/cookbook_version.rb +1 -1
  28. data/lib/chef/data_collector.rb +14 -0
  29. data/lib/chef/delayed_evaluator.rb +4 -0
  30. data/lib/chef/dsl/reader_helpers.rb +1 -1
  31. data/lib/chef/dsl/rest_resource.rb +77 -0
  32. data/lib/chef/event_dispatch/base.rb +3 -0
  33. data/lib/chef/event_dispatch/dispatcher.rb +0 -1
  34. data/lib/chef/exceptions.rb +9 -1
  35. data/lib/chef/file_access_control/windows.rb +4 -1
  36. data/lib/chef/file_cache.rb +17 -2
  37. data/lib/chef/formatters/doc.rb +1 -1
  38. data/lib/chef/guard_interpreter/resource_guard_interpreter.rb +2 -0
  39. data/lib/chef/http/authenticator.rb +253 -3
  40. data/lib/chef/http/ssl_policies.rb +2 -2
  41. data/lib/chef/mixin/{homebrew_user.rb → homebrew.rb} +13 -16
  42. data/lib/chef/mixin/openssl_helper.rb +1 -16
  43. data/lib/chef/mixin/powershell_exec.rb +5 -28
  44. data/lib/chef/monkey_patches/net-http.rb +127 -0
  45. data/lib/chef/node/attribute.rb +3 -11
  46. data/lib/chef/node/attribute_collections.rb +10 -1
  47. data/lib/chef/node/immutable_collections.rb +17 -6
  48. data/lib/chef/node/mixin/immutablize_array.rb +1 -0
  49. data/lib/chef/node/mixin/state_tracking.rb +7 -4
  50. data/lib/chef/node/mixin/state_tracking_array.rb +41 -0
  51. data/lib/chef/node.rb +23 -1
  52. data/lib/chef/platform/query_helpers.rb +4 -2
  53. data/lib/chef/policy_builder/policyfile.rb +8 -0
  54. data/lib/chef/property.rb +13 -6
  55. data/lib/chef/provider/group/windows.rb +1 -1
  56. data/lib/chef/provider/http_request.rb +11 -9
  57. data/lib/chef/provider/launchd.rb +2 -1
  58. data/lib/chef/provider/mount/linux.rb +6 -1
  59. data/lib/chef/provider/mount/mount.rb +13 -5
  60. data/lib/chef/provider/mount/windows.rb +1 -1
  61. data/lib/chef/provider/package/apt.rb +11 -2
  62. data/lib/chef/provider/package/chocolatey.rb +260 -22
  63. data/lib/chef/provider/package/dnf/dnf_helper.py +7 -0
  64. data/lib/chef/provider/package/homebrew.rb +6 -9
  65. data/lib/chef/provider/package/powershell.rb +1 -0
  66. data/lib/chef/provider/package/rubygems.rb +5 -1
  67. data/lib/chef/provider/package/snap.rb +3 -2
  68. data/lib/chef/provider/package/windows/msi.rb +2 -2
  69. data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +1 -1
  70. data/lib/chef/provider/package/yum/yum_helper.py +3 -3
  71. data/lib/chef/provider/package/zypper/version.rb +60 -0
  72. data/lib/chef/provider/package/zypper.rb +47 -3
  73. data/lib/chef/provider/powershell_script.rb +96 -6
  74. data/lib/chef/provider/registry_key.rb +2 -0
  75. data/lib/chef/provider/remote_file/http.rb +1 -1
  76. data/lib/chef/provider/service/systemd.rb +23 -8
  77. data/lib/chef/provider/service/windows.rb +1 -1
  78. data/lib/chef/provider/service.rb +14 -0
  79. data/lib/chef/provider/user/aix.rb +5 -0
  80. data/lib/chef/provider/user/linux.rb +29 -0
  81. data/lib/chef/provider/user/mac.rb +1 -1
  82. data/lib/chef/provider/user/windows.rb +5 -0
  83. data/lib/chef/provider/user.rb +45 -9
  84. data/lib/chef/provider/yum_repository.rb +13 -1
  85. data/lib/chef/provider.rb +1 -1
  86. data/lib/chef/recipe.rb +4 -12
  87. data/lib/chef/resource/_rest_resource.rb +389 -0
  88. data/lib/chef/resource/alternatives.rb +0 -1
  89. data/lib/chef/resource/apt_package.rb +21 -1
  90. data/lib/chef/resource/apt_preference.rb +0 -1
  91. data/lib/chef/resource/apt_repository.rb +138 -18
  92. data/lib/chef/resource/apt_update.rb +0 -1
  93. data/lib/chef/resource/archive_file.rb +0 -1
  94. data/lib/chef/resource/bash.rb +13 -1
  95. data/lib/chef/resource/batch.rb +0 -1
  96. data/lib/chef/resource/bff_package.rb +0 -1
  97. data/lib/chef/resource/breakpoint.rb +0 -1
  98. data/lib/chef/resource/build_essential.rb +0 -1
  99. data/lib/chef/resource/cab_package.rb +0 -1
  100. data/lib/chef/resource/chef_client_config.rb +12 -14
  101. data/lib/chef/resource/chef_client_cron.rb +1 -2
  102. data/lib/chef/resource/chef_client_launchd.rb +2 -2
  103. data/lib/chef/resource/chef_client_scheduled_task.rb +3 -3
  104. data/lib/chef/resource/chef_client_systemd_timer.rb +5 -1
  105. data/lib/chef/resource/chef_client_trusted_certificate.rb +0 -1
  106. data/lib/chef/resource/chef_gem.rb +1 -2
  107. data/lib/chef/resource/chef_handler.rb +0 -1
  108. data/lib/chef/resource/chef_sleep.rb +1 -3
  109. data/lib/chef/resource/chef_vault_secret.rb +0 -1
  110. data/lib/chef/resource/chocolatey_config.rb +0 -1
  111. data/lib/chef/resource/chocolatey_feature.rb +0 -1
  112. data/lib/chef/resource/chocolatey_installer.rb +207 -0
  113. data/lib/chef/resource/chocolatey_package.rb +8 -1
  114. data/lib/chef/resource/chocolatey_source.rb +0 -1
  115. data/lib/chef/resource/cookbook_file.rb +0 -1
  116. data/lib/chef/resource/cron/_cron_shared.rb +0 -1
  117. data/lib/chef/resource/cron/cron.rb +0 -1
  118. data/lib/chef/resource/cron/cron_d.rb +15 -1
  119. data/lib/chef/resource/cron_access.rb +0 -1
  120. data/lib/chef/resource/csh.rb +0 -1
  121. data/lib/chef/resource/directory.rb +0 -1
  122. data/lib/chef/resource/dmg_package.rb +2 -1
  123. data/lib/chef/resource/dnf_package.rb +0 -1
  124. data/lib/chef/resource/dpkg_package.rb +0 -1
  125. data/lib/chef/resource/dsc_resource.rb +0 -1
  126. data/lib/chef/resource/dsc_script.rb +1 -2
  127. data/lib/chef/resource/execute.rb +8 -7
  128. data/lib/chef/resource/file.rb +0 -1
  129. data/lib/chef/resource/freebsd_package.rb +2 -1
  130. data/lib/chef/resource/gem_package.rb +2 -1
  131. data/lib/chef/resource/group.rb +25 -2
  132. data/lib/chef/resource/habitat/habitat_package.rb +0 -1
  133. data/lib/chef/resource/habitat/habitat_sup.rb +6 -7
  134. data/lib/chef/resource/habitat/habitat_sup_windows.rb +1 -1
  135. data/lib/chef/resource/habitat_config.rb +0 -1
  136. data/lib/chef/resource/habitat_install.rb +2 -2
  137. data/lib/chef/resource/habitat_service.rb +0 -1
  138. data/lib/chef/resource/habitat_user_toml.rb +0 -1
  139. data/lib/chef/resource/homebrew_cask.rb +21 -33
  140. data/lib/chef/resource/homebrew_package.rb +3 -2
  141. data/lib/chef/resource/homebrew_tap.rb +32 -18
  142. data/lib/chef/resource/homebrew_update.rb +4 -6
  143. data/lib/chef/resource/hostname.rb +0 -1
  144. data/lib/chef/resource/http_request.rb +0 -1
  145. data/lib/chef/resource/ifconfig.rb +0 -1
  146. data/lib/chef/resource/inspec_input.rb +0 -1
  147. data/lib/chef/resource/inspec_waiver.rb +0 -1
  148. data/lib/chef/resource/inspec_waiver_file_entry.rb +2 -3
  149. data/lib/chef/resource/ips_package.rb +0 -1
  150. data/lib/chef/resource/kernel_module.rb +0 -1
  151. data/lib/chef/resource/ksh.rb +0 -1
  152. data/lib/chef/resource/launchd.rb +9 -3
  153. data/lib/chef/resource/link.rb +0 -1
  154. data/lib/chef/resource/locale.rb +0 -1
  155. data/lib/chef/resource/log.rb +0 -1
  156. data/lib/chef/resource/lwrp_base.rb +0 -4
  157. data/lib/chef/resource/macos_pkg.rb +111 -0
  158. data/lib/chef/resource/macos_userdefaults.rb +3 -4
  159. data/lib/chef/resource/macosx_service.rb +0 -1
  160. data/lib/chef/resource/macports_package.rb +2 -1
  161. data/lib/chef/resource/mdadm.rb +0 -1
  162. data/lib/chef/resource/mount.rb +0 -1
  163. data/lib/chef/resource/msu_package.rb +0 -1
  164. data/lib/chef/resource/notify_group.rb +0 -2
  165. data/lib/chef/resource/ohai.rb +0 -1
  166. data/lib/chef/resource/ohai_hint.rb +0 -1
  167. data/lib/chef/resource/openbsd_package.rb +2 -1
  168. data/lib/chef/resource/openssl_dhparam.rb +0 -2
  169. data/lib/chef/resource/openssl_ec_private_key.rb +0 -2
  170. data/lib/chef/resource/openssl_ec_public_key.rb +0 -2
  171. data/lib/chef/resource/openssl_rsa_private_key.rb +0 -2
  172. data/lib/chef/resource/openssl_rsa_public_key.rb +0 -2
  173. data/lib/chef/resource/openssl_x509_certificate.rb +0 -2
  174. data/lib/chef/resource/openssl_x509_crl.rb +0 -2
  175. data/lib/chef/resource/openssl_x509_request.rb +0 -2
  176. data/lib/chef/resource/osx_profile.rb +0 -1
  177. data/lib/chef/resource/package.rb +0 -1
  178. data/lib/chef/resource/pacman_package.rb +2 -1
  179. data/lib/chef/resource/paludis_package.rb +0 -1
  180. data/lib/chef/resource/perl.rb +0 -1
  181. data/lib/chef/resource/plist.rb +7 -3
  182. data/lib/chef/resource/portage_package.rb +2 -1
  183. data/lib/chef/resource/powershell_package.rb +4 -1
  184. data/lib/chef/resource/powershell_package_source.rb +0 -1
  185. data/lib/chef/resource/powershell_script.rb +5 -2
  186. data/lib/chef/resource/python.rb +0 -1
  187. data/lib/chef/resource/reboot.rb +0 -1
  188. data/lib/chef/resource/registry_key.rb +6 -1
  189. data/lib/chef/resource/remote_directory.rb +0 -1
  190. data/lib/chef/resource/remote_file.rb +0 -1
  191. data/lib/chef/resource/rhsm_errata.rb +0 -1
  192. data/lib/chef/resource/rhsm_errata_level.rb +0 -1
  193. data/lib/chef/resource/rhsm_register.rb +2 -4
  194. data/lib/chef/resource/rhsm_repo.rb +0 -1
  195. data/lib/chef/resource/rhsm_subscription.rb +0 -1
  196. data/lib/chef/resource/route.rb +0 -1
  197. data/lib/chef/resource/rpm_package.rb +2 -1
  198. data/lib/chef/resource/ruby.rb +0 -1
  199. data/lib/chef/resource/ruby_block.rb +0 -1
  200. data/lib/chef/resource/scm/_scm.rb +0 -2
  201. data/lib/chef/resource/scm/git.rb +0 -2
  202. data/lib/chef/resource/scm/subversion.rb +0 -2
  203. data/lib/chef/resource/script.rb +0 -1
  204. data/lib/chef/resource/selinux/common_helpers.rb +47 -0
  205. data/lib/chef/resource/selinux/selinux_debian.erb +18 -0
  206. data/lib/chef/resource/selinux/selinux_default.erb +15 -0
  207. data/lib/chef/resource/selinux_boolean.rb +101 -0
  208. data/lib/chef/resource/selinux_fcontext.rb +160 -0
  209. data/lib/chef/resource/selinux_install.rb +107 -0
  210. data/lib/chef/resource/selinux_login.rb +129 -0
  211. data/lib/chef/resource/selinux_module.rb +143 -0
  212. data/lib/chef/resource/selinux_permissive.rb +64 -0
  213. data/lib/chef/resource/selinux_port.rb +118 -0
  214. data/lib/chef/resource/selinux_state.rb +166 -0
  215. data/lib/chef/resource/selinux_user.rb +137 -0
  216. data/lib/chef/resource/service.rb +4 -2
  217. data/lib/chef/resource/smartos_package.rb +2 -1
  218. data/lib/chef/resource/snap_package.rb +25 -1
  219. data/lib/chef/resource/solaris_package.rb +2 -1
  220. data/lib/chef/resource/ssh_known_hosts_entry.rb +0 -1
  221. data/lib/chef/resource/sudo.rb +37 -3
  222. data/lib/chef/resource/support/client.erb +2 -2
  223. data/lib/chef/resource/support/ulimit.erb +40 -0
  224. data/lib/chef/resource/swap_file.rb +0 -1
  225. data/lib/chef/resource/sysctl.rb +2 -2
  226. data/lib/chef/resource/systemd_unit.rb +0 -1
  227. data/lib/chef/resource/template.rb +0 -1
  228. data/lib/chef/resource/timezone.rb +0 -1
  229. data/lib/chef/resource/user/aix_user.rb +0 -1
  230. data/lib/chef/resource/user/linux_user.rb +0 -1
  231. data/lib/chef/resource/user/mac_user.rb +0 -1
  232. data/lib/chef/resource/user/pw_user.rb +0 -1
  233. data/lib/chef/resource/user/solaris_user.rb +0 -1
  234. data/lib/chef/resource/user/windows_user.rb +0 -1
  235. data/lib/chef/resource/user.rb +10 -1
  236. data/lib/chef/resource/user_ulimit.rb +38 -1
  237. data/lib/chef/resource/whyrun_safe_ruby_block.rb +0 -1
  238. data/lib/chef/resource/windows_ad_join.rb +0 -2
  239. data/lib/chef/resource/windows_audit_policy.rb +0 -2
  240. data/lib/chef/resource/windows_auto_run.rb +0 -1
  241. data/lib/chef/resource/windows_certificate.rb +1 -1
  242. data/lib/chef/resource/windows_defender.rb +0 -1
  243. data/lib/chef/resource/windows_defender_exclusion.rb +0 -1
  244. data/lib/chef/resource/windows_dfs_folder.rb +0 -1
  245. data/lib/chef/resource/windows_dfs_namespace.rb +0 -1
  246. data/lib/chef/resource/windows_dfs_server.rb +0 -1
  247. data/lib/chef/resource/windows_dns_record.rb +0 -1
  248. data/lib/chef/resource/windows_dns_zone.rb +0 -1
  249. data/lib/chef/resource/windows_env.rb +0 -1
  250. data/lib/chef/resource/windows_feature.rb +0 -1
  251. data/lib/chef/resource/windows_feature_dism.rb +0 -1
  252. data/lib/chef/resource/windows_feature_powershell.rb +0 -1
  253. data/lib/chef/resource/windows_firewall_profile.rb +0 -2
  254. data/lib/chef/resource/windows_firewall_rule.rb +0 -1
  255. data/lib/chef/resource/windows_font.rb +2 -3
  256. data/lib/chef/resource/windows_package.rb +3 -4
  257. data/lib/chef/resource/windows_pagefile.rb +0 -2
  258. data/lib/chef/resource/windows_path.rb +0 -1
  259. data/lib/chef/resource/windows_printer.rb +0 -1
  260. data/lib/chef/resource/windows_printer_port.rb +0 -1
  261. data/lib/chef/resource/windows_script.rb +0 -2
  262. data/lib/chef/resource/windows_security_policy.rb +2 -3
  263. data/lib/chef/resource/windows_service.rb +0 -1
  264. data/lib/chef/resource/windows_share.rb +0 -1
  265. data/lib/chef/resource/windows_shortcut.rb +1 -2
  266. data/lib/chef/resource/windows_task.rb +0 -1
  267. data/lib/chef/resource/windows_uac.rb +0 -1
  268. data/lib/chef/resource/windows_update_settings.rb +0 -1
  269. data/lib/chef/resource/windows_user_privilege.rb +14 -11
  270. data/lib/chef/resource/windows_workgroup.rb +0 -1
  271. data/lib/chef/resource/yum_package.rb +2 -1
  272. data/lib/chef/resource/yum_repository.rb +4 -1
  273. data/lib/chef/resource/zypper_package.rb +2 -1
  274. data/lib/chef/resource/zypper_repository.rb +0 -1
  275. data/lib/chef/resource.rb +23 -5
  276. data/lib/chef/resource_inspector.rb +25 -7
  277. data/lib/chef/resource_reporter.rb +4 -0
  278. data/lib/chef/resources.rb +11 -0
  279. data/lib/chef/run_context.rb +3 -3
  280. data/lib/chef/secret_fetcher/azure_key_vault.rb +1 -1
  281. data/lib/chef/util/powershell/ps_credential.rb +10 -0
  282. data/lib/chef/version.rb +1 -1
  283. data/lib/chef/win32/handle.rb +6 -7
  284. data/lib/chef/win32/registry.rb +12 -4
  285. data/lib/chef/win32/security.rb +16 -1
  286. data/spec/data/rubygems.org/sexp_processor-info +2 -1
  287. data/spec/data/trusted_certs/intermediate.pem +38 -27
  288. data/spec/functional/resource/cookbook_file_spec.rb +1 -1
  289. data/spec/functional/resource/dsc_script_spec.rb +1 -1
  290. data/spec/functional/resource/execute_spec.rb +1 -1
  291. data/spec/functional/resource/group_spec.rb +26 -42
  292. data/spec/functional/resource/link_spec.rb +8 -8
  293. data/spec/functional/resource/plist_spec.rb +25 -0
  294. data/spec/functional/resource/registry_spec.rb +233 -609
  295. data/spec/functional/resource/remote_file_spec.rb +1 -1
  296. data/spec/functional/resource/user/linux_user_spec.rb +127 -0
  297. data/spec/functional/resource/windows_certificate_spec.rb +1 -1
  298. data/spec/functional/resource/windows_font_spec.rb +12 -9
  299. data/spec/functional/resource/yum_package_spec.rb +1 -1
  300. data/spec/functional/resource/zypper_package_spec.rb +12 -0
  301. data/spec/functional/shell_spec.rb +1 -2
  302. data/spec/functional/version_spec.rb +1 -1
  303. data/spec/functional/win32/registry_spec.rb +0 -3
  304. data/spec/integration/client/client_spec.rb +88 -3
  305. data/spec/integration/client/exit_code_spec.rb +1 -1
  306. data/spec/integration/client/fips_spec.rb +5 -5
  307. data/spec/integration/client/ipv6_spec.rb +1 -1
  308. data/spec/integration/client/open_ssl_spec.rb +3 -3
  309. data/spec/integration/compliance/compliance_spec.rb +1 -1
  310. data/spec/integration/recipes/accumulator_spec.rb +1 -1
  311. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +1 -1
  312. data/spec/integration/recipes/lwrp_spec.rb +1 -1
  313. data/spec/integration/recipes/notifies_spec.rb +1 -1
  314. data/spec/integration/recipes/notifying_block_spec.rb +1 -1
  315. data/spec/integration/recipes/remote_directory.rb +1 -1
  316. data/spec/integration/recipes/unified_mode_spec.rb +1 -1
  317. data/spec/integration/recipes/use_partial_spec.rb +2 -1
  318. data/spec/integration/solo/solo_spec.rb +2 -2
  319. data/spec/spec_helper.rb +7 -4
  320. data/spec/support/chef_helpers.rb +2 -2
  321. data/spec/support/platform_helpers.rb +28 -7
  322. data/spec/support/ruby_installer.rb +1 -1
  323. data/spec/support/shared/functional/file_resource.rb +3 -3
  324. data/spec/support/shared/functional/windows_script.rb +2 -2
  325. data/spec/tiny_server.rb +5 -2
  326. data/spec/unit/application/client_spec.rb +0 -10
  327. data/spec/unit/chef_fs/file_system_spec.rb +2 -0
  328. data/spec/unit/client_spec.rb +80 -4
  329. data/spec/unit/compliance/runner_spec.rb +8 -0
  330. data/spec/unit/cookbook/syntax_check_spec.rb +3 -0
  331. data/spec/unit/data_collector_spec.rb +106 -2
  332. data/spec/unit/delayed_evaluator_spec.rb +35 -0
  333. data/spec/unit/file_cache_spec.rb +64 -0
  334. data/spec/unit/http/authenticator_spec.rb +121 -0
  335. data/spec/unit/mixin/homebrew_spec.rb +118 -0
  336. data/spec/unit/mixin/openssl_helper_spec.rb +5 -0
  337. data/spec/unit/mixin/powershell_exec_spec.rb +5 -5
  338. data/spec/unit/node/vivid_mash_spec.rb +42 -0
  339. data/spec/unit/node_spec.rb +6 -0
  340. data/spec/unit/platform/query_helpers_spec.rb +2 -17
  341. data/spec/unit/property/validation_spec.rb +30 -0
  342. data/spec/unit/provider/apt_repository_spec.rb +48 -12
  343. data/spec/unit/provider/cron_spec.rb +2 -0
  344. data/spec/unit/provider/http_request_spec.rb +60 -72
  345. data/spec/unit/provider/launchd_spec.rb +2 -2
  346. data/spec/unit/provider/mount/aix_spec.rb +2 -2
  347. data/spec/unit/provider/mount/linux_spec.rb +15 -4
  348. data/spec/unit/provider/mount/mount_spec.rb +8 -8
  349. data/spec/unit/provider/package/apt_spec.rb +18 -13
  350. data/spec/unit/provider/package/chocolatey_spec.rb +41 -9
  351. data/spec/unit/provider/package/homebrew_spec.rb +4 -1
  352. data/spec/unit/provider/package/rpm_spec.rb +2 -2
  353. data/spec/unit/provider/package/rubygems_spec.rb +1 -1
  354. data/spec/unit/provider/package/windows_spec.rb +5 -5
  355. data/spec/unit/provider/package/zypper_spec.rb +32 -0
  356. data/spec/unit/provider/powershell_script_spec.rb +100 -4
  357. data/spec/unit/provider/registry_key_spec.rb +17 -17
  358. data/spec/unit/provider/remote_file/http_spec.rb +4 -4
  359. data/spec/unit/provider/service/systemd_service_spec.rb +1 -0
  360. data/spec/unit/provider/user/linux_spec.rb +51 -1
  361. data/spec/unit/provider/user/windows_spec.rb +1 -0
  362. data/spec/unit/provider/user_spec.rb +24 -6
  363. data/spec/unit/resource/apt_repository_spec.rb +5 -0
  364. data/spec/unit/resource/archive_file_spec.rb +1 -1
  365. data/spec/unit/resource/chef_client_cron_spec.rb +5 -0
  366. data/spec/unit/resource/chef_client_launchd_spec.rb +5 -0
  367. data/spec/unit/resource/chef_client_scheduled_task_spec.rb +5 -0
  368. data/spec/unit/resource/chef_client_systemd_timer_spec.rb +1 -1
  369. data/spec/unit/resource/chocolatey_installer_spec.rb +151 -0
  370. data/spec/unit/resource/cron_d_spec.rb +37 -1
  371. data/spec/unit/resource/macos_pkg_spec.rb +38 -0
  372. data/spec/unit/resource/powershell_script_spec.rb +2 -2
  373. data/spec/unit/resource/rest_resource_spec.rb +381 -0
  374. data/spec/unit/resource/selinux_boolean_spec.rb +92 -0
  375. data/spec/unit/resource/selinux_fcontext_spec.rb +65 -0
  376. data/spec/unit/resource/selinux_install_spec.rb +60 -0
  377. data/spec/unit/resource/selinux_login_spec.rb +73 -0
  378. data/spec/unit/resource/selinux_module_spec.rb +55 -0
  379. data/spec/unit/resource/selinux_permissive_spec.rb +39 -0
  380. data/spec/unit/resource/selinux_port_spec.rb +42 -0
  381. data/spec/unit/resource/selinux_state_spec.rb +46 -0
  382. data/spec/unit/resource/selinux_user_spec.rb +92 -0
  383. data/spec/unit/resource/sysctl_spec.rb +2 -2
  384. data/spec/unit/resource/user/linux_user_spec.rb +42 -0
  385. data/spec/unit/resource/yum_repository_spec.rb +4 -0
  386. data/spec/unit/resource_inspector_spec.rb +36 -0
  387. data/spec/unit/resource_reporter_spec.rb +57 -3
  388. data/spec/unit/resource_spec.rb +94 -2
  389. data/spec/unit/util/dsc/local_configuration_manager_spec.rb +1 -1
  390. data/spec/unit/util/powershell/ps_credential_spec.rb +6 -0
  391. data/tasks/rspec.rb +1 -1
  392. metadata +126 -44
  393. data/lib/chef/powershell.rb +0 -81
  394. data/spec/unit/mixin/homebrew_user_spec.rb +0 -119
  395. /data/spec/functional/assets/yumrepo/repodata/{01a3b-filelists.sqlite.bz2 → 4632d67cb92636e7575d911c24f0e04d3505a944e97c483abe0c3e73a7c62d33-filelists.sqlite.bz2} +0 -0
  396. /data/spec/functional/assets/yumrepo/repodata/{6bf96-other.xml.gz → 74599b793e54d877323837d2d81a1c3c594c44e4335f9528234bb490f7b9b439-other.xml.gz} +0 -0
  397. /data/spec/functional/assets/yumrepo/repodata/{5dc1e-primary.sqlite.bz2 → a845d418f919d2115ab95a56b2c76f6825ad0d0bede49181a55c04f58995d057-primary.sqlite.bz2} +0 -0
  398. /data/spec/functional/assets/yumrepo/repodata/{7c365-other.sqlite.bz2 → af9b7cf9ef23bd7b43068d74a460f3b5d06753d638e58e4a0c9edc35bfb9cdc4-other.sqlite.bz2} +0 -0
  399. /data/spec/functional/assets/yumrepo/repodata/{401dc-filelists.xml.gz → bdb4f5f1492a3b9532f22c43110a81500dd744f23da0aec5c33b2a41317c737d-filelists.xml.gz} +0 -0
  400. /data/spec/functional/assets/yumrepo/repodata/{dabe2-primary.xml.gz → c10d1d34ce99e02f12ec96ef68360543ab1bb7c3cb81a4a2bf78df7d8597e9df-primary.xml.gz} +0 -0
@@ -0,0 +1,118 @@
1
+ #
2
+ # Licensed under the Apache License, Version 2.0 (the "License");
3
+ # you may not use this file except in compliance with the License.
4
+ # You may obtain a copy of the License at
5
+ #
6
+ # http://www.apache.org/licenses/LICENSE-2.0
7
+ #
8
+ # Unless required by applicable law or agreed to in writing, software
9
+ # distributed under the License is distributed on an "AS IS" BASIS,
10
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ # See the License for the specific language governing permissions and
12
+ # limitations under the License.
13
+
14
+ require_relative "../resource"
15
+ require_relative "selinux/common_helpers"
16
+
17
+ class Chef
18
+ class Resource
19
+ class SelinuxPort < Chef::Resource
20
+ unified_mode true
21
+
22
+ provides :selinux_port
23
+
24
+ description "Use the **selinux_port** resource to assign a network port to a specific SELinux context. For example, running a web server on a non-standard port."
25
+ introduced "18.0"
26
+ examples <<~DOC
27
+ **Allow nginx/apache to bind to port 5678 by giving it the http_port_t context**:
28
+
29
+ ```ruby
30
+ selinux_port '5678' do
31
+ protocol 'tcp'
32
+ secontext 'http_port_t'
33
+ end
34
+ ```
35
+ DOC
36
+
37
+ property :port, [Integer, String],
38
+ name_property: true,
39
+ regex: /^\d+$/,
40
+ description: "Port to modify."
41
+
42
+ property :protocol, String,
43
+ equal_to: %w{tcp udp},
44
+ required: %i{manage add modify},
45
+ description: "Protocol to modify."
46
+
47
+ property :secontext, String,
48
+ required: %i{manage add modify},
49
+ description: "SELinux context to assign to the port."
50
+
51
+ action_class do
52
+ include Chef::SELinux::CommonHelpers
53
+ def current_port_context
54
+ # use awk to see if the given port is within a reported port range
55
+ shell_out!(
56
+ <<~CMD
57
+ seinfo --portcon=#{new_resource.port} | grep 'portcon #{new_resource.protocol}' | \
58
+ awk -F: '$(NF-1) !~ /reserved_port_t$/ && $(NF-3) !~ /[0-9]*-[0-9]*/ {print $(NF-1)}'
59
+ CMD
60
+ ).stdout.split
61
+ end
62
+ end
63
+
64
+ action :manage, description: "Assign the port to the right context regardless of previous state." do
65
+ run_action(:add)
66
+ run_action(:modify)
67
+ end
68
+
69
+ action :addormodify, description: "Assigns the port context if not set. Updates the port context if previously set." do
70
+ Chef::Log.warn("The :addormodify action for selinux_port is deprecated and will be removed in a future release. Use the :manage action instead.")
71
+ run_action(:manage)
72
+ end
73
+
74
+ # Create if doesn't exist, do not touch if port is already registered (even under different type)
75
+ action :add, description: "Assign the port context if not set." do
76
+ if selinux_disabled?
77
+ Chef::Log.warn("Unable to add SELinux port #{new_resource.name} as SELinux is disabled")
78
+ return
79
+ end
80
+
81
+ if current_port_context.empty?
82
+ converge_by "Adding context #{new_resource.secontext} to port #{new_resource.port}/#{new_resource.protocol}" do
83
+ shell_out!("semanage port -a -t '#{new_resource.secontext}' -p #{new_resource.protocol} #{new_resource.port}")
84
+ end
85
+ end
86
+ end
87
+
88
+ # Only modify port if it exists & doesn't have the correct context already
89
+ action :modify, description: "Update the port context if previously set." do
90
+ if selinux_disabled?
91
+ Chef::Log.warn("Unable to modify SELinux port #{new_resource.name} as SELinux is disabled")
92
+ return
93
+ end
94
+
95
+ if !current_port_context.empty? && !current_port_context.include?(new_resource.secontext)
96
+ converge_by "Modifying context #{new_resource.secontext} to port #{new_resource.port}/#{new_resource.protocol}" do
97
+ shell_out!("semanage port -m -t '#{new_resource.secontext}' -p #{new_resource.protocol} #{new_resource.port}")
98
+ end
99
+ end
100
+ end
101
+
102
+ # Delete if exists
103
+ action :delete, description: "Removes the port context if set." do
104
+ if selinux_disabled?
105
+ Chef::Log.warn("Unable to delete SELinux port #{new_resource.name} as SELinux is disabled")
106
+ return
107
+ end
108
+
109
+ unless current_port_context.empty?
110
+ converge_by "Deleting context from port #{new_resource.port}/#{new_resource.protocol}" do
111
+ shell_out!("semanage port -d -p #{new_resource.protocol} #{new_resource.port}")
112
+ end
113
+ end
114
+ end
115
+
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,166 @@
1
+ #
2
+ # Licensed under the Apache License, Version 2.0 (the "License");
3
+ # you may not use this file except in compliance with the License.
4
+ # You may obtain a copy of the License at
5
+ #
6
+ # http://www.apache.org/licenses/LICENSE-2.0
7
+ #
8
+ # Unless required by applicable law or agreed to in writing, software
9
+ # distributed under the License is distributed on an "AS IS" BASIS,
10
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ # See the License for the specific language governing permissions and
12
+ # limitations under the License.
13
+
14
+ require_relative "../resource"
15
+ require_relative "selinux/common_helpers"
16
+
17
+ class Chef
18
+ class Resource
19
+ class SelinuxState < Chef::Resource
20
+ unified_mode true
21
+
22
+ provides :selinux_state
23
+
24
+ description "Use **selinux_state** resource to manages the SELinux state on the system. It does this by using the `setenforce` command and rendering the `/etc/selinux/config` file from a template."
25
+ introduced "18.0"
26
+ examples <<~DOC
27
+ **Set SELinux state to permissive**:
28
+
29
+ ```ruby
30
+ selinux_state 'permissive' do
31
+ action :permissive
32
+ end
33
+ ```
34
+
35
+ **Set SELinux state to enforcing**:
36
+
37
+ ```ruby
38
+ selinux_state 'enforcing' do
39
+ action :enforcing
40
+ end
41
+ ```
42
+
43
+ **Set SELinux state to disabled**:
44
+ ```ruby
45
+ selinux_state 'disabled' do
46
+ action :disabled
47
+ end
48
+ ```
49
+ DOC
50
+
51
+ default_action :nothing
52
+
53
+ property :config_file, String,
54
+ default: "/etc/selinux/config",
55
+ description: "Path to SELinux config file on disk."
56
+
57
+ property :persistent, [true, false],
58
+ default: true,
59
+ description: "Set the status update in the SELinux configuration file."
60
+
61
+ property :policy, String,
62
+ default: lazy { default_policy_platform },
63
+ equal_to: %w{default minimum mls src strict targeted},
64
+ description: "SELinux policy type."
65
+
66
+ property :automatic_reboot, [true, false, Symbol],
67
+ default: false,
68
+ description: "Perform an automatic node reboot if required for state change."
69
+
70
+ deprecated_property_alias "temporary", "persistent", "The temporary property was renamed persistent in the 4.0 release of this cookbook. Please update your cookbooks to use the new property name."
71
+
72
+ action_class do
73
+ include Chef::SELinux::CommonHelpers
74
+ def render_selinux_template(action)
75
+ Chef::Log.warn("It is advised to set the configuration first to permissive to relabel the filesystem prior to enforcing.") if selinux_disabled? && action == :enforcing
76
+
77
+ unless new_resource.automatic_reboot
78
+ Chef::Log.warn("Changes from disabled require a reboot.") if selinux_disabled? && %i{enforcing permissive}.include?(action)
79
+ Chef::Log.warn("Disabling selinux requires a reboot.") if (selinux_enforcing? || selinux_permissive?) && action == :disabled
80
+ end
81
+
82
+ template "#{action} selinux config" do
83
+ path new_resource.config_file
84
+ source debian? ? ::File.expand_path("selinux/selinux_debian.erb", __dir__) : ::File.expand_path("selinux/selinux_default.erb", __dir__)
85
+ local true
86
+ variables(
87
+ selinux: action.to_s,
88
+ selinuxtype: new_resource.policy
89
+ )
90
+ end
91
+ end
92
+
93
+ def node_selinux_restart
94
+ unless new_resource.automatic_reboot
95
+ Chef::Log.warn("SELinux state change to #{action} requires a manual reboot as SELinux is currently #{selinux_state} and automatic reboots are disabled.")
96
+ return
97
+ end
98
+
99
+ outer_action = action
100
+ reboot "selinux_state_change" do
101
+ delay_mins 1
102
+ reason "SELinux state change to #{outer_action} from #{selinux_state}"
103
+
104
+ action new_resource.automatic_reboot.is_a?(Symbol) ? new_resource.automatic_reboot : :reboot_now
105
+ end
106
+ end
107
+ end
108
+
109
+ action :enforcing, description: "Set the SELinux state to enforcing." do
110
+ unless selinux_disabled? || selinux_enforcing?
111
+ execute "selinux-setenforce-enforcing" do
112
+ command "/usr/sbin/setenforce 1"
113
+ end
114
+ end
115
+
116
+ if selinux_activate_required?
117
+ execute "debian-selinux-activate" do
118
+ command "/usr/sbin/selinux-activate"
119
+ end
120
+ end
121
+
122
+ render_selinux_template(action) if new_resource.persistent
123
+ node_selinux_restart if state_change_reboot_required?
124
+ end
125
+
126
+ action :permissive, description: "Set the SELinux state to permissive." do
127
+ unless selinux_disabled? || selinux_permissive?
128
+ execute "selinux-setenforce-permissive" do
129
+ command "/usr/sbin/setenforce 0"
130
+ end
131
+ end
132
+
133
+ if selinux_activate_required?
134
+ execute "debian-selinux-activate" do
135
+ command "/usr/sbin/selinux-activate"
136
+ end
137
+ end
138
+
139
+ render_selinux_template(action) if new_resource.persistent
140
+ node_selinux_restart if state_change_reboot_required?
141
+ end
142
+
143
+ action :disabled, description: "Set the SELinux state to disabled. **NOTE**: Switching to or from disabled requires a reboot!" do
144
+ raise "A non-persistent change to the disabled SELinux status is not possible." unless new_resource.persistent
145
+
146
+ render_selinux_template(action)
147
+ node_selinux_restart if state_change_reboot_required?
148
+ end
149
+
150
+ private
151
+
152
+ #
153
+ # Decide default policy platform based upon platform_family
154
+ #
155
+ # @return [String] Policy platform name
156
+ def default_policy_platform
157
+ case node["platform_family"]
158
+ when "rhel", "fedora", "amazon"
159
+ "targeted"
160
+ when "debian"
161
+ "default"
162
+ end
163
+ end
164
+ end
165
+ end
166
+ end
@@ -0,0 +1,137 @@
1
+ #
2
+ # Licensed under the Apache License, Version 2.0 (the "License");
3
+ # you may not use this file except in compliance with the License.
4
+ # You may obtain a copy of the License at
5
+ #
6
+ # http://www.apache.org/licenses/LICENSE-2.0
7
+ #
8
+ # Unless required by applicable law or agreed to in writing, software
9
+ # distributed under the License is distributed on an "AS IS" BASIS,
10
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ # See the License for the specific language governing permissions and
12
+ # limitations under the License.
13
+
14
+ require_relative "../resource"
15
+ require_relative "selinux/common_helpers"
16
+
17
+ class Chef
18
+ class Resource
19
+ class SelinuxUser < Chef::Resource
20
+ unified_mode true
21
+
22
+ provides :selinux_user
23
+
24
+ description "Use the **selinux_user** resource to add, update, or remove SELinux users."
25
+ introduced "18.1"
26
+ examples <<~DOC
27
+ **Manage test_u SELinux user with a level and range of s0 and roles sysadm_r and staff_r**:
28
+
29
+ ```ruby
30
+ selinux_user 'test_u' do
31
+ level 's0'
32
+ range 's0'
33
+ roles %w(sysadm_r staff_r)
34
+ end
35
+ ```
36
+ DOC
37
+
38
+ property :user, String,
39
+ name_property: true,
40
+ description: "An optional property to set the SELinux user value if it differs from the resource block's name."
41
+
42
+ property :level, String,
43
+ description: "MLS/MCS security level for the SELinux user."
44
+
45
+ property :range, String,
46
+ description: "MLS/MCS security range for the SELinux user."
47
+
48
+ property :roles, Array,
49
+ description: "Associated SELinux roles for the user.",
50
+ coerce: proc { |r| Array(r).sort }
51
+
52
+ load_current_value do |new_resource|
53
+ users = shell_out!("semanage user -l").stdout.split("\n")
54
+
55
+ current_user = users.grep(/^#{Regexp.escape(new_resource.user)}\s+/) do |u|
56
+ u.match(/^(?<user>[^\s]+)\s+(?<prefix>[^\s]+)\s+(?<level>[^\s]+)\s+(?<range>[^\s]+)\s+(?<roles>.*)$/)
57
+ # match returns [<Match 'data'>] or [], shift converts that to <Match 'data'> or nil
58
+ end.shift
59
+
60
+ current_value_does_not_exist! unless current_user
61
+
62
+ # Existing resources should maintain their current configuration unless otherwise specified
63
+ new_resource.level ||= current_user[:level]
64
+ new_resource.range ||= current_user[:range]
65
+ new_resource.roles ||= current_user[:roles].to_s.split.sort
66
+
67
+ level current_user[:level]
68
+ range current_user[:range]
69
+ roles current_user[:roles].to_s.split.sort
70
+ end
71
+
72
+ action_class do
73
+ include Chef::SELinux::CommonHelpers
74
+
75
+ def semanage_user_args
76
+ # Generate arguments for semanage user -a or -m
77
+ args = ""
78
+
79
+ args += " -L #{new_resource.level}" if new_resource.level
80
+ args += " -r #{new_resource.range}" if new_resource.range
81
+ args += " -R '#{new_resource.roles.join(" ")}'" unless new_resource.roles.to_a.empty?
82
+
83
+ args
84
+ end
85
+ end
86
+
87
+ action :manage, description: "Sets the SELinux user to the desired settings regardless of previous state." do
88
+ run_action(:add)
89
+ run_action(:modify)
90
+ end
91
+
92
+ # Create if doesn't exist, do not touch if user already exists
93
+ action :add, description: "Creates the SELinux user if not previously created." do
94
+ raise "The roles property must be populated to create a new SELinux user" if new_resource.roles.to_a.empty?
95
+
96
+ if selinux_disabled?
97
+ Chef::Log.warn("Unable to add SELinux user #{new_resource.user} as SELinux is disabled")
98
+ return
99
+ end
100
+
101
+ unless current_resource
102
+ converge_if_changed do
103
+ shell_out!("semanage user -a#{semanage_user_args} #{new_resource.user}")
104
+ end
105
+ end
106
+ end
107
+
108
+ # Only modify port if it exists & doesn't have the correct context already
109
+ action :modify, description: "Updates the SELinux user if previously created." do
110
+ if selinux_disabled?
111
+ Chef::Log.warn("Unable to modify SELinux user #{new_resource.user} as SELinux is disabled")
112
+ return
113
+ end
114
+
115
+ if current_resource
116
+ converge_if_changed do
117
+ shell_out!("semanage user -m#{semanage_user_args} #{new_resource.user}")
118
+ end
119
+ end
120
+ end
121
+
122
+ # Delete if exists
123
+ action :delete, description: "Removes the SELinux user if previously created." do
124
+ if selinux_disabled?
125
+ Chef::Log.warn("Unable to delete SELinux user #{new_resource.user} as SELinux is disabled")
126
+ return
127
+ end
128
+
129
+ if current_resource
130
+ converge_by "deleting SELinux user #{new_resource.user}" do
131
+ shell_out!("semanage user -d #{new_resource.user}")
132
+ end
133
+ end
134
+ end
135
+ end
136
+ end
137
+ end
@@ -27,7 +27,6 @@ class Chef
27
27
  class Service < Chef::Resource
28
28
  include Chef::Platform::ServiceHelpers
29
29
  extend Chef::Platform::ServiceHelpers
30
- unified_mode true
31
30
 
32
31
  provides :service, target_mode: true
33
32
 
@@ -82,7 +81,7 @@ class Chef
82
81
  # specify overrides for the start_command, stop_command and
83
82
  # restart_command properties.
84
83
  property :init_command, String,
85
- description: "The path to the init script that is associated with the service. Use init_command to prevent the need to specify overrides for the start_command, stop_command, and restart_command properties. When this property is not specified, the #{ChefUtils::Dist::Infra::PRODUCT} will use the default init command for the service provider being used.",
84
+ description: "The path to the init script that is associated with the service. Use `init_command` to prevent the need to specify overrides for the `start_command`, `stop_command`, and `restart_command` properties. When this property is not specified, the #{ChefUtils::Dist::Infra::PRODUCT} will use the default init command for the service provider being used.",
86
85
  desired_state: false
87
86
 
88
87
  # if the service is enabled or not
@@ -94,6 +93,9 @@ class Chef
94
93
  # if the service is masked or not
95
94
  property :masked, [ TrueClass, FalseClass ], skip_docs: true
96
95
 
96
+ # if the service is static or not
97
+ property :static, [ TrueClass, FalseClass ], skip_docs: true
98
+
97
99
  # if the service is indirect or not
98
100
  property :indirect, [ TrueClass, FalseClass ], skip_docs: true
99
101
 
@@ -21,13 +21,14 @@ require_relative "package"
21
21
  class Chef
22
22
  class Resource
23
23
  class SmartosPackage < Chef::Resource::Package
24
- unified_mode true
25
24
 
26
25
  provides :smartos_package
27
26
  provides :package, platform_family: "smartos"
28
27
 
29
28
  description "Use the **smartos_package** resource to manage packages for the SmartOS platform."
30
29
 
30
+ allowed_actions :install, :upgrade, :remove
31
+
31
32
  property :package_name, String,
32
33
  description: "An optional property to set the package name if it differs from the resource block's name.",
33
34
  identity: true
@@ -21,12 +21,36 @@ require_relative "package"
21
21
  class Chef
22
22
  class Resource
23
23
  class SnapPackage < Chef::Resource::Package
24
- unified_mode true
25
24
 
26
25
  provides :snap_package
27
26
 
28
27
  description "Use the **snap_package** resource to manage snap packages on Debian and Ubuntu platforms."
29
28
  introduced "15.0"
29
+ examples <<~DOC
30
+ **Install a package**
31
+
32
+ ```ruby
33
+ snap_package 'hello'
34
+ ```
35
+
36
+ **Upgrade a package**
37
+
38
+ ```ruby
39
+ snap_package 'hello' do
40
+ action :upgrade
41
+ end
42
+ ```
43
+
44
+ **Install a package with classic confinement**
45
+
46
+ ```ruby
47
+ snap_package 'hello' do
48
+ options 'classic'
49
+ end
50
+ ```
51
+ DOC
52
+
53
+ allowed_actions :install, :upgrade, :remove, :purge
30
54
 
31
55
  property :channel, String,
32
56
  description: "The default channel. For example: stable.",
@@ -22,12 +22,13 @@ require_relative "package"
22
22
  class Chef
23
23
  class Resource
24
24
  class SolarisPackage < Chef::Resource::Package
25
- unified_mode true
26
25
 
27
26
  provides :solaris_package
28
27
 
29
28
  description "Use the **solaris_package** resource to manage packages on the Solaris platform."
30
29
 
30
+ allowed_actions :install, :upgrade, :remove
31
+
31
32
  property :package_name, String,
32
33
  description: "An optional property to set the package name if it differs from the resource block's name.",
33
34
  identity: true
@@ -23,7 +23,6 @@ require "chef-utils/dist" unless defined?(ChefUtils::Dist)
23
23
  class Chef
24
24
  class Resource
25
25
  class SshKnownHostsEntry < Chef::Resource
26
- unified_mode true
27
26
 
28
27
  provides :ssh_known_hosts_entry
29
28
 
@@ -24,7 +24,6 @@ require_relative "../resource"
24
24
  class Chef
25
25
  class Resource
26
26
  class Sudo < Chef::Resource
27
- unified_mode true
28
27
 
29
28
  provides(:sudo) { true }
30
29
 
@@ -60,6 +59,41 @@ class Chef
60
59
  nopasswd true
61
60
  end
62
61
  ```
62
+
63
+ **Create command aliases and assign them to a group**
64
+
65
+ ```ruby
66
+ sudo 'webteam' do
67
+ command_aliases [
68
+ {
69
+ 'name': 'WEBTEAM_SYSTEMD_JBOSS',
70
+ 'command_list': [
71
+ '/usr/bin/systemctl start eap7-standalone.service',
72
+ '/usr/bin/systemctl start jbcs-httpd24-httpd.service', \
73
+ '/usr/bin/systemctl stop eap7-standalone.service', \
74
+ '/usr/bin/systemctl stop jbcs-httpd24-httpd.service', \
75
+ '/usr/bin/systemctl restart eap7-standalone.service', \
76
+ '/usr/bin/systemctl restart jbcs-httpd24-httpd.service', \
77
+ '/usr/bin/systemctl --full edit eap7-standalone.service', \
78
+ '/usr/bin/systemctl --full edit jbcs-httpd24-httpd.service', \
79
+ '/usr/bin/systemctl daemon-reload',
80
+ ]
81
+ },
82
+ {
83
+ 'name': 'GENERIC_SYSTEMD',
84
+ 'command_list': [
85
+ '/usr/sbin/systemctl list-unit-files',
86
+ '/usr/sbin/systemctl list-timers', \
87
+ '/usr/sbin/systemctl is-active *', \
88
+ '/usr/sbin/systemctl is-enabled *',
89
+ ]
90
+ }
91
+ ]
92
+ nopasswd true
93
+ users '%webteam'
94
+ commands [ 'WEBTEAM_SYSTEMD_JBOSS', 'GENERIC_SYSTEMD' ]
95
+ end
96
+ ```
63
97
  DOC
64
98
 
65
99
  # According to the sudo man pages sudo will ignore files in an include dir that have a `.` or `~`
@@ -80,7 +114,7 @@ class Chef
80
114
  coerce: proc { |x| coerce_groups(x) }
81
115
 
82
116
  property :commands, Array,
83
- description: "An array of full paths to commands this sudoer can execute.",
117
+ description: "An array of full paths to commands and/or command aliases this sudoer can execute.",
84
118
  default: ["ALL"]
85
119
 
86
120
  property :host, String,
@@ -111,7 +145,7 @@ class Chef
111
145
  default: []
112
146
 
113
147
  property :command_aliases, Array,
114
- description: "Command aliases that can be used as allowed commands later in the configuration.",
148
+ description: "Command aliases that can be used as allowed commands later in the configuration. The object represents an array of hashes in the following format: `[{'name':'ALIAS1','command_list': [ 'command1', 'command2' ] }, {'name':'Alias2','command_list: [ 'command3', 'command4 arg1 arg2' ]}]`",
115
149
  default: []
116
150
 
117
151
  property :setenv, [TrueClass, FalseClass],
@@ -39,10 +39,10 @@ log_location <%= @log_location.inspect %>
39
39
  <% end -%>
40
40
  <%# These data_collector options are special as they have a '.' -%>
41
41
  <% unless @data_collector_server_url.nil? || @data_collector_server_url.empty? %>
42
- data_collector.server_url <%= @data_collector_server_url %>
42
+ data_collector.server_url <%= @data_collector_server_url.inspect %>
43
43
  <% end %>
44
44
  <% unless @data_collector_token.nil? || @data_collector_token.empty? %>
45
- data_collector.token <%= @data_collector_token %>
45
+ data_collector.token <%= @data_collector_token.inspect %>
46
46
  <% end %>
47
47
  <%# The code below is not DRY on purpose to improve readability -%>
48
48
  <% unless @start_handlers.empty? -%>
@@ -2,6 +2,18 @@
2
2
 
3
3
  # Limits settings for <%= @ulimit_user %>
4
4
 
5
+ <% unless @as_limit.nil? -%>
6
+ <%= @ulimit_user -%> - as <%= @as_limit %>
7
+ <% else -%><% unless @as_soft_limit.nil? -%><%= @ulimit_user -%> soft as <%= @as_soft_limit %><% end -%>
8
+ <% unless @as_hard_limit.nil? -%><%= @ulimit_user -%> hard as <%= @as_hard_limit %><% end -%>
9
+ <% end -%>
10
+
11
+ <% unless @cpu_limit.nil? -%>
12
+ <%= @ulimit_user -%> - cpu <%= @cpu_limit %>
13
+ <% else -%><% unless @cpu_soft_limit.nil? -%><%= @ulimit_user -%> soft cpu <%= @cpu_soft_limit %><% end -%>
14
+ <% unless @cpu_hard_limit.nil? -%><%= @ulimit_user -%> hard cpu <%= @cpu_hard_limit %><% end -%>
15
+ <% end -%>
16
+
5
17
  <% unless @filehandle_limit.nil? -%>
6
18
  <%= @ulimit_user -%> - nofile <%= @filehandle_limit %>
7
19
  <% else -%><% unless @filehandle_soft_limit.nil? -%><%= @ulimit_user -%> soft nofile <%= @filehandle_soft_limit %><% end -%>
@@ -14,22 +26,50 @@
14
26
  <% unless @process_hard_limit.nil? -%><%= @ulimit_user -%> hard nproc <%= @process_hard_limit %><% end -%>
15
27
  <% end -%>
16
28
 
29
+ <% unless @locks_limit.nil? -%>
30
+ <%= @ulimit_user -%> - locks <%= @locks_limit %>
31
+ <% end -%>
32
+
17
33
  <% unless @memory_limit.nil? -%>
18
34
  <%= @ulimit_user -%> - memlock <%= @memory_limit %>
19
35
  <% end -%>
20
36
 
37
+ <% unless @maxlogins_limit.nil? -%>
38
+ <%= @ulimit_user -%> - maxlogins <%= @maxlogins_limit %>
39
+ <% else -%><% unless @maxlogins_soft_limit.nil? -%><%= @ulimit_user -%> soft maxlogins <%= @maxlogins_soft_limit %><% end -%>
40
+ <% unless @maxlogins_hard_limit.nil? -%><%= @ulimit_user -%> hard maxlogins <%= @maxlogins_hard_limit %><% end -%>
41
+ <% end -%>
42
+
43
+ <% unless @msgqueue_limit.nil? -%>
44
+ <%= @ulimit_user -%> - msgqueue <%= @msgqueue_limit %>
45
+ <% else -%><% unless @msgqueue_soft_limit.nil? -%><%= @ulimit_user -%> soft msgqueue <%= @msgqueue_soft_limit %><% end -%>
46
+ <% unless @msgqueue_hard_limit.nil? -%><%= @ulimit_user -%> hard msgqueue <%= @msgqueue_hard_limit %><% end -%>
47
+ <% end -%>
48
+
21
49
  <% unless @core_limit.nil? -%>
22
50
  <%= @ulimit_user -%> - core <%= @core_limit %>
23
51
  <% else -%><% unless @core_soft_limit.nil? -%><%= @ulimit_user -%> soft core <%= @core_soft_limit %><% end -%>
24
52
  <% unless @core_hard_limit.nil? -%><%= @ulimit_user -%> hard core <%= @core_hard_limit %><% end -%>
25
53
  <% end -%>
26
54
 
55
+ <% unless @sigpending_limit.nil? -%>
56
+ <%= @ulimit_user -%> - sigpending <%= @sigpending_limit %>
57
+ <% else -%><% unless @sigpending_soft_limit.nil? -%><%= @ulimit_user -%> soft sigpending <%= @sigpending_soft_limit %><% end -%>
58
+ <% unless @sigpending_hard_limit.nil? -%><%= @ulimit_user -%> hard sigpending <%= @sigpending_hard_limit %><% end -%>
59
+ <% end -%>
60
+
27
61
  <% unless @stack_limit.nil? -%>
28
62
  <%= @ulimit_user -%> - stack <%= @stack_limit %>
29
63
  <% else -%><% unless @stack_soft_limit.nil? -%><%= @ulimit_user -%> soft stack <%= @stack_soft_limit %><% end -%>
30
64
  <% unless @stack_hard_limit.nil? -%><%= @ulimit_user -%> hard stack <%= @stack_hard_limit %><% end -%>
31
65
  <% end -%>
32
66
 
67
+ <% unless @rss_limit.nil? -%>
68
+ <%= @ulimit_user -%> - rss <%= @rss_limit %>
69
+ <% else -%><% unless @rss_soft_limit.nil? -%><%= @ulimit_user -%> soft rss <%= @rss_soft_limit %><% end -%>
70
+ <% unless @rss_hard_limit.nil? -%><%= @ulimit_user -%> hard rss <%= @rss_hard_limit %><% end -%>
71
+ <% end -%>
72
+
33
73
  <% unless @rtprio_limit.nil? -%>
34
74
  <%= @ulimit_user -%> - rtprio <%= @rtprio_limit %>
35
75
  <% else -%><% unless @rtprio_soft_limit.nil? -%><%= @ulimit_user -%> soft rtprio <%= @rtprio_soft_limit %><% end -%>