chef 17.10.95 → 18.1.0

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 (329) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +16 -8
  3. data/README.md +7 -7
  4. data/Rakefile +3 -22
  5. data/{chef-universal-mingw32.gemspec → chef-universal-mingw-ucrt.gemspec} +8 -7
  6. data/chef.gemspec +12 -5
  7. data/lib/chef/api_client_v1.rb +9 -1
  8. data/lib/chef/application/exit_code.rb +3 -3
  9. data/lib/chef/chef_fs/file_system.rb +21 -7
  10. data/lib/chef/client.rb +169 -17
  11. data/lib/chef/compliance/input.rb +1 -1
  12. data/lib/chef/compliance/profile.rb +1 -1
  13. data/lib/chef/compliance/profile_collection.rb +0 -1
  14. data/lib/chef/compliance/waiver.rb +1 -1
  15. data/lib/chef/cookbook/syntax_check.rb +2 -2
  16. data/lib/chef/dsl/reader_helpers.rb +1 -1
  17. data/lib/chef/dsl/rest_resource.rb +77 -0
  18. data/lib/chef/event_dispatch/base.rb +3 -0
  19. data/lib/chef/exceptions.rb +8 -0
  20. data/lib/chef/http/authenticator.rb +170 -3
  21. data/lib/chef/http/ssl_policies.rb +3 -3
  22. data/lib/chef/mixin/powershell_exec.rb +5 -28
  23. data/lib/chef/node/mixin/immutablize_array.rb +1 -0
  24. data/lib/chef/property.rb +13 -6
  25. data/lib/chef/provider/cron.rb +5 -1
  26. data/lib/chef/provider/group/windows.rb +1 -1
  27. data/lib/chef/provider/http_request.rb +11 -9
  28. data/lib/chef/provider/launchd.rb +1 -0
  29. data/lib/chef/provider/mount/linux.rb +5 -0
  30. data/lib/chef/provider/mount/mount.rb +8 -0
  31. data/lib/chef/provider/mount/windows.rb +1 -1
  32. data/lib/chef/provider/package/chocolatey.rb +1 -18
  33. data/lib/chef/provider/package/rubygems.rb +1 -1
  34. data/lib/chef/provider/package/snap.rb +1 -1
  35. data/lib/chef/provider/package/windows/msi.rb +2 -2
  36. data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +1 -1
  37. data/lib/chef/provider/package/yum/yum_helper.py +5 -17
  38. data/lib/chef/provider/package/zypper/version.rb +60 -0
  39. data/lib/chef/provider/package/zypper.rb +47 -3
  40. data/lib/chef/provider/service/windows.rb +1 -1
  41. data/lib/chef/provider/user/aix.rb +5 -0
  42. data/lib/chef/provider/user/linux.rb +29 -0
  43. data/lib/chef/provider/user/mac.rb +1 -1
  44. data/lib/chef/provider/user.rb +46 -14
  45. data/lib/chef/provider/yum_repository.rb +13 -1
  46. data/lib/chef/provider.rb +1 -1
  47. data/lib/chef/recipe.rb +1 -1
  48. data/lib/chef/resource/_rest_resource.rb +389 -0
  49. data/lib/chef/resource/alternatives.rb +0 -1
  50. data/lib/chef/resource/apt_package.rb +2 -1
  51. data/lib/chef/resource/apt_preference.rb +0 -1
  52. data/lib/chef/resource/apt_repository.rb +0 -1
  53. data/lib/chef/resource/apt_update.rb +0 -1
  54. data/lib/chef/resource/archive_file.rb +0 -1
  55. data/lib/chef/resource/bash.rb +0 -1
  56. data/lib/chef/resource/batch.rb +0 -1
  57. data/lib/chef/resource/bff_package.rb +0 -1
  58. data/lib/chef/resource/breakpoint.rb +0 -1
  59. data/lib/chef/resource/build_essential.rb +0 -1
  60. data/lib/chef/resource/cab_package.rb +0 -1
  61. data/lib/chef/resource/chef_client_config.rb +12 -14
  62. data/lib/chef/resource/chef_client_cron.rb +1 -2
  63. data/lib/chef/resource/chef_client_launchd.rb +2 -2
  64. data/lib/chef/resource/chef_client_scheduled_task.rb +3 -3
  65. data/lib/chef/resource/chef_client_systemd_timer.rb +0 -1
  66. data/lib/chef/resource/chef_client_trusted_certificate.rb +0 -1
  67. data/lib/chef/resource/chef_gem.rb +0 -1
  68. data/lib/chef/resource/chef_handler.rb +0 -1
  69. data/lib/chef/resource/chef_sleep.rb +1 -3
  70. data/lib/chef/resource/chef_vault_secret.rb +0 -1
  71. data/lib/chef/resource/chocolatey_config.rb +0 -1
  72. data/lib/chef/resource/chocolatey_feature.rb +0 -1
  73. data/lib/chef/resource/chocolatey_package.rb +0 -1
  74. data/lib/chef/resource/chocolatey_source.rb +0 -1
  75. data/lib/chef/resource/cookbook_file.rb +0 -1
  76. data/lib/chef/resource/cron/_cron_shared.rb +0 -1
  77. data/lib/chef/resource/cron/cron.rb +0 -1
  78. data/lib/chef/resource/cron/cron_d.rb +15 -1
  79. data/lib/chef/resource/cron_access.rb +0 -1
  80. data/lib/chef/resource/csh.rb +0 -1
  81. data/lib/chef/resource/directory.rb +0 -1
  82. data/lib/chef/resource/dmg_package.rb +2 -1
  83. data/lib/chef/resource/dnf_package.rb +0 -1
  84. data/lib/chef/resource/dpkg_package.rb +0 -1
  85. data/lib/chef/resource/dsc_resource.rb +0 -1
  86. data/lib/chef/resource/dsc_script.rb +0 -1
  87. data/lib/chef/resource/execute.rb +0 -1
  88. data/lib/chef/resource/file.rb +0 -1
  89. data/lib/chef/resource/freebsd_package.rb +2 -1
  90. data/lib/chef/resource/gem_package.rb +2 -1
  91. data/lib/chef/resource/group.rb +25 -2
  92. data/lib/chef/resource/habitat/habitat_package.rb +0 -1
  93. data/lib/chef/resource/habitat/habitat_sup.rb +6 -7
  94. data/lib/chef/resource/habitat/habitat_sup_windows.rb +1 -1
  95. data/lib/chef/resource/habitat_config.rb +0 -1
  96. data/lib/chef/resource/habitat_install.rb +0 -1
  97. data/lib/chef/resource/habitat_service.rb +0 -1
  98. data/lib/chef/resource/habitat_user_toml.rb +0 -1
  99. data/lib/chef/resource/homebrew_cask.rb +0 -1
  100. data/lib/chef/resource/homebrew_package.rb +2 -1
  101. data/lib/chef/resource/homebrew_tap.rb +0 -1
  102. data/lib/chef/resource/homebrew_update.rb +0 -2
  103. data/lib/chef/resource/hostname.rb +0 -1
  104. data/lib/chef/resource/http_request.rb +0 -1
  105. data/lib/chef/resource/ifconfig.rb +0 -1
  106. data/lib/chef/resource/inspec_input.rb +0 -1
  107. data/lib/chef/resource/inspec_waiver.rb +0 -1
  108. data/lib/chef/resource/inspec_waiver_file_entry.rb +2 -3
  109. data/lib/chef/resource/ips_package.rb +0 -1
  110. data/lib/chef/resource/kernel_module.rb +0 -1
  111. data/lib/chef/resource/ksh.rb +0 -1
  112. data/lib/chef/resource/launchd.rb +3 -1
  113. data/lib/chef/resource/link.rb +0 -1
  114. data/lib/chef/resource/locale.rb +2 -6
  115. data/lib/chef/resource/log.rb +0 -1
  116. data/lib/chef/resource/lwrp_base.rb +0 -4
  117. data/lib/chef/resource/macos_userdefaults.rb +8 -13
  118. data/lib/chef/resource/macosx_service.rb +0 -1
  119. data/lib/chef/resource/macports_package.rb +2 -1
  120. data/lib/chef/resource/mdadm.rb +0 -1
  121. data/lib/chef/resource/mount.rb +0 -1
  122. data/lib/chef/resource/msu_package.rb +0 -1
  123. data/lib/chef/resource/notify_group.rb +0 -2
  124. data/lib/chef/resource/ohai.rb +0 -1
  125. data/lib/chef/resource/ohai_hint.rb +0 -1
  126. data/lib/chef/resource/openbsd_package.rb +2 -1
  127. data/lib/chef/resource/openssl_dhparam.rb +0 -2
  128. data/lib/chef/resource/openssl_ec_private_key.rb +0 -2
  129. data/lib/chef/resource/openssl_ec_public_key.rb +0 -2
  130. data/lib/chef/resource/openssl_rsa_private_key.rb +0 -2
  131. data/lib/chef/resource/openssl_rsa_public_key.rb +0 -2
  132. data/lib/chef/resource/openssl_x509_certificate.rb +0 -2
  133. data/lib/chef/resource/openssl_x509_crl.rb +0 -2
  134. data/lib/chef/resource/openssl_x509_request.rb +0 -2
  135. data/lib/chef/resource/osx_profile.rb +0 -1
  136. data/lib/chef/resource/package.rb +0 -1
  137. data/lib/chef/resource/pacman_package.rb +2 -1
  138. data/lib/chef/resource/paludis_package.rb +0 -1
  139. data/lib/chef/resource/perl.rb +0 -1
  140. data/lib/chef/resource/plist.rb +7 -3
  141. data/lib/chef/resource/portage_package.rb +2 -1
  142. data/lib/chef/resource/powershell_package.rb +0 -1
  143. data/lib/chef/resource/powershell_package_source.rb +0 -1
  144. data/lib/chef/resource/powershell_script.rb +0 -1
  145. data/lib/chef/resource/python.rb +0 -1
  146. data/lib/chef/resource/reboot.rb +0 -1
  147. data/lib/chef/resource/registry_key.rb +0 -1
  148. data/lib/chef/resource/remote_directory.rb +0 -1
  149. data/lib/chef/resource/remote_file.rb +0 -1
  150. data/lib/chef/resource/rhsm_errata.rb +0 -1
  151. data/lib/chef/resource/rhsm_errata_level.rb +0 -1
  152. data/lib/chef/resource/rhsm_register.rb +2 -4
  153. data/lib/chef/resource/rhsm_repo.rb +0 -1
  154. data/lib/chef/resource/rhsm_subscription.rb +0 -1
  155. data/lib/chef/resource/route.rb +0 -1
  156. data/lib/chef/resource/rpm_package.rb +2 -1
  157. data/lib/chef/resource/ruby.rb +0 -1
  158. data/lib/chef/resource/ruby_block.rb +0 -1
  159. data/lib/chef/resource/scm/_scm.rb +0 -2
  160. data/lib/chef/resource/scm/git.rb +0 -2
  161. data/lib/chef/resource/scm/subversion.rb +0 -2
  162. data/lib/chef/resource/script.rb +0 -1
  163. data/lib/chef/resource/selinux/common_helpers.rb +47 -0
  164. data/lib/chef/resource/selinux/selinux_debian.erb +18 -0
  165. data/lib/chef/resource/selinux/selinux_default.erb +15 -0
  166. data/lib/chef/resource/selinux_boolean.rb +101 -0
  167. data/lib/chef/resource/selinux_fcontext.rb +160 -0
  168. data/lib/chef/resource/selinux_install.rb +107 -0
  169. data/lib/chef/resource/selinux_module.rb +143 -0
  170. data/lib/chef/resource/selinux_permissive.rb +64 -0
  171. data/lib/chef/resource/selinux_port.rb +118 -0
  172. data/lib/chef/resource/selinux_state.rb +166 -0
  173. data/lib/chef/resource/service.rb +0 -1
  174. data/lib/chef/resource/smartos_package.rb +2 -1
  175. data/lib/chef/resource/snap_package.rb +2 -1
  176. data/lib/chef/resource/solaris_package.rb +2 -1
  177. data/lib/chef/resource/ssh_known_hosts_entry.rb +0 -1
  178. data/lib/chef/resource/sudo.rb +0 -1
  179. data/lib/chef/resource/support/client.erb +2 -2
  180. data/lib/chef/resource/swap_file.rb +0 -1
  181. data/lib/chef/resource/sysctl.rb +1 -2
  182. data/lib/chef/resource/systemd_unit.rb +0 -1
  183. data/lib/chef/resource/template.rb +0 -1
  184. data/lib/chef/resource/timezone.rb +0 -1
  185. data/lib/chef/resource/user/aix_user.rb +0 -1
  186. data/lib/chef/resource/user/linux_user.rb +0 -1
  187. data/lib/chef/resource/user/mac_user.rb +0 -1
  188. data/lib/chef/resource/user/pw_user.rb +0 -1
  189. data/lib/chef/resource/user/solaris_user.rb +0 -1
  190. data/lib/chef/resource/user/windows_user.rb +0 -1
  191. data/lib/chef/resource/user.rb +10 -1
  192. data/lib/chef/resource/user_ulimit.rb +0 -1
  193. data/lib/chef/resource/whyrun_safe_ruby_block.rb +0 -1
  194. data/lib/chef/resource/windows_ad_join.rb +0 -2
  195. data/lib/chef/resource/windows_audit_policy.rb +0 -2
  196. data/lib/chef/resource/windows_auto_run.rb +0 -1
  197. data/lib/chef/resource/windows_defender.rb +0 -1
  198. data/lib/chef/resource/windows_defender_exclusion.rb +0 -1
  199. data/lib/chef/resource/windows_dfs_folder.rb +0 -1
  200. data/lib/chef/resource/windows_dfs_namespace.rb +0 -1
  201. data/lib/chef/resource/windows_dfs_server.rb +0 -1
  202. data/lib/chef/resource/windows_dns_record.rb +0 -1
  203. data/lib/chef/resource/windows_dns_zone.rb +0 -1
  204. data/lib/chef/resource/windows_env.rb +0 -1
  205. data/lib/chef/resource/windows_feature.rb +0 -1
  206. data/lib/chef/resource/windows_feature_dism.rb +0 -1
  207. data/lib/chef/resource/windows_feature_powershell.rb +0 -1
  208. data/lib/chef/resource/windows_firewall_profile.rb +0 -2
  209. data/lib/chef/resource/windows_firewall_rule.rb +0 -1
  210. data/lib/chef/resource/windows_font.rb +2 -3
  211. data/lib/chef/resource/windows_package.rb +3 -4
  212. data/lib/chef/resource/windows_pagefile.rb +0 -2
  213. data/lib/chef/resource/windows_path.rb +0 -1
  214. data/lib/chef/resource/windows_printer.rb +0 -1
  215. data/lib/chef/resource/windows_printer_port.rb +0 -1
  216. data/lib/chef/resource/windows_script.rb +0 -2
  217. data/lib/chef/resource/windows_security_policy.rb +0 -1
  218. data/lib/chef/resource/windows_service.rb +0 -1
  219. data/lib/chef/resource/windows_share.rb +0 -1
  220. data/lib/chef/resource/windows_shortcut.rb +1 -2
  221. data/lib/chef/resource/windows_task.rb +0 -1
  222. data/lib/chef/resource/windows_uac.rb +0 -1
  223. data/lib/chef/resource/windows_update_settings.rb +0 -1
  224. data/lib/chef/resource/windows_user_privilege.rb +0 -1
  225. data/lib/chef/resource/windows_workgroup.rb +0 -1
  226. data/lib/chef/resource/yum_package.rb +2 -1
  227. data/lib/chef/resource/yum_repository.rb +4 -1
  228. data/lib/chef/resource/zypper_package.rb +2 -1
  229. data/lib/chef/resource/zypper_repository.rb +0 -1
  230. data/lib/chef/resource.rb +12 -5
  231. data/lib/chef/resources.rb +7 -0
  232. data/lib/chef/run_context.rb +3 -3
  233. data/lib/chef/secret_fetcher/azure_key_vault.rb +3 -3
  234. data/lib/chef/version.rb +1 -1
  235. data/lib/chef/win32/handle.rb +6 -7
  236. data/lib/chef/win32/registry.rb +7 -3
  237. data/spec/data/chef_guid +1 -0
  238. data/spec/data/nodes/mcwfhpowell.json +3 -0
  239. data/spec/data/rubygems.org/sexp_processor-info +2 -1
  240. data/spec/data/trusted_certs/example.crt +20 -29
  241. data/spec/data/trusted_certs/example_no_cn.crt +34 -30
  242. data/spec/data/trusted_certs/opscode.pem +54 -33
  243. data/spec/functional/assets/yumrepo-empty/repodata/01a3b489a465bcac22a43492163df43451dc6ce47d27f66de289756b91635523-filelists.sqlite.bz2 +0 -0
  244. data/spec/functional/assets/yumrepo-empty/repodata/401dc19bda88c82c403423fb835844d64345f7e95f5b9835888189c03834cc93-filelists.xml.gz +0 -0
  245. data/spec/functional/assets/yumrepo-empty/repodata/5dc1e6e73c84803f059bb3065e684e56adfc289a7e398946574d79dac6643945-primary.sqlite.bz2 +0 -0
  246. data/spec/functional/assets/yumrepo-empty/repodata/6bf9672d0862e8ef8b8ff05a2fd0208a922b1f5978e6589d87944c88259cb670-other.xml.gz +0 -0
  247. data/spec/functional/assets/yumrepo-empty/repodata/7c36572015e075add2b38b900837bcdbb8a504130ddff49b2351a7fc0affa3d4-other.sqlite.bz2 +0 -0
  248. data/spec/functional/assets/yumrepo-empty/repodata/dabe2ce5481d23de1f4f52bdcfee0f9af98316c9e0de2ce8123adeefa0dd08b9-primary.xml.gz +0 -0
  249. data/spec/functional/assets/yumrepo-empty/repodata/repomd.xml +55 -0
  250. data/spec/functional/resource/chocolatey_package_spec.rb +20 -32
  251. data/spec/functional/resource/dsc_script_spec.rb +1 -1
  252. data/spec/functional/resource/group_spec.rb +10 -6
  253. data/spec/functional/resource/link_spec.rb +8 -8
  254. data/spec/functional/resource/macos_userdefaults_spec.rb +4 -4
  255. data/spec/functional/resource/plist_spec.rb +25 -0
  256. data/spec/functional/resource/user/linux_user_spec.rb +127 -0
  257. data/spec/functional/resource/windows_certificate_spec.rb +1 -26
  258. data/spec/functional/resource/windows_font_spec.rb +12 -9
  259. data/spec/functional/resource/yum_package_spec.rb +17 -1
  260. data/spec/functional/resource/zypper_package_spec.rb +12 -0
  261. data/spec/functional/shell_spec.rb +1 -2
  262. data/spec/functional/version_spec.rb +1 -1
  263. data/spec/integration/client/client_spec.rb +82 -3
  264. data/spec/integration/client/exit_code_spec.rb +1 -1
  265. data/spec/integration/client/fips_spec.rb +20 -0
  266. data/spec/integration/client/ipv6_spec.rb +1 -1
  267. data/spec/integration/compliance/compliance_spec.rb +1 -1
  268. data/spec/integration/recipes/accumulator_spec.rb +1 -1
  269. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +1 -1
  270. data/spec/integration/recipes/lwrp_spec.rb +1 -1
  271. data/spec/integration/recipes/notifies_spec.rb +1 -1
  272. data/spec/integration/recipes/notifying_block_spec.rb +1 -1
  273. data/spec/integration/recipes/remote_directory.rb +1 -1
  274. data/spec/integration/recipes/unified_mode_spec.rb +1 -1
  275. data/spec/integration/recipes/use_partial_spec.rb +2 -1
  276. data/spec/integration/solo/solo_spec.rb +2 -2
  277. data/spec/spec_helper.rb +5 -0
  278. data/spec/support/platform_helpers.rb +8 -0
  279. data/spec/support/ruby_installer.rb +1 -1
  280. data/spec/support/shared/functional/windows_script.rb +2 -2
  281. data/spec/unit/application/client_spec.rb +0 -10
  282. data/spec/unit/chef_fs/file_system_spec.rb +2 -0
  283. data/spec/unit/client_spec.rb +57 -8
  284. data/spec/unit/compliance/reporter/chef_server_automate_spec.rb +1 -1
  285. data/spec/unit/cookbook/syntax_check_spec.rb +3 -0
  286. data/spec/unit/http/authenticator_spec.rb +68 -0
  287. data/spec/unit/mixin/powershell_exec_spec.rb +5 -5
  288. data/spec/unit/platform/query_helpers_spec.rb +2 -17
  289. data/spec/unit/property/validation_spec.rb +30 -0
  290. data/spec/unit/provider/cron_spec.rb +36 -0
  291. data/spec/unit/provider/http_request_spec.rb +60 -72
  292. data/spec/unit/provider/mount/linux_spec.rb +10 -0
  293. data/spec/unit/provider/package/chocolatey_spec.rb +3 -19
  294. data/spec/unit/provider/package/rubygems_spec.rb +1 -1
  295. data/spec/unit/provider/package/zypper_spec.rb +32 -0
  296. data/spec/unit/provider/user/linux_spec.rb +51 -11
  297. data/spec/unit/provider/user_spec.rb +24 -6
  298. data/spec/unit/resource/archive_file_spec.rb +1 -1
  299. data/spec/unit/resource/chef_client_cron_spec.rb +5 -0
  300. data/spec/unit/resource/chef_client_launchd_spec.rb +5 -0
  301. data/spec/unit/resource/chef_client_scheduled_task_spec.rb +5 -0
  302. data/spec/unit/resource/chef_client_systemd_timer_spec.rb +1 -1
  303. data/spec/unit/resource/cron_d_spec.rb +37 -1
  304. data/spec/unit/resource/macos_user_defaults_spec.rb +4 -4
  305. data/spec/unit/resource/rest_resource_spec.rb +381 -0
  306. data/spec/unit/resource/selinux_boolean_spec.rb +92 -0
  307. data/spec/unit/resource/selinux_fcontext_spec.rb +65 -0
  308. data/spec/unit/resource/selinux_install_spec.rb +60 -0
  309. data/spec/unit/resource/selinux_module_spec.rb +55 -0
  310. data/spec/unit/resource/selinux_permissive_spec.rb +39 -0
  311. data/spec/unit/resource/selinux_port_spec.rb +42 -0
  312. data/spec/unit/resource/selinux_state_spec.rb +46 -0
  313. data/spec/unit/resource/sysctl_spec.rb +2 -2
  314. data/spec/unit/resource/user/linux_user_spec.rb +42 -0
  315. data/spec/unit/resource/yum_repository_spec.rb +4 -0
  316. data/spec/unit/resource_spec.rb +0 -1
  317. data/spec/unit/util/dsc/local_configuration_manager_spec.rb +1 -1
  318. data/tasks/rspec.rb +1 -1
  319. metadata +107 -31
  320. /data/spec/functional/assets/chocolatey_feed/{test-A.1.0.0.nupkg → test-A.1.0.nupkg} +0 -0
  321. /data/spec/functional/assets/chocolatey_feed/{test-A.1.5.0.nupkg → test-A.1.5.nupkg} +0 -0
  322. /data/spec/functional/assets/chocolatey_feed/{test-A.2.0.0.nupkg → test-A.2.0.nupkg} +0 -0
  323. /data/spec/functional/assets/chocolatey_feed/{test-B.1.0.0.nupkg → test-B.1.0.nupkg} +0 -0
  324. /data/spec/functional/assets/yumrepo/repodata/{01a3b-filelists.sqlite.bz2 → 4632d67cb92636e7575d911c24f0e04d3505a944e97c483abe0c3e73a7c62d33-filelists.sqlite.bz2} +0 -0
  325. /data/spec/functional/assets/yumrepo/repodata/{6bf96-other.xml.gz → 74599b793e54d877323837d2d81a1c3c594c44e4335f9528234bb490f7b9b439-other.xml.gz} +0 -0
  326. /data/spec/functional/assets/yumrepo/repodata/{5dc1e-primary.sqlite.bz2 → a845d418f919d2115ab95a56b2c76f6825ad0d0bede49181a55c04f58995d057-primary.sqlite.bz2} +0 -0
  327. /data/spec/functional/assets/yumrepo/repodata/{7c365-other.sqlite.bz2 → af9b7cf9ef23bd7b43068d74a460f3b5d06753d638e58e4a0c9edc35bfb9cdc4-other.sqlite.bz2} +0 -0
  328. /data/spec/functional/assets/yumrepo/repodata/{401dc-filelists.xml.gz → bdb4f5f1492a3b9532f22c43110a81500dd744f23da0aec5c33b2a41317c737d-filelists.xml.gz} +0 -0
  329. /data/spec/functional/assets/yumrepo/repodata/{dabe2-primary.xml.gz → c10d1d34ce99e02f12ec96ef68360543ab1bb7c3cb81a4a2bf78df7d8597e9df-primary.xml.gz} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cbd02b60802f0874cef53b37a8b8d5996600fdcb6c53c29263fe454b18bf0cb6
4
- data.tar.gz: 70e96d302b07784e0b2fe4c93141f72510169f5a5456f6084d6d3f51fece3a33
3
+ metadata.gz: 2116a9a16e93030ed9aa85235426085567d3ef63e0c603bffa3a5a1614bb439e
4
+ data.tar.gz: cc9dcbc47ddcb72e3fe920f9da13a788a607b66d628331b23a03ea8dbad53c30
5
5
  SHA512:
6
- metadata.gz: f61a95453d1b50956c6c0b72552b3c8581b1707606589375352a0bdbbde54f7504c9a37d635b4ac2b2299ed33e75dfdec535ca2802b5be1e60a4ad1d33bf35b0
7
- data.tar.gz: 0c8fbbd7634626b2178516af1df72274d352f789097b5fde508b38d00e98860c6c359f391a4c2bc2573ff257b63a7d5833937ef3e0c9b1a1ea1e709504093c41
6
+ metadata.gz: d14c879526c8da207c572690f7e5c0a066c8ff89d33412053f6eaf3635ae2231d1f0c2c3478b1ebae30219ac0cbf86ee8c2381239eda50b937f853c2b7a77028
7
+ data.tar.gz: 1bfb25d57117e4cc93655ab55573cebcffd9854402a59606f79e5a6e05bc8660d18c2ccc85d2a09c007789509dd23abee90a1a3d26a07bc6d93ba8fff12d0b58
data/Gemfile CHANGED
@@ -2,8 +2,12 @@ source "https://rubygems.org"
2
2
 
3
3
  gem "chef", path: "."
4
4
 
5
- gem "ohai", git: "https://github.com/chef/ohai.git", branch: "17-stable"
5
+ gem "ohai", git: "https://github.com/chef/ohai.git", branch: "main"
6
6
 
7
+ # Nwed to file a bug with rest-client. In the meantime, we can use this until they accept the update.
8
+ gem "rest-client", git: "https://github.com/chef/rest-client", branch: "jfm/ucrt_update1"
9
+
10
+ gem "ffi", ">= 1.15.5"
7
11
  gem "chef-utils", path: File.expand_path("chef-utils", __dir__) if File.exist?(File.expand_path("chef-utils", __dir__))
8
12
  gem "chef-config", path: File.expand_path("chef-config", __dir__) if File.exist?(File.expand_path("chef-config", __dir__))
9
13
 
@@ -15,12 +19,12 @@ else
15
19
  gem "chef-bin" # rubocop:disable Bundler/DuplicatedGem
16
20
  end
17
21
 
18
- gem "cheffish", "~> 17.0.0"
22
+ gem "cheffish", ">= 17"
19
23
 
20
24
  group(:omnibus_package) do
21
25
  gem "appbundler"
22
26
  gem "rb-readline"
23
- gem "inspec-core-bin", ">= 4.24" # need to provide the binaries for inspec
27
+ gem "inspec-core-bin", ">= 5" # need to provide the binaries for inspec
24
28
  gem "chef-vault"
25
29
  end
26
30
 
@@ -33,10 +37,13 @@ group(:omnibus_package, :pry) do
33
37
  gem "pry-stack_explorer"
34
38
  end
35
39
 
40
+ # proxifier gem is busted on ruby 3.1 and seems abandoned so use git fork of gem
41
+ gem "proxifier", git: "https://github.com/chef/ruby-proxifier", branch: "lcg/ruby-3"
42
+
36
43
  # Everything except AIX and Windows
37
44
  group(:ruby_shadow) do
38
45
  # if ruby-shadow does a release that supports ruby-3.0 this can be removed
39
- gem "ruby-shadow", git: "https://github.com/chef/ruby-shadow", branch: "lcg/ruby-3.0", platforms: :ruby
46
+ gem "ruby-shadow", git: "https://github.com/chef/ruby-shadow", branch: "lcg/ruby-3.0", platforms: :ruby unless RUBY_PLATFORM == "x64-mingw-ucrt"
40
47
  end
41
48
 
42
49
  # deps that cannot be put in the knife gem because they require a compiler and fail on windows nodes
@@ -51,10 +58,11 @@ group(:development, :test) do
51
58
  gem "fauxhai-ng" # for chef-utils gem
52
59
  end
53
60
 
54
- group(:chefstyle) do
55
- # for testing new chefstyle rules
56
- gem "chefstyle", git: "https://github.com/chef/chefstyle.git", branch: "main"
57
- end
61
+ gem "chefstyle"
62
+ # group(:chefstyle) do
63
+ # # for testing new chefstyle rules
64
+ # gem "chefstyle", git: "https://github.com/chef/chefstyle.git", branch: "main"
65
+ # end
58
66
 
59
67
  instance_eval(ENV["GEMFILE_MOD"]) if ENV["GEMFILE_MOD"]
60
68
 
data/README.md CHANGED
@@ -1,16 +1,16 @@
1
1
  # Chef Infra
2
2
  [![Code Climate](https://codeclimate.com/github/chef/chef.svg)](https://codeclimate.com/github/chef/chef)
3
- [![Build Status](https://badge.buildkite.com/c82093430ceec7d27af05febb9dcafe3aa331fff9d74c0ab9d.svg?branch=chef-17)](https://buildkite.com/chef-oss/chef-chef-chef-17-verify)
3
+ [![Build Status](https://badge.buildkite.com/c82093430ceec7d27af05febb9dcafe3aa331fff9d74c0ab9d.svg?branch=main)](https://buildkite.com/chef-oss/chef-chef-main-verify)
4
4
  [![Gem Version](https://badge.fury.io/rb/chef.svg)](https://badge.fury.io/rb/chef)
5
- [![](https://img.shields.io/badge/Release%20Policy-Cadence%20Release-brightgreen.svg)](https://github.com/chef/chef/blob/master/docs/dev/design_documents/client_release_cadence.md)
5
+ [![](https://img.shields.io/badge/Release%20Policy-Cadence%20Release-brightgreen.svg)](https://github.com/chef/chef/blob/main/docs/dev/design_documents/client_release_cadence.md)
6
6
 
7
- **Umbrella Project**: [Chef Infra](https://github.com/chef/chef-oss-practices/blob/master/projects/chef-infra.md)
7
+ **Umbrella Project**: [Chef Infra](https://github.com/chef/chef-oss-practices/blob/main/projects/chef-infra.md)
8
8
 
9
- **Project State**: [Active](https://github.com/chef/chef-oss-practices/blob/master/repo-management/repo-states.md#active)
9
+ **Project State**: [Active](https://github.com/chef/chef-oss-practices/blob/main/repo-management/repo-states.md#active)
10
10
 
11
- **Issues [Response Time Maximum](https://github.com/chef/chef-oss-practices/blob/master/repo-management/repo-states.md)**: 14 days
11
+ **Issues [Response Time Maximum](https://github.com/chef/chef-oss-practices/blob/main/repo-management/repo-states.md)**: 14 days
12
12
 
13
- **Pull Request [Response Time Maximum](https://github.com/chef/chef-oss-practices/blob/master/repo-management/repo-states.md)**: 14 days
13
+ **Pull Request [Response Time Maximum](https://github.com/chef/chef-oss-practices/blob/main/repo-management/repo-states.md)**: 14 days
14
14
 
15
15
  ## Getting Started
16
16
 
@@ -23,7 +23,7 @@ For Chef Infra usage, please refer to [Learn Chef](https://learn.chef.io/), our
23
23
  Other useful resources for Chef Infra users:
24
24
 
25
25
  - Documentation: <https://docs.chef.io/>
26
- - Source: <https://github.com/chef/chef/tree/master>
26
+ - Source: <https://github.com/chef/chef/tree/main>
27
27
  - Tickets/Issues: <https://github.com/chef/chef/issues>
28
28
  - Slack: [Chef Community Slack](https://community-slack.chef.io/)
29
29
  - Mailing list/Forum: <https://discourse.chef.io>
data/Rakefile CHANGED
@@ -40,7 +40,7 @@ namespace :pre_install do
40
40
  %w{chef-utils chef-config}.each do |gem|
41
41
  path = ::File.join(::File.dirname(__FILE__), gem)
42
42
  Dir.chdir(path) do
43
- sh("rake install")
43
+ system "rake install"
44
44
  end
45
45
  end
46
46
  end
@@ -61,9 +61,9 @@ end
61
61
 
62
62
  # hack in all the preinstall tasks to occur before the traditional install task
63
63
  task install: "pre_install:all"
64
-
65
64
  # make sure we build the correct gemspec on windows
66
- gemspec = Gem.win_platform? ? "chef-universal-mingw32" : "chef"
65
+ gemspec = Gem.win_platform? ? "chef-universal-mingw-ucrt" : "chef"
66
+
67
67
  Bundler::GemHelper.install_tasks name: gemspec
68
68
 
69
69
  # this gets appended to the normal bundler install helper
@@ -99,25 +99,6 @@ task :register_eventlog do
99
99
  end
100
100
  end
101
101
 
102
- desc "Copies powershell_exec related binaries from the latest built Habitat Packages"
103
- task :update_chef_exec_dll do
104
- raise "This task must be run on Windows since we are installing a Windows targeted package!" unless Gem.win_platform?
105
-
106
- require "mkmf"
107
- raise "Unable to locate Habitat cli. Please install Habitat cli before invoking this task!" unless find_executable "hab"
108
-
109
- sh("hab pkg install chef/chef-powershell-shim")
110
- sh("hab pkg install chef/chef-powershell-shim-x86")
111
- x64 = `hab pkg path chef/chef-powershell-shim`.chomp.tr("\\", "/")
112
- x86 = `hab pkg path chef/chef-powershell-shim-x86`.chomp.tr("\\", "/")
113
- FileUtils.rm_rf(Dir["distro/ruby_bin_folder/AMD64/*"])
114
- FileUtils.rm_rf(Dir["distro/ruby_bin_folder/x86/*"])
115
- puts "Copying #{x64}/bin/* to distro/ruby_bin_folder/AMD64"
116
- FileUtils.cp_r(Dir["#{x64}/bin/*"], "distro/ruby_bin_folder/AMD64")
117
- puts "Copying #{x86}/bin/* to distro/ruby_bin_folder/x86"
118
- FileUtils.cp_r(Dir["#{x86}/bin/*"], "distro/ruby_bin_folder/x86")
119
- end
120
-
121
102
  begin
122
103
  require "chefstyle"
123
104
  require "rubocop/rake_task"
@@ -1,8 +1,8 @@
1
- gemspec = eval(IO.read(File.expand_path("chef.gemspec", __dir__)))
1
+ gemspec = instance_eval(File.read(File.expand_path("chef.gemspec", __dir__)))
2
2
 
3
- gemspec.platform = Gem::Platform.new(%w{universal mingw32})
3
+ gemspec.platform = Gem::Platform.new(%w{x64-mingw-ucrt})
4
4
 
5
- gemspec.add_dependency "win32-api", "~> 1.5.3"
5
+ gemspec.add_dependency "win32-api", "~> 1.10.0"
6
6
  gemspec.add_dependency "win32-event", "~> 0.6.1"
7
7
  # TODO: Relax this pin and make the necessary updaets. The issue originally
8
8
  # leading to this pin has been fixed in 0.6.5.
@@ -11,12 +11,13 @@ gemspec.add_dependency "win32-mmap", "~> 0.4.1"
11
11
  gemspec.add_dependency "win32-mutex", "~> 0.4.2"
12
12
  gemspec.add_dependency "win32-process", "~> 0.9"
13
13
  gemspec.add_dependency "win32-service", ">= 2.1.5", "< 3.0"
14
- gemspec.add_dependency "win32-taskscheduler", "~> 2.0"
15
- gemspec.add_dependency "win32-certstore", "~> 0.6.15"
16
14
  gemspec.add_dependency "wmi-lite", "~> 1.0"
15
+ gemspec.add_dependency "win32-taskscheduler", "~> 2.0"
17
16
  gemspec.add_dependency "iso8601", ">= 0.12.1", "< 0.14" # validate 0.14 when it comes out
18
- gemspec.add_dependency "chef-powershell", "~> 1.0.12" # 0.5+ required for specifying user vs. system store
17
+ gemspec.add_dependency "win32-certstore", "~> 0.6.15" # 0.5+ required for specifying user vs. system store
18
+ gemspec.add_dependency "chef-powershell", "~> 1.0.12" # The guts of the powershell_exec code have been moved to its own gem, chef-powershell. It's part of the chef-powershell-shim repo.
19
+
19
20
  gemspec.extensions << "ext/win32-eventlog/Rakefile"
20
21
  gemspec.files += Dir.glob("{distro,ext}/**/*")
21
22
 
22
- gemspec
23
+ gemspec
data/chef.gemspec CHANGED
@@ -22,12 +22,17 @@ Gem::Specification.new do |s|
22
22
  s.email = "adam@chef.io"
23
23
  s.homepage = "https://www.chef.io"
24
24
 
25
- s.required_ruby_version = ">= 2.7.0"
25
+ if RUBY_PLATFORM =~ /aix/
26
+ s.required_ruby_version = ">= 3.0.3"
27
+ else
28
+ s.required_ruby_version = ">= 3.1.0"
29
+ end
26
30
 
27
31
  s.add_dependency "chef-config", "= #{Chef::VERSION}"
28
32
  s.add_dependency "chef-utils", "= #{Chef::VERSION}"
29
33
  s.add_dependency "train-core", "~> 3.10" # 3.2.28 fixes sudo prompts. See https://github.com/chef/chef/pull/9635
30
34
  s.add_dependency "train-winrm", ">= 0.2.5"
35
+ s.add_dependency "train-rest", ">= 0.4.1" # target mode with rest APIs
31
36
 
32
37
  s.add_dependency "license-acceptance", ">= 1.0.5", "< 3"
33
38
  s.add_dependency "mixlib-cli", ">= 2.1.1", "< 3.0"
@@ -35,12 +40,13 @@ Gem::Specification.new do |s|
35
40
  s.add_dependency "mixlib-authentication", ">= 2.1", "< 4"
36
41
  s.add_dependency "mixlib-shellout", ">= 3.1.1", "< 4.0"
37
42
  s.add_dependency "mixlib-archive", ">= 0.4", "< 2.0"
38
- s.add_dependency "ohai", "~> 17.0"
39
- s.add_dependency "inspec-core", ">= 4.23"
43
+ s.add_dependency "ohai", "~> 18.0"
44
+ s.add_dependency "inspec-core", ">= 5"
40
45
 
41
- s.add_dependency "ffi", "~> 1.15.0"
46
+ s.add_dependency "ffi", ">= 1.15.5"
42
47
  s.add_dependency "ffi-yajl", "~> 2.2"
43
48
  s.add_dependency "net-sftp", ">= 2.1.2", "< 5.0" # remote_file resource
49
+ s.add_dependency "net-ftp" # remote_file resource
44
50
  s.add_dependency "erubis", "~> 2.7" # template resource / cookbook syntax check
45
51
  s.add_dependency "diff-lcs", ">= 1.2.4", "!= 1.4.0", "< 1.6.0" # 1.4 breaks output. Used in lib/chef/util/diff
46
52
  s.add_dependency "ffi-libarchive", "~> 1.0", ">= 1.0.3" # archive_file resource
@@ -52,6 +58,7 @@ Gem::Specification.new do |s|
52
58
  s.add_dependency "addressable"
53
59
  s.add_dependency "syslog-logger", "~> 1.6"
54
60
  s.add_dependency "uuidtools", ">= 2.1.5", "< 3.0" # osx_profile resource
61
+ s.add_dependency "unf_ext", ">= 0.0.8.2" # This is ruby31 compatible ucrt gem version
55
62
  s.add_dependency "corefoundation", "~> 0.3.4" # macos_userdefaults resource
56
63
 
57
64
  s.add_dependency "proxifier", "~> 1.0"
@@ -70,7 +77,7 @@ Gem::Specification.new do |s|
70
77
 
71
78
  s.metadata = {
72
79
  "bug_tracker_uri" => "https://github.com/chef/chef/issues",
73
- "changelog_uri" => "https://github.com/chef/chef/blob/master/CHANGELOG.md",
80
+ "changelog_uri" => "https://github.com/chef/chef/blob/main/CHANGELOG.md",
74
81
  "documentation_uri" => "https://docs.chef.io/",
75
82
  "homepage_uri" => "https://www.chef.io",
76
83
  "mailing_list_uri" => "https://discourse.chef.io/",
@@ -64,6 +64,10 @@ class Chef
64
64
  @chef_rest_v1 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_url], { api_version: "1", inflate_json_class: false })
65
65
  end
66
66
 
67
+ def chef_rest_v1_with_validator
68
+ @chef_rest_v1_with_validator ||= Chef::ServerAPI.new(Chef::Config[:chef_server_url], { client_name: Chef::Config[:validation_client_name], signing_key_filename: Chef::Config[:validation_key], api_version: "1", inflate_json_class: false })
69
+ end
70
+
67
71
  def self.http_api
68
72
  Chef::ServerAPI.new(Chef::Config[:chef_server_url], { api_version: "1", inflate_json_class: false })
69
73
  end
@@ -293,7 +297,11 @@ class Chef
293
297
  payload[:public_key] = public_key unless public_key.nil?
294
298
  payload[:create_key] = create_key unless create_key.nil?
295
299
 
296
- new_client = chef_rest_v1.post("clients", payload)
300
+ new_client = if Chef::Config[:migrate_key_to_keystore] == true
301
+ chef_rest_v1_with_validator.post("clients", payload)
302
+ else
303
+ chef_rest_v1.post("clients", payload)
304
+ end
297
305
 
298
306
  # get the private_key out of the chef_key hash if it exists
299
307
  if new_client["chef_key"]
@@ -19,8 +19,8 @@
19
19
  class Chef
20
20
  class Application
21
21
 
22
- # These are the exit codes defined in Chef RFC 062
23
- # https://github.com/chef/chef-rfc/blob/master/rfc062-exit-status.md
22
+ # These are the exit codes defined in the exit codes design document
23
+ # https://github.com/chef/chef/blob/main/docs/dev/design_documents/client_exit_codes.md
24
24
  class ExitCode
25
25
  require "chef-utils/dist" unless defined?(ChefUtils::Dist)
26
26
 
@@ -140,7 +140,7 @@ class Chef
140
140
 
141
141
  def non_standard_exit_code_warning(exit_code)
142
142
  "#{ChefUtils::Dist::Infra::CLIENT} attempted to exit with a non-standard exit code of #{exit_code}." \
143
- " The #{ChefUtils::Dist::Infra::PRODUCT} Exit Codes design document (https://github.com/chef/chef-rfc/blob/master/rfc062-exit-status.md)" \
143
+ " The #{ChefUtils::Dist::Infra::PRODUCT} Exit Codes design document (https://github.com/chef/chef/blob/main/docs/dev/design_documents/client_exit_codes.md)" \
144
144
  " defines the exit codes that should be used with #{ChefUtils::Dist::Infra::CLIENT}. Chef::Application::ExitCode defines" \
145
145
  " valid exit codes Non-standard exit codes are redefined as GENERIC_FAILURE."
146
146
  end
@@ -140,17 +140,18 @@ class Chef
140
140
  def self.copy_to(pattern, src_root, dest_root, recurse_depth, options, ui = nil, format_path = nil)
141
141
  found_result = false
142
142
  error = false
143
+ result = {}
143
144
  list_pairs(pattern, src_root, dest_root).parallel_each do |src, dest|
144
145
  found_result = true
145
146
  new_dest_parent = get_or_create_parent(dest, options, ui, format_path)
146
- child_error = copy_entries(src, dest, new_dest_parent, recurse_depth, options, ui, format_path)
147
+ child_error, result = copy_entries(src, dest, new_dest_parent, recurse_depth, options, ui, format_path)
147
148
  error ||= child_error
148
149
  end
149
150
  if !found_result && pattern.exact_path
150
151
  ui.error "#{pattern}: No such file or directory on remote or local" if ui
151
152
  error = true
152
153
  end
153
- error
154
+ [error, result]
154
155
  end
155
156
 
156
157
  # Yield entries for children that are in either +a_root+ or +b_root+, with
@@ -275,6 +276,7 @@ class Chef
275
276
  # case we shouldn't waste time trying PUT if we know the file doesn't
276
277
  # exist.
277
278
  # Will need to decide how that works with checksums, though.
279
+ result = { "total" => 0, "success_count" => 0, "failed" => [] }
278
280
  error = false
279
281
  begin
280
282
  dest_path = format_path.call(dest_entry) if ui
@@ -290,6 +292,8 @@ class Chef
290
292
  dest_entry.delete(true)
291
293
  ui.output "Deleted extra entry #{dest_path} (purge is on)" if ui
292
294
  rescue Chef::ChefFS::FileSystem::NotFoundError
295
+ failure = { "src_path" => src_path, "reason" => "Entry #{dest_path} does not exist" }
296
+ result["failed"].append(failure)
293
297
  ui.output "Entry #{dest_path} does not exist. Nothing to do. (purge is on)" if ui
294
298
  end
295
299
  end
@@ -323,7 +327,7 @@ class Chef
323
327
  if recurse_depth != 0
324
328
  src_entry.children.parallel_each do |src_child|
325
329
  new_dest_child = new_dest_dir.child(src_child.name)
326
- child_error = copy_entries(src_child, new_dest_child, new_dest_dir, recurse_depth ? recurse_depth - 1 : recurse_depth, options, ui, format_path)
330
+ child_error, result = copy_entries(src_child, new_dest_child, new_dest_dir, recurse_depth ? recurse_depth - 1 : recurse_depth, options, ui, format_path)
327
331
  error ||= child_error
328
332
  end
329
333
  end
@@ -339,14 +343,15 @@ class Chef
339
343
 
340
344
  else
341
345
  # Both exist.
342
-
343
346
  # If the entry can do a copy directly, do that.
344
347
  if dest_entry.respond_to?(:copy_from)
345
348
  if options[:force] || compare(src_entry, dest_entry)[0] == false
346
349
  if options[:dry_run]
347
350
  ui.output "Would update #{dest_path}" if ui
348
351
  else
352
+ result["total"] += 1
349
353
  dest_entry.copy_from(src_entry, options)
354
+ result["success_count"] += 1
350
355
  ui.output "Updated #{dest_path}" if ui
351
356
  end
352
357
  end
@@ -359,7 +364,7 @@ class Chef
359
364
  # If both are directories, recurse into their children
360
365
  if recurse_depth != 0
361
366
  child_pairs(src_entry, dest_entry).parallel_each do |src_child, dest_child|
362
- child_error = copy_entries(src_child, dest_child, dest_entry, recurse_depth ? recurse_depth - 1 : recurse_depth, options, ui, format_path)
367
+ child_error, result = copy_entries(src_child, dest_child, dest_entry, recurse_depth ? recurse_depth - 1 : recurse_depth, options, ui, format_path)
363
368
  error ||= child_error
364
369
  end
365
370
  end
@@ -373,7 +378,6 @@ class Chef
373
378
  ui.error("File #{src_path} is a regular file while file #{dest_path} is a directory\n") if ui
374
379
  return
375
380
  else
376
-
377
381
  # Both are files! Copy them unless we're sure they are the same.'
378
382
  if options[:diff] == false
379
383
  should_copy = false
@@ -389,7 +393,9 @@ class Chef
389
393
  ui.output "Would update #{dest_path}" if ui
390
394
  else
391
395
  src_value = src_entry.read if src_value.nil?
396
+ result["total"] += 1
392
397
  dest_entry.write(src_value)
398
+ result["success_count"] += 1
393
399
  ui.output "Updated #{dest_path}" if ui
394
400
  end
395
401
  end
@@ -397,17 +403,25 @@ class Chef
397
403
  end
398
404
  end
399
405
  rescue RubyFileError => e
406
+ failure = { "src_path" => src_path, "reason" => e.reason }
407
+ result["failed"].append(failure)
400
408
  ui.warn "#{format_path.call(e.entry)} #{e.reason}." if ui
401
409
  rescue DefaultEnvironmentCannotBeModifiedError => e
410
+ failure = { "src_path" => src_path, "reason" => e.reason }
411
+ result["failed"].append(failure)
402
412
  ui.warn "#{format_path.call(e.entry)} #{e.reason}." if ui
403
413
  rescue OperationFailedError => e
414
+ failure = { "src_path" => src_path, "reason" => e.reason }
415
+ result["failed"].append(failure)
404
416
  ui.error "#{format_path.call(e.entry)} failed to #{e.operation}: #{e.message}" if ui
405
417
  error = true
406
418
  rescue OperationNotAllowedError => e
419
+ failure = { "src_path" => src_path, "reason" => e.reason }
420
+ result["failed"].append(failure)
407
421
  ui.error "#{format_path.call(e.entry)} #{e.reason}." if ui
408
422
  error = true
409
423
  end
410
- error
424
+ [error, result]
411
425
  end
412
426
 
413
427
  def get_or_create_parent(entry, options, ui, format_path)
data/lib/chef/client.rb CHANGED
@@ -64,6 +64,10 @@ class Chef
64
64
  # The main object in a Chef run. Preps a Chef::Node and Chef::RunContext,
65
65
  # syncs cookbooks if necessary, and triggers convergence.
66
66
  class Client
67
+ CRYPT_EXPORTABLE = 0x00000001
68
+
69
+ attr_reader :local_context
70
+
67
71
  extend Chef::Mixin::Deprecation
68
72
 
69
73
  extend Forwardable
@@ -326,27 +330,12 @@ class Chef
326
330
  def warn_if_eol
327
331
  require_relative "version"
328
332
 
329
- # New Date format is YYYY-MM-DD or false
330
- new_date = eol_override
331
-
332
333
  # We make a release every year so take the version you're on + 2006 and you get
333
334
  # the year it goes EOL
334
335
  eol_year = 2006 + Gem::Version.new(Chef::VERSION).segments.first
335
- cut_off_date = !!new_date ? Time.parse(new_date) : Time.new(eol_year, 5, 01)
336
-
337
- return if Time.now < cut_off_date
338
-
339
- logger.warn("This release of #{ChefUtils::Dist::Infra::PRODUCT} became end of life (EOL) on #{cut_off_date.strftime("%b %d, %Y")}. Please update to a supported release to receive new features, bug fixes, and security updates.")
340
- end
341
336
 
342
- def eol_override
343
- # If you want to override the existing EOL date, add a file in the root of Chef
344
- # put a date in it in the form of YYYY-DD-MM.
345
- override_file = "EOL_override"
346
- if File.exist?(override_file)
347
- File.read(File.expand_path(override_file)).strip
348
- else
349
- false
337
+ if Time.now > Time.new(eol_year, 5, 01)
338
+ logger.warn("This release of #{ChefUtils::Dist::Infra::PRODUCT} became end of life (EOL) on May 1st #{eol_year}. Please update to a supported release to receive new features, bug fixes, and security updates.")
350
339
  end
351
340
  end
352
341
 
@@ -655,6 +644,16 @@ class Chef
655
644
  if !config[:client_key]
656
645
  events.skipping_registration(client_name, config)
657
646
  logger.trace("Client key is unspecified - skipping registration")
647
+ elsif ::Chef::Config[:migrate_key_to_keystore] == true && ChefUtils.windows?
648
+ cert_name = "chef-#{client_name}"
649
+ result = check_certstore_for_key(cert_name)
650
+ if result.rassoc("#{cert_name}")
651
+ logger.trace("Client key #{config[:client_key]} is present in Certificate Store - skipping registration")
652
+ else
653
+ create_new_key_and_register(cert_name)
654
+ logger.trace("New client keys created in the Certificate Store - skipping registration")
655
+ end
656
+ events.skipping_registration(client_name, config)
658
657
  elsif File.exists?(config[:client_key])
659
658
  events.skipping_registration(client_name, config)
660
659
  logger.trace("Client key #{config[:client_key]} is present - skipping registration")
@@ -673,6 +672,158 @@ class Chef
673
672
  raise
674
673
  end
675
674
 
675
+ # In the brave new world of No Certs On Disk, we want to put the pem file into Keychain or the Certstore
676
+ # But is it already there?
677
+ def check_certstore_for_key(cert_name)
678
+ require "win32-certstore"
679
+ win32certstore = ::Win32::Certstore.open("MY")
680
+ win32certstore.search("#{cert_name}")
681
+ end
682
+
683
+ def generate_pfx_package(cert_name, date)
684
+ self.class.generate_pfx_package(cert_name, date)
685
+ end
686
+
687
+ def self.generate_pfx_package(cert_name, date)
688
+ require "openssl" unless defined?(OpenSSL)
689
+
690
+ key = OpenSSL::PKey::RSA.new(2048)
691
+ public_key = key.public_key
692
+
693
+ subject = "CN=#{cert_name}"
694
+
695
+ cert = OpenSSL::X509::Certificate.new
696
+ cert.subject = cert.issuer = OpenSSL::X509::Name.parse(subject)
697
+ cert.not_before = Time.now
698
+ cert.not_after = Time.parse(date)
699
+ cert.public_key = public_key
700
+ cert.serial = 0x0
701
+ cert.version = 2
702
+
703
+ ef = OpenSSL::X509::ExtensionFactory.new
704
+ ef.subject_certificate = cert
705
+ ef.issuer_certificate = cert
706
+ cert.extensions = [
707
+ ef.create_extension("subjectKeyIdentifier", "hash"),
708
+ ef.create_extension("keyUsage", "digitalSignature,keyEncipherment", true),
709
+ ]
710
+ cert.add_extension(ef.create_ext_from_string("extendedKeyUsage=critical,serverAuth,clientAuth"))
711
+
712
+ cert.sign key, OpenSSL::Digest.new("SHA256")
713
+ password = ::Chef::HTTP::Authenticator.get_cert_password
714
+ pfx = OpenSSL::PKCS12.create(password, subject, key, cert)
715
+ pfx
716
+ end
717
+
718
+ def update_key_and_register(cert_name)
719
+ self.class.update_key_and_register(cert_name)
720
+ end
721
+
722
+ def self.update_key_and_register(cert_name, expiring_cert = nil)
723
+ # Chef client and node objects exist on Chef Server already
724
+ # Create a new public/private keypair in secure storage
725
+ # and register the new public cert with Chef Server
726
+ require "time" unless defined?(Time)
727
+ autoload :URI, "uri"
728
+
729
+ node = Chef::Config[:node_name]
730
+ end_date = Time.new + (3600 * 24 * 90)
731
+ end_date = end_date.utc.iso8601
732
+
733
+ new_cert_name = Time.now.utc.iso8601
734
+ payload = {
735
+ name: new_cert_name,
736
+ clientname: node,
737
+ public_key: "",
738
+ expiration_date: end_date,
739
+ }
740
+
741
+ new_pfx = generate_pfx_package(cert_name, end_date)
742
+ payload[:public_key] = new_pfx.certificate.public_key.to_pem
743
+ base_url = "#{Chef::Config[:chef_server_url]}"
744
+
745
+ @tmpdir = Dir.mktmpdir
746
+ file_path = File.join(@tmpdir, "#{node}.pem")
747
+
748
+ # The pfx files expire every 90 days.
749
+ # We check them in /http/authenticator to see if they are expiring when we extract the private key
750
+ # If they are, we come here to update Chef Server with a new public key
751
+ if expiring_cert
752
+ File.open(file_path, "w") { |f| f.write expiring_cert.key.to_pem }
753
+ signing_cert = file_path
754
+ client = Chef::ServerAPI.new(base_url, client_name: Chef::Config[:node_name], signing_key_filename: signing_cert )
755
+ File.delete(file_path)
756
+ else
757
+ client = Chef::ServerAPI.new(base_url, client_name: Chef::Config[:node_name], signing_key_filename: Chef::Config[:client_key] )
758
+ end
759
+
760
+ # Get the list of keys for this client
761
+ # Then add the new key we just created
762
+ # Then we delete the old one.
763
+ cert_list = client.get(base_url + "/clients/#{node}/keys")
764
+ client.post(base_url + "/clients/#{node}/keys", payload)
765
+
766
+ # We want to remove the old key for various reasons
767
+ # In the case where more than 1 certificate is returned we assume
768
+ # there is some special condition applied to the client so we won't delete the old
769
+ # certificates
770
+ if cert_list.count < 2
771
+ cert_hash = cert_list.reduce({}, :merge!)
772
+ old_cert_name = cert_hash["name"]
773
+ new_key = new_pfx.key.to_pem
774
+ File.open(file_path, "w") { |f| f.write new_key }
775
+ client = Chef::ServerAPI.new(base_url, client_name: Chef::Config[:node_name], signing_key_filename: file_path)
776
+ client.delete(base_url + "/clients/#{node}/keys/#{old_cert_name}")
777
+ File.delete(file_path)
778
+ end
779
+ import_pfx_to_store(new_pfx)
780
+ end
781
+
782
+ def create_new_key_and_register(cert_name)
783
+ require "time" unless defined?(Time)
784
+ autoload :URI, "uri"
785
+
786
+ # KeyMigration.instance.key_migrated = true
787
+
788
+ node = Chef::Config[:node_name]
789
+ d = Time.now
790
+ if d.month == 10 || d.month == 11 || d.month == 12
791
+ end_date = Time.new(d.year + 1, d.month - 9, d.day, d.hour, d.min, d.sec).utc.iso8601
792
+ else
793
+ end_date = Time.new(d.year, d.month + 3, d.day, d.hour, d.min, d.sec).utc.iso8601
794
+ end
795
+
796
+ payload = {
797
+ name: node,
798
+ clientname: node,
799
+ public_key: "",
800
+ expiration_date: end_date,
801
+ }
802
+
803
+ new_pfx = generate_pfx_package(cert_name, end_date)
804
+ payload[:public_key] = new_pfx.certificate.public_key.to_pem
805
+ base_url = "#{Chef::Config[:chef_server_url]}"
806
+ client = Chef::ServerAPI.new(base_url, client_name: Chef::Config[:validation_client_name], signing_key_filename: Chef::Config[:validation_key])
807
+ client.post(base_url + "/clients", payload)
808
+ Chef::Log.trace("Updated client data: #{client.inspect}")
809
+ import_pfx_to_store(new_pfx)
810
+ end
811
+
812
+ def import_pfx_to_store(new_pfx)
813
+ self.class.import_pfx_to_store(new_pfx)
814
+ end
815
+
816
+ def self.import_pfx_to_store(new_pfx)
817
+ password = ::Chef::HTTP::Authenticator.get_cert_password
818
+ require "win32-certstore"
819
+ tempfile = Tempfile.new("#{Chef::Config[:node_name]}.pfx")
820
+ File.open(tempfile, "wb") { |f| f.print new_pfx.to_der }
821
+
822
+ store = ::Win32::Certstore.open("MY")
823
+ store.add_pfx(tempfile, password, CRYPT_EXPORTABLE)
824
+ tempfile.unlink
825
+ end
826
+
676
827
  #
677
828
  # Converges all compiled resources.
678
829
  #
@@ -937,3 +1088,4 @@ end
937
1088
  require_relative "cookbook_loader"
938
1089
  require_relative "cookbook_version"
939
1090
  require_relative "cookbook/synchronizer"
1091
+
@@ -101,7 +101,7 @@ class Chef
101
101
  # and cookbook_name are required this is probably not externally useful.
102
102
  #
103
103
  def self.from_yaml(events, string, path = nil, cookbook_name = nil)
104
- from_hash(events, YAML.load(string), path, cookbook_name)
104
+ from_hash(events, YAML.safe_load(string, permitted_classes: [Date]), path, cookbook_name)
105
105
  end
106
106
 
107
107
  # @param filename [String] full path to the yml file in the cookbook
@@ -108,7 +108,7 @@ class Chef
108
108
  # and cookbook_name are required this is probably not externally useful.
109
109
  #
110
110
  def self.from_yaml(events, string, path, cookbook_name)
111
- from_hash(events, YAML.load(string), path, cookbook_name)
111
+ from_hash(events, YAML.safe_load(string, permitted_classes: [Date]), path, cookbook_name)
112
112
  end
113
113
 
114
114
  # @param filename [String] full path to the inspec.yml file in the cookbook
@@ -45,7 +45,6 @@ class Chef
45
45
  end
46
46
 
47
47
  # @return [Boolean] if any of the profiles are enabled
48
- #
49
48
  def using_profiles?
50
49
  any?(&:enabled?)
51
50
  end
@@ -101,7 +101,7 @@ class Chef
101
101
  # and cookbook_name are required this is probably not externally useful.
102
102
  #
103
103
  def self.from_yaml(events, string, path = nil, cookbook_name = nil)
104
- from_hash(events, YAML.load(string), path, cookbook_name)
104
+ from_hash(events, YAML.safe_load(string, permitted_classes: [Date]), path, cookbook_name)
105
105
  end
106
106
 
107
107
  # @param filename [String] full path to the yml file in the cookbook