chef 13.12.14-universal-mingw32 → 14.0.190-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (747) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +151 -0
  3. data/Gemfile +12 -9
  4. data/README.md +34 -32
  5. data/Rakefile +22 -18
  6. data/VERSION +1 -0
  7. data/acceptance/.shared/kitchen_acceptance/.kitchen.digitalocean.yml +33 -0
  8. data/acceptance/.shared/kitchen_acceptance/.kitchen.ec2.yml +272 -0
  9. data/acceptance/.shared/kitchen_acceptance/.kitchen.vagrant.yml +57 -0
  10. data/acceptance/.shared/kitchen_acceptance/libraries/kitchen.rb +68 -0
  11. data/acceptance/.shared/kitchen_acceptance/metadata.rb +1 -0
  12. data/acceptance/Gemfile +19 -0
  13. data/acceptance/Gemfile.lock +266 -0
  14. data/acceptance/README.md +137 -0
  15. data/acceptance/basics/.acceptance/acceptance-cookbook/.gitignore +2 -0
  16. data/acceptance/basics/.acceptance/acceptance-cookbook/metadata.rb +3 -0
  17. data/acceptance/basics/.acceptance/acceptance-cookbook/recipes/destroy.rb +1 -0
  18. data/acceptance/basics/.acceptance/acceptance-cookbook/recipes/provision.rb +1 -0
  19. data/acceptance/basics/.acceptance/acceptance-cookbook/recipes/verify.rb +1 -0
  20. data/acceptance/basics/.kitchen.yml +4 -0
  21. data/acceptance/basics/test/integration/chef-current-install/serverspec/chef_client_spec.rb +19 -0
  22. data/acceptance/basics/test/integration/chef-current-install/serverspec/spec_helper.rb +6 -0
  23. data/acceptance/basics/test/integration/helpers/serverspec/Gemfile +8 -0
  24. data/acceptance/data-collector/.acceptance/acceptance-cookbook/.gitignore +2 -0
  25. data/acceptance/data-collector/.acceptance/acceptance-cookbook/metadata.rb +3 -0
  26. data/acceptance/data-collector/.acceptance/acceptance-cookbook/recipes/destroy.rb +2 -0
  27. data/acceptance/data-collector/.acceptance/acceptance-cookbook/recipes/provision.rb +2 -0
  28. data/acceptance/data-collector/.acceptance/acceptance-cookbook/recipes/verify.rb +2 -0
  29. data/acceptance/data-collector/.acceptance/data-collector-test/.gitignore +16 -0
  30. data/acceptance/data-collector/.acceptance/data-collector-test/Berksfile +3 -0
  31. data/acceptance/data-collector/.acceptance/data-collector-test/files/default/api.rb +101 -0
  32. data/acceptance/data-collector/.acceptance/data-collector-test/files/default/apigemfile +3 -0
  33. data/acceptance/data-collector/.acceptance/data-collector-test/files/default/client-rb-both-mode.rb +4 -0
  34. data/acceptance/data-collector/.acceptance/data-collector-test/files/default/client-rb-client-mode.rb +4 -0
  35. data/acceptance/data-collector/.acceptance/data-collector-test/files/default/client-rb-no-endpoint.rb +2 -0
  36. data/acceptance/data-collector/.acceptance/data-collector-test/files/default/client-rb-solo-mode.rb +4 -0
  37. data/acceptance/data-collector/.acceptance/data-collector-test/files/default/config.ru +2 -0
  38. data/acceptance/data-collector/.acceptance/data-collector-test/metadata.rb +7 -0
  39. data/acceptance/data-collector/.acceptance/data-collector-test/recipes/default.rb +44 -0
  40. data/acceptance/data-collector/.kitchen.yml +9 -0
  41. data/acceptance/data-collector/Berksfile +3 -0
  42. data/acceptance/data-collector/test/integration/default/serverspec/default_spec.rb +208 -0
  43. data/acceptance/data-collector/test/integration/helpers/serverspec/Gemfile +8 -0
  44. data/acceptance/omnitruck/.acceptance/acceptance-cookbook/.gitignore +2 -0
  45. data/acceptance/omnitruck/.acceptance/acceptance-cookbook/metadata.rb +1 -0
  46. data/acceptance/omnitruck/.acceptance/acceptance-cookbook/recipes/destroy.rb +1 -0
  47. data/acceptance/omnitruck/.acceptance/acceptance-cookbook/recipes/provision.rb +1 -0
  48. data/acceptance/omnitruck/.acceptance/acceptance-cookbook/recipes/verify.rb +61 -0
  49. data/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/.gitignore +2 -0
  50. data/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/cookbook_kitchen.rb +43 -0
  51. data/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/top_cookbooks.rb +41 -0
  52. data/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/metadata.rb +3 -0
  53. data/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/recipes/destroy.rb +1 -0
  54. data/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/recipes/provision.rb +1 -0
  55. data/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/recipes/verify.rb +1 -0
  56. data/acceptance/top-cookbooks/.gitignore +1 -0
  57. data/acceptance/top-cookbooks/.kitchen.chocolatey.yml +6 -0
  58. data/acceptance/top-cookbooks/.kitchen.iis.yml +4 -0
  59. data/acceptance/top-cookbooks/.kitchen.learn-the-basics-rhel.yml +7 -0
  60. data/acceptance/top-cookbooks/.kitchen.learn-the-basics-ubuntu.yml +7 -0
  61. data/acceptance/top-cookbooks/.kitchen.learn-the-basics-windows.yml +7 -0
  62. data/acceptance/top-cookbooks/.kitchen.powershell.yml +4 -0
  63. data/acceptance/top-cookbooks/.kitchen.sql_server.yml +5 -0
  64. data/acceptance/top-cookbooks/.kitchen.winbox.yml +8 -0
  65. data/acceptance/top-cookbooks/.kitchen.windows.yml +38 -0
  66. data/acceptance/trivial/.acceptance/acceptance-cookbook/.gitignore +2 -0
  67. data/acceptance/trivial/.acceptance/acceptance-cookbook/metadata.rb +2 -0
  68. data/acceptance/trivial/.acceptance/acceptance-cookbook/recipes/destroy.rb +1 -0
  69. data/acceptance/trivial/.acceptance/acceptance-cookbook/recipes/provision.rb +1 -0
  70. data/acceptance/trivial/.acceptance/acceptance-cookbook/recipes/verify.rb +1 -0
  71. data/acceptance/trivial/.kitchen.yml +7 -0
  72. data/acceptance/trivial/test/integration/chef-current-install/inspec/chef_client_spec.rb +5 -0
  73. data/acceptance/windows-service/.acceptance/acceptance-cookbook/.gitignore +2 -0
  74. data/acceptance/windows-service/.acceptance/acceptance-cookbook/metadata.rb +2 -0
  75. data/acceptance/windows-service/.acceptance/acceptance-cookbook/recipes/destroy.rb +1 -0
  76. data/acceptance/windows-service/.acceptance/acceptance-cookbook/recipes/provision.rb +1 -0
  77. data/acceptance/windows-service/.acceptance/acceptance-cookbook/recipes/verify.rb +1 -0
  78. data/acceptance/windows-service/.kitchen.yml +7 -0
  79. data/acceptance/windows-service/test/integration/chef-windows-service/inspec/chef_windows_service_spec.rb +58 -0
  80. data/chef-universal-mingw32.gemspec +2 -2
  81. data/chef.gemspec +10 -10
  82. data/distro/powershell/chef/Chef.PowerShell.dll +0 -0
  83. data/distro/powershell/chef/Newtonsoft.Json.dll +0 -0
  84. data/lib/chef/api_client.rb +1 -1
  85. data/lib/chef/api_client/registration.rb +10 -2
  86. data/lib/chef/api_client_v1.rb +7 -6
  87. data/lib/chef/application.rb +75 -46
  88. data/lib/chef/application/client.rb +17 -19
  89. data/lib/chef/application/solo.rb +13 -16
  90. data/lib/chef/application/windows_service.rb +5 -5
  91. data/lib/chef/audit/audit_event_proxy.rb +1 -1
  92. data/lib/chef/audit/audit_reporter.rb +12 -12
  93. data/lib/chef/audit/runner.rb +2 -2
  94. data/lib/chef/chef_fs/chef_fs_data_store.rb +17 -31
  95. data/lib/chef/chef_fs/command_line.rb +9 -9
  96. data/lib/chef/chef_fs/data_handler/acl_data_handler.rb +1 -1
  97. data/lib/chef/chef_fs/data_handler/policy_data_handler.rb +1 -1
  98. data/lib/chef/chef_fs/data_handler/policy_group_data_handler.rb +1 -1
  99. data/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb +2 -2
  100. data/lib/chef/chef_fs/file_system/chef_server/policies_dir.rb +2 -2
  101. data/lib/chef/chef_fs/file_system/multiplexed_dir.rb +1 -1
  102. data/lib/chef/chef_fs/file_system/repository/base_file.rb +2 -2
  103. data/lib/chef/chef_fs/file_system_cache.rb +1 -1
  104. data/lib/chef/chef_fs/path_utils.rb +2 -2
  105. data/lib/chef/client.rb +61 -41
  106. data/lib/chef/config.rb +1 -2
  107. data/lib/chef/config_fetcher.rb +1 -1
  108. data/lib/chef/cookbook/chefignore.rb +2 -2
  109. data/lib/chef/cookbook/cookbook_collection.rb +2 -2
  110. data/lib/chef/cookbook/cookbook_version_loader.rb +0 -1
  111. data/lib/chef/cookbook/gem_installer.rb +4 -4
  112. data/lib/chef/cookbook/manifest_v2.rb +1 -1
  113. data/lib/chef/cookbook/metadata.rb +2 -3
  114. data/lib/chef/cookbook/remote_file_vendor.rb +4 -4
  115. data/lib/chef/cookbook/synchronizer.rb +2 -2
  116. data/lib/chef/cookbook/syntax_check.rb +4 -4
  117. data/lib/chef/cookbook_loader.rb +10 -2
  118. data/lib/chef/cookbook_site_streaming_uploader.rb +4 -4
  119. data/lib/chef/cookbook_uploader.rb +2 -3
  120. data/lib/chef/cookbook_version.rb +5 -11
  121. data/lib/chef/data_bag.rb +1 -3
  122. data/lib/chef/data_bag_item.rb +1 -7
  123. data/lib/chef/data_collector.rb +111 -35
  124. data/lib/chef/data_collector/messages.rb +2 -2
  125. data/lib/chef/data_collector/messages/helpers.rb +2 -4
  126. data/lib/chef/deprecated.rb +0 -4
  127. data/lib/chef/dsl/data_query.rb +1 -5
  128. data/lib/chef/dsl/include_attribute.rb +3 -7
  129. data/lib/chef/dsl/include_recipe.rb +1 -5
  130. data/lib/chef/dsl/platform_introspection.rb +9 -13
  131. data/lib/chef/dsl/reboot_pending.rb +1 -8
  132. data/lib/chef/dsl/recipe.rb +2 -12
  133. data/lib/chef/dsl/universal.rb +3 -3
  134. data/lib/chef/environment.rb +2 -4
  135. data/lib/chef/event_dispatch/dsl.rb +2 -2
  136. data/lib/chef/exceptions.rb +1 -1
  137. data/lib/chef/file_access_control/unix.rb +14 -14
  138. data/lib/chef/file_content_management/content_base.rb +3 -1
  139. data/lib/chef/file_content_management/deploy/cp.rb +2 -2
  140. data/lib/chef/file_content_management/deploy/mv_unix.rb +4 -4
  141. data/lib/chef/file_content_management/deploy/mv_windows.rb +1 -1
  142. data/lib/chef/file_content_management/tempfile.rb +1 -1
  143. data/lib/chef/formatters/error_inspectors/compile_error_inspector.rb +3 -3
  144. data/lib/chef/guard_interpreter/default_guard_interpreter.rb +3 -1
  145. data/lib/chef/guard_interpreter/resource_guard_interpreter.rb +2 -2
  146. data/lib/chef/handler.rb +1 -3
  147. data/lib/chef/handler/json_file.rb +1 -2
  148. data/lib/chef/http.rb +23 -11
  149. data/lib/chef/http/auth_credentials.rb +1 -1
  150. data/lib/chef/http/basic_client.rb +16 -17
  151. data/lib/chef/http/decompressor.rb +6 -6
  152. data/lib/chef/http/http_request.rb +5 -5
  153. data/lib/chef/http/json_output.rb +2 -2
  154. data/lib/chef/http/socketless_chef_zero_client.rb +2 -2
  155. data/lib/chef/http/validate_content_length.rb +5 -5
  156. data/lib/chef/knife.rb +1 -1
  157. data/lib/chef/knife/bootstrap.rb +12 -37
  158. data/lib/chef/knife/bootstrap/templates/chef-full.erb +7 -1
  159. data/lib/chef/knife/client_reregister.rb +1 -1
  160. data/lib/chef/knife/configure.rb +1 -3
  161. data/lib/chef/knife/cookbook_download.rb +2 -2
  162. data/lib/chef/knife/cookbook_metadata.rb +3 -3
  163. data/lib/chef/knife/cookbook_site_install.rb +2 -2
  164. data/lib/chef/knife/cookbook_site_share.rb +5 -5
  165. data/lib/chef/knife/cookbook_test.rb +2 -2
  166. data/lib/chef/knife/cookbook_upload.rb +2 -2
  167. data/lib/chef/knife/core/status_presenter.rb +22 -17
  168. data/lib/chef/knife/core/subcommand_loader.rb +1 -1
  169. data/lib/chef/knife/deps.rb +1 -1
  170. data/lib/chef/knife/environment_compare.rb +4 -4
  171. data/lib/chef/knife/exec.rb +3 -3
  172. data/lib/chef/knife/list.rb +1 -1
  173. data/lib/chef/knife/node_policy_set.rb +79 -0
  174. data/lib/chef/knife/osc_user_reregister.rb +1 -1
  175. data/lib/chef/knife/ssh.rb +35 -22
  176. data/lib/chef/knife/ssl_check.rb +3 -3
  177. data/lib/chef/knife/ssl_fetch.rb +1 -1
  178. data/lib/chef/knife/user_reregister.rb +1 -1
  179. data/lib/chef/knife/xargs.rb +1 -1
  180. data/lib/chef/mixin/api_version_request_handling.rb +2 -4
  181. data/lib/chef/mixin/create_path.rb +1 -1
  182. data/lib/chef/mixin/deprecation.rb +14 -14
  183. data/lib/chef/mixin/from_file.rb +5 -0
  184. data/lib/chef/mixin/get_source_from_package.rb +2 -2
  185. data/lib/chef/mixin/homebrew_user.rb +13 -2
  186. data/lib/chef/mixin/openssl_helper.rb +119 -0
  187. data/lib/chef/mixin/params_validate.rb +2 -8
  188. data/lib/chef/mixin/powershell_exec.rb +105 -0
  189. data/lib/chef/mixin/provides.rb +3 -2
  190. data/lib/chef/mixin/securable.rb +1 -5
  191. data/lib/chef/mixin/shell_out.rb +2 -2
  192. data/lib/chef/mixin/template.rb +1 -3
  193. data/lib/chef/mixin/user_context.rb +6 -3
  194. data/lib/chef/mixin/why_run.rb +6 -11
  195. data/lib/chef/monkey_patches/net_http.rb +7 -7
  196. data/lib/chef/monologger.rb +2 -86
  197. data/lib/chef/node.rb +30 -20
  198. data/lib/chef/node/attribute.rb +1 -6
  199. data/lib/chef/node/attribute_collections.rb +2 -2
  200. data/lib/chef/node/immutable_collections.rb +1 -1
  201. data/lib/chef/node/mixin/immutablize_array.rb +110 -3
  202. data/lib/chef/node/mixin/immutablize_hash.rb +111 -5
  203. data/lib/chef/node_map.rb +5 -23
  204. data/lib/chef/platform/query_helpers.rb +0 -12
  205. data/lib/chef/policy_builder/dynamic.rb +1 -1
  206. data/lib/chef/policy_builder/expand_node_object.rb +1 -1
  207. data/lib/chef/policy_builder/policyfile.rb +17 -1
  208. data/lib/chef/powershell.rb +55 -0
  209. data/lib/chef/property.rb +12 -34
  210. data/lib/chef/provider.rb +16 -39
  211. data/lib/chef/provider/apt_preference.rb +3 -3
  212. data/lib/chef/provider/apt_repository.rb +116 -34
  213. data/lib/chef/provider/batch.rb +1 -1
  214. data/lib/chef/provider/cookbook_file/content.rb +1 -1
  215. data/lib/chef/provider/cron.rb +10 -10
  216. data/lib/chef/provider/cron/unix.rb +3 -3
  217. data/lib/chef/provider/directory.rb +3 -3
  218. data/lib/chef/provider/dsc_resource.rb +4 -4
  219. data/lib/chef/provider/dsc_script.rb +4 -4
  220. data/lib/chef/provider/execute.rb +9 -5
  221. data/lib/chef/provider/file.rb +12 -12
  222. data/lib/chef/provider/git.rb +14 -14
  223. data/lib/chef/provider/group.rb +6 -6
  224. data/lib/chef/provider/group/aix.rb +1 -1
  225. data/lib/chef/provider/group/dscl.rb +4 -4
  226. data/lib/chef/provider/group/groupadd.rb +4 -4
  227. data/lib/chef/provider/group/groupmod.rb +3 -3
  228. data/lib/chef/provider/group/pw.rb +4 -4
  229. data/lib/chef/provider/group/windows.rb +2 -2
  230. data/lib/chef/provider/http_request.rb +12 -12
  231. data/lib/chef/provider/ifconfig.rb +6 -6
  232. data/lib/chef/provider/ifconfig/aix.rb +1 -1
  233. data/lib/chef/provider/ifconfig/debian.rb +3 -5
  234. data/lib/chef/provider/launchd.rb +1 -1
  235. data/lib/chef/provider/link.rb +6 -6
  236. data/lib/chef/provider/log.rb +1 -1
  237. data/lib/chef/provider/lwrp_base.rb +2 -2
  238. data/lib/chef/provider/mdadm.rb +10 -10
  239. data/lib/chef/provider/mount.rb +12 -12
  240. data/lib/chef/provider/mount/aix.rb +20 -21
  241. data/lib/chef/provider/mount/mount.rb +20 -15
  242. data/lib/chef/provider/mount/solaris.rb +6 -6
  243. data/lib/chef/provider/mount/windows.rb +7 -7
  244. data/lib/chef/provider/noop.rb +1 -1
  245. data/lib/chef/provider/ohai.rb +1 -1
  246. data/lib/chef/provider/osx_profile.rb +8 -8
  247. data/lib/chef/provider/package.rb +56 -42
  248. data/lib/chef/provider/package/apt.rb +24 -14
  249. data/lib/chef/provider/package/{aix.rb → bff.rb} +12 -12
  250. data/lib/chef/provider/package/cab.rb +3 -3
  251. data/lib/chef/provider/package/chocolatey.rb +1 -9
  252. data/lib/chef/provider/package/dnf/python_helper.rb +6 -6
  253. data/lib/chef/provider/package/dpkg.rb +9 -9
  254. data/lib/chef/provider/package/freebsd/base.rb +2 -2
  255. data/lib/chef/provider/package/freebsd/pkg.rb +2 -2
  256. data/lib/chef/provider/package/freebsd/pkgng.rb +1 -1
  257. data/lib/chef/provider/package/homebrew.rb +3 -3
  258. data/lib/chef/provider/package/ips.rb +2 -2
  259. data/lib/chef/provider/package/macports.rb +3 -3
  260. data/lib/chef/provider/package/msu.rb +2 -2
  261. data/lib/chef/provider/package/openbsd.rb +3 -3
  262. data/lib/chef/provider/package/pacman.rb +3 -3
  263. data/lib/chef/provider/package/paludis.rb +2 -2
  264. data/lib/chef/provider/package/portage.rb +27 -33
  265. data/lib/chef/provider/package/powershell.rb +24 -9
  266. data/lib/chef/provider/package/rpm.rb +5 -6
  267. data/lib/chef/provider/package/rubygems.rb +32 -28
  268. data/lib/chef/provider/package/smartos.rb +6 -6
  269. data/lib/chef/provider/package/solaris.rb +10 -10
  270. data/lib/chef/provider/package/windows.rb +6 -15
  271. data/lib/chef/provider/package/windows/exe.rb +6 -4
  272. data/lib/chef/provider/package/windows/msi.rb +8 -6
  273. data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +12 -6
  274. data/lib/chef/provider/package/yum.rb +167 -398
  275. data/lib/chef/provider/package/yum/python_helper.rb +221 -0
  276. data/lib/chef/provider/package/yum/rpm_utils.rb +10 -1
  277. data/lib/chef/provider/package/yum/simplejson/LICENSE.txt +79 -0
  278. data/lib/chef/provider/package/yum/simplejson/__init__.py +318 -0
  279. data/lib/chef/provider/package/yum/simplejson/__init__.pyc +0 -0
  280. data/lib/chef/provider/package/yum/simplejson/decoder.py +354 -0
  281. data/lib/chef/provider/package/yum/simplejson/decoder.pyc +0 -0
  282. data/lib/chef/provider/package/yum/simplejson/encoder.py +440 -0
  283. data/lib/chef/provider/package/yum/simplejson/encoder.pyc +0 -0
  284. data/lib/chef/provider/package/yum/simplejson/scanner.py +65 -0
  285. data/lib/chef/provider/package/yum/simplejson/scanner.pyc +0 -0
  286. data/lib/chef/provider/package/yum/simplejson/tool.py +37 -0
  287. data/lib/chef/provider/package/yum/version.rb +56 -0
  288. data/lib/chef/provider/package/yum/yum_cache.rb +33 -316
  289. data/lib/chef/provider/package/yum/yum_helper.py +198 -0
  290. data/lib/chef/provider/package/zypper.rb +9 -13
  291. data/lib/chef/provider/powershell_script.rb +3 -3
  292. data/lib/chef/provider/reboot.rb +3 -3
  293. data/lib/chef/provider/registry_key.rb +16 -4
  294. data/lib/chef/provider/remote_directory.rb +1 -3
  295. data/lib/chef/provider/remote_file/cache_control_data.rb +1 -1
  296. data/lib/chef/provider/remote_file/content.rb +4 -4
  297. data/lib/chef/provider/remote_file/http.rb +5 -3
  298. data/lib/chef/provider/remote_file/local_file.rb +1 -1
  299. data/lib/chef/provider/remote_file/network_file.rb +2 -2
  300. data/lib/chef/provider/route.rb +12 -11
  301. data/lib/chef/provider/ruby_block.rb +1 -1
  302. data/lib/chef/provider/script.rb +2 -2
  303. data/lib/chef/provider/service.rb +14 -14
  304. data/lib/chef/provider/service/aix.rb +3 -3
  305. data/lib/chef/provider/service/aixinit.rb +2 -2
  306. data/lib/chef/provider/service/debian.rb +5 -5
  307. data/lib/chef/provider/service/freebsd.rb +3 -3
  308. data/lib/chef/provider/service/gentoo.rb +2 -2
  309. data/lib/chef/provider/service/macosx.rb +8 -8
  310. data/lib/chef/provider/service/openbsd.rb +1 -1
  311. data/lib/chef/provider/service/simple.rb +7 -7
  312. data/lib/chef/provider/service/systemd.rb +4 -4
  313. data/lib/chef/provider/service/upstart.rb +10 -9
  314. data/lib/chef/provider/service/windows.rb +245 -70
  315. data/lib/chef/provider/subversion.rb +8 -8
  316. data/lib/chef/provider/systemd_unit.rb +25 -6
  317. data/lib/chef/provider/user.rb +10 -10
  318. data/lib/chef/provider/user/aix.rb +3 -3
  319. data/lib/chef/provider/user/dscl.rb +2 -2
  320. data/lib/chef/provider/user/pw.rb +4 -4
  321. data/lib/chef/provider/user/solaris.rb +1 -1
  322. data/lib/chef/provider/user/useradd.rb +3 -3
  323. data/lib/chef/provider/user/windows.rb +4 -4
  324. data/lib/chef/provider/whyrun_safe_ruby_block.rb +1 -1
  325. data/lib/chef/provider/{env.rb → windows_env.rb} +55 -19
  326. data/lib/chef/provider/windows_task.rb +27 -27
  327. data/lib/chef/provider/zypper_repository.rb +7 -7
  328. data/lib/chef/provider_resolver.rb +4 -4
  329. data/lib/chef/providers.rb +2 -9
  330. data/lib/chef/resource.rb +19 -13
  331. data/lib/chef/resource/action_class.rb +2 -2
  332. data/lib/chef/resource/apt_package.rb +10 -4
  333. data/lib/chef/resource/apt_preference.rb +20 -7
  334. data/lib/chef/resource/apt_repository.rb +21 -12
  335. data/lib/chef/resource/apt_update.rb +3 -3
  336. data/lib/chef/resource/bash.rb +6 -4
  337. data/lib/chef/resource/batch.rb +8 -6
  338. data/lib/chef/resource/bff_package.rb +8 -5
  339. data/lib/chef/resource/breakpoint.rb +9 -6
  340. data/lib/chef/resource/build_essential.rb +139 -0
  341. data/lib/chef/resource/cab_package.rb +5 -4
  342. data/lib/chef/resource/chef_gem.rb +1 -1
  343. data/lib/chef/resource/chef_handler.rb +130 -0
  344. data/lib/chef/resource/chocolatey_package.rb +6 -6
  345. data/lib/chef/resource/cookbook_file.rb +12 -9
  346. data/lib/chef/resource/cron.rb +14 -75
  347. data/lib/chef/resource/csh.rb +6 -4
  348. data/lib/chef/resource/directory.rb +7 -4
  349. data/lib/chef/resource/dmg_package.rb +161 -0
  350. data/lib/chef/resource/dnf_package.rb +10 -7
  351. data/lib/chef/resource/dpkg_package.rb +5 -3
  352. data/lib/chef/resource/dsc_resource.rb +11 -28
  353. data/lib/chef/resource/dsc_script.rb +14 -37
  354. data/lib/chef/resource/execute.rb +15 -78
  355. data/lib/chef/resource/file.rb +6 -5
  356. data/lib/chef/resource/file/verification.rb +5 -1
  357. data/lib/chef/resource/freebsd_package.rb +2 -1
  358. data/lib/chef/resource/gem_package.rb +6 -3
  359. data/lib/chef/resource/git.rb +4 -15
  360. data/lib/chef/resource/group.rb +7 -46
  361. data/lib/chef/resource/homebrew_cask.rb +98 -0
  362. data/lib/chef/resource/homebrew_package.rb +3 -3
  363. data/lib/chef/resource/homebrew_tap.rb +86 -0
  364. data/lib/chef/resource/hostname.rb +249 -0
  365. data/lib/chef/resource/http_request.rb +8 -22
  366. data/lib/chef/resource/ifconfig.rb +3 -2
  367. data/lib/chef/resource/ips_package.rb +4 -3
  368. data/lib/chef/resource/ksh.rb +7 -6
  369. data/lib/chef/resource/launchd.rb +4 -4
  370. data/lib/chef/resource/link.rb +18 -56
  371. data/lib/chef/resource/log.rb +6 -8
  372. data/lib/chef/resource/lwrp_base.rb +4 -5
  373. data/lib/chef/resource/macos_userdefaults.rb +133 -0
  374. data/lib/chef/resource/macosx_service.rb +7 -23
  375. data/lib/chef/resource/macports_package.rb +2 -1
  376. data/lib/chef/resource/mdadm.rb +13 -84
  377. data/lib/chef/resource/mount.rb +21 -127
  378. data/lib/chef/resource/msu_package.rb +4 -4
  379. data/lib/chef/resource/ohai.rb +5 -3
  380. data/lib/chef/resource/ohai_hint.rb +93 -0
  381. data/lib/chef/resource/openbsd_package.rb +3 -3
  382. data/lib/chef/resource/openssl_dhparam.rb +80 -0
  383. data/lib/chef/resource/openssl_rsa_private_key.rb +93 -0
  384. data/lib/chef/resource/openssl_rsa_public_key.rb +73 -0
  385. data/lib/chef/resource/osx_profile.rb +9 -10
  386. data/lib/chef/resource/package.rb +8 -6
  387. data/lib/chef/resource/pacman_package.rb +3 -2
  388. data/lib/chef/resource/paludis_package.rb +4 -4
  389. data/lib/chef/resource/perl.rb +6 -4
  390. data/lib/chef/resource/portage_package.rb +3 -6
  391. data/lib/chef/resource/powershell_package.rb +9 -13
  392. data/lib/chef/resource/powershell_script.rb +9 -8
  393. data/lib/chef/resource/python.rb +5 -4
  394. data/lib/chef/resource/reboot.rb +8 -9
  395. data/lib/chef/resource/registry_key.rb +9 -19
  396. data/lib/chef/resource/remote_directory.rb +5 -3
  397. data/lib/chef/resource/remote_file.rb +11 -50
  398. data/lib/chef/resource/resource_notification.rb +2 -2
  399. data/lib/chef/resource/rhsm_errata.rb +44 -0
  400. data/lib/chef/resource/rhsm_errata_level.rb +51 -0
  401. data/lib/chef/resource/rhsm_register.rb +162 -0
  402. data/lib/chef/resource/rhsm_repo.rb +62 -0
  403. data/lib/chef/resource/rhsm_subscription.rb +95 -0
  404. data/lib/chef/resource/route.rb +3 -1
  405. data/lib/chef/resource/rpm_package.rb +3 -3
  406. data/lib/chef/resource/ruby.rb +6 -4
  407. data/lib/chef/resource/ruby_block.rb +6 -17
  408. data/lib/chef/resource/scm.rb +14 -146
  409. data/lib/chef/resource/script.rb +7 -5
  410. data/lib/chef/resource/service.rb +2 -1
  411. data/lib/chef/resource/smartos_package.rb +4 -3
  412. data/lib/chef/resource/solaris_package.rb +3 -2
  413. data/lib/chef/resource/subversion.rb +20 -4
  414. data/lib/chef/resource/sudo.rb +231 -0
  415. data/lib/chef/resource/support/sudoer.erb +18 -0
  416. data/lib/chef/resource/swap_file.rb +209 -0
  417. data/lib/chef/resource/sysctl.rb +111 -0
  418. data/lib/chef/resource/systemd_unit.rb +6 -5
  419. data/lib/chef/resource/template.rb +6 -27
  420. data/lib/chef/resource/windows_ad_join.rb +92 -0
  421. data/lib/chef/resource/windows_auto_run.rb +87 -0
  422. data/lib/chef/resource/{env.rb → windows_env.rb} +11 -5
  423. data/lib/chef/resource/windows_feature.rb +95 -0
  424. data/lib/chef/resource/windows_feature_dism.rb +226 -0
  425. data/lib/chef/resource/windows_feature_powershell.rb +256 -0
  426. data/lib/chef/resource/windows_font.rb +127 -0
  427. data/lib/chef/resource/windows_package.rb +5 -3
  428. data/lib/chef/resource/windows_pagefile.rb +206 -0
  429. data/lib/chef/resource/windows_path.rb +3 -3
  430. data/lib/chef/resource/windows_printer.rb +148 -0
  431. data/lib/chef/resource/windows_printer_port.rb +136 -0
  432. data/lib/chef/resource/windows_service.rb +79 -38
  433. data/lib/chef/resource/windows_shortcut.rb +79 -0
  434. data/lib/chef/resource/windows_task.rb +5 -5
  435. data/lib/chef/resource/yum_package.rb +8 -2
  436. data/lib/chef/resource/yum_repository.rb +12 -5
  437. data/lib/chef/resource/zypper_package.rb +5 -3
  438. data/lib/chef/resource/zypper_repository.rb +17 -12
  439. data/lib/chef/resource_inspector.rb +89 -0
  440. data/lib/chef/resource_reporter.rb +5 -6
  441. data/lib/chef/resource_resolver.rb +4 -4
  442. data/lib/chef/resources.rb +31 -6
  443. data/lib/chef/role.rb +1 -3
  444. data/lib/chef/run_context.rb +21 -12
  445. data/lib/chef/run_context/cookbook_compiler.rb +18 -9
  446. data/lib/chef/search/query.rb +1 -2
  447. data/lib/chef/shell.rb +0 -1
  448. data/lib/chef/shell/model_wrapper.rb +1 -1
  449. data/lib/chef/shell/shell_session.rb +4 -3
  450. data/lib/chef/util/diff.rb +2 -2
  451. data/lib/chef/util/dsc/configuration_generator.rb +1 -1
  452. data/lib/chef/util/dsc/lcm_output_parser.rb +1 -1
  453. data/lib/chef/util/dsc/local_configuration_manager.rb +4 -4
  454. data/lib/chef/util/selinux.rb +1 -1
  455. data/lib/chef/util/windows/logon_session.rb +5 -2
  456. data/lib/chef/util/windows/net_user.rb +2 -2
  457. data/lib/chef/util/windows/volume.rb +0 -4
  458. data/lib/chef/version.rb +1 -1
  459. data/lib/chef/win32/api/error.rb +2 -2
  460. data/lib/chef/win32/api/net.rb +1 -1
  461. data/lib/chef/win32/api/security.rb +11 -0
  462. data/lib/chef/win32/eventlog.rb +2 -2
  463. data/lib/chef/win32/mutex.rb +1 -1
  464. data/lib/chef/win32/registry.rb +17 -17
  465. data/lib/chef/win32/security.rb +34 -12
  466. data/lib/chef/win32/security/sid.rb +1 -2
  467. data/lib/chef/win32/version.rb +2 -15
  468. data/lib/chef/win32_service_constants.rb +143 -0
  469. data/spec/data/mixin/invalid_data.rb +3 -0
  470. data/spec/data/mixin/real_data.rb +2 -0
  471. data/spec/functional/assets/yumrepo/chef_rpm-1.10-1.aarch64.rpm +0 -0
  472. data/spec/functional/assets/yumrepo/chef_rpm-1.10-1.i686.rpm +0 -0
  473. data/spec/functional/assets/yumrepo/chef_rpm-1.10-1.ppc64.rpm +0 -0
  474. data/spec/functional/assets/yumrepo/chef_rpm-1.10-1.ppc64le.rpm +0 -0
  475. data/spec/functional/assets/yumrepo/chef_rpm-1.10-1.s390x.rpm +0 -0
  476. data/spec/functional/assets/yumrepo/chef_rpm-1.10-1.src.rpm +0 -0
  477. data/spec/functional/assets/yumrepo/chef_rpm-1.10-1.x86_64.rpm +0 -0
  478. data/spec/functional/assets/yumrepo/chef_rpm-1.2-1.aarch64.rpm +0 -0
  479. data/spec/functional/assets/yumrepo/chef_rpm-1.2-1.i686.rpm +0 -0
  480. data/spec/functional/assets/yumrepo/chef_rpm-1.2-1.ppc64.rpm +0 -0
  481. data/spec/functional/assets/yumrepo/chef_rpm-1.2-1.ppc64le.rpm +0 -0
  482. data/spec/functional/assets/yumrepo/chef_rpm-1.2-1.s390x.rpm +0 -0
  483. data/spec/functional/assets/yumrepo/chef_rpm-1.2-1.src.rpm +0 -0
  484. data/spec/functional/assets/yumrepo/chef_rpm-1.2-1.x86_64.rpm +0 -0
  485. data/spec/functional/assets/yumrepo/repodata/4632d67cb92636e7575d911c24f0e04d3505a944e97c483abe0c3e73a7c62d33-filelists.sqlite.bz2 +0 -0
  486. data/spec/functional/assets/yumrepo/repodata/74599b793e54d877323837d2d81a1c3c594c44e4335f9528234bb490f7b9b439-other.xml.gz +0 -0
  487. data/spec/functional/assets/yumrepo/repodata/a845d418f919d2115ab95a56b2c76f6825ad0d0bede49181a55c04f58995d057-primary.sqlite.bz2 +0 -0
  488. data/spec/functional/assets/yumrepo/repodata/af9b7cf9ef23bd7b43068d74a460f3b5d06753d638e58e4a0c9edc35bfb9cdc4-other.sqlite.bz2 +0 -0
  489. data/spec/functional/assets/yumrepo/repodata/bdb4f5f1492a3b9532f22c43110a81500dd744f23da0aec5c33b2a41317c737d-filelists.xml.gz +0 -0
  490. data/spec/functional/assets/yumrepo/repodata/c10d1d34ce99e02f12ec96ef68360543ab1bb7c3cb81a4a2bf78df7d8597e9df-primary.xml.gz +0 -0
  491. data/spec/functional/assets/yumrepo/repodata/filelists.xml.gz +0 -0
  492. data/spec/functional/assets/yumrepo/repodata/other.xml.gz +0 -0
  493. data/spec/functional/assets/yumrepo/repodata/primary.xml.gz +0 -0
  494. data/spec/functional/assets/yumrepo/repodata/repomd.xml +19 -53
  495. data/spec/functional/event_loggers/windows_eventlog_spec.rb +2 -2
  496. data/spec/functional/http/simple_spec.rb +6 -6
  497. data/spec/functional/mixin/from_file_spec.rb +82 -0
  498. data/spec/functional/notifications_spec.rb +1 -1
  499. data/spec/functional/resource/{package_spec.rb → apt_package_spec.rb} +4 -4
  500. data/spec/functional/resource/dnf_package_spec.rb +115 -115
  501. data/spec/functional/resource/ifconfig_spec.rb +1 -2
  502. data/spec/functional/resource/link_spec.rb +9 -13
  503. data/spec/functional/resource/powershell_script_spec.rb +0 -2
  504. data/spec/functional/resource/registry_spec.rb +3 -3
  505. data/spec/functional/resource/remote_file_spec.rb +4 -4
  506. data/spec/functional/resource/user/windows_spec.rb +3 -1
  507. data/spec/functional/resource/windows_env_spec.rb +285 -0
  508. data/spec/functional/resource/windows_task_spec.rb +303 -2
  509. data/spec/functional/resource/yum_package_spec.rb +949 -0
  510. data/spec/functional/root_alias_spec.rb +1 -1
  511. data/spec/functional/win32/security_spec.rb +60 -7
  512. data/spec/functional/win32/versions_spec.rb +7 -9
  513. data/spec/integration/client/client_spec.rb +99 -7
  514. data/spec/integration/knife/chef_fs_data_store_spec.rb +23 -4
  515. data/spec/integration/recipes/recipe_dsl_spec.rb +26 -26
  516. data/spec/integration/recipes/resource_action_spec.rb +25 -120
  517. data/spec/spec_helper.rb +10 -2
  518. data/spec/support/lib/chef/resource/one_two_three_four.rb +0 -2
  519. data/spec/support/lib/chef/resource/zen_master.rb +1 -3
  520. data/spec/support/mock/constant.rb +1 -1
  521. data/spec/support/platform_helpers.rb +24 -7
  522. data/spec/support/shared/context/client.rb +13 -10
  523. data/spec/support/shared/examples/client.rb +50 -0
  524. data/spec/support/shared/functional/file_resource.rb +1 -1
  525. data/spec/support/shared/functional/securable_resource.rb +2 -2
  526. data/spec/support/shared/integration/knife_support.rb +5 -0
  527. data/spec/unit/application/client_spec.rb +39 -13
  528. data/spec/unit/application/solo_spec.rb +1 -8
  529. data/spec/unit/application_spec.rb +66 -2
  530. data/spec/unit/audit/audit_event_proxy_spec.rb +1 -1
  531. data/spec/unit/audit/audit_reporter_spec.rb +16 -16
  532. data/spec/unit/chef_fs/file_system_spec.rb +1 -1
  533. data/spec/unit/client_spec.rb +3 -4
  534. data/spec/unit/cookbook/metadata_spec.rb +1 -1
  535. data/spec/unit/cookbook_loader_spec.rb +6 -6
  536. data/spec/unit/cookbook_manifest_spec.rb +2 -2
  537. data/spec/unit/cookbook_version_file_specificity_spec.rb +5 -25
  538. data/spec/unit/data_collector/messages/helpers_spec.rb +9 -0
  539. data/spec/unit/data_collector/resource_report_spec.rb +3 -3
  540. data/spec/unit/data_collector_spec.rb +135 -1
  541. data/spec/unit/dsl/reboot_pending_spec.rb +0 -13
  542. data/spec/unit/dsl/recipe_spec.rb +0 -13
  543. data/spec/unit/environment_spec.rb +2 -2
  544. data/spec/unit/exceptions_spec.rb +1 -1
  545. data/spec/unit/http/validate_content_length_spec.rb +5 -5
  546. data/spec/unit/knife/bootstrap_spec.rb +11 -15
  547. data/spec/unit/knife/configure_spec.rb +1 -2
  548. data/spec/unit/knife/cookbook_test_spec.rb +2 -2
  549. data/spec/unit/knife/core/gem_glob_loader_spec.rb +2 -2
  550. data/spec/unit/knife/core/node_editor_spec.rb +6 -6
  551. data/spec/unit/knife/environment_compare_spec.rb +3 -3
  552. data/spec/unit/knife/node_edit_spec.rb +3 -1
  553. data/spec/unit/knife/node_policy_set_spec.rb +122 -0
  554. data/spec/unit/knife/osc_user_reregister_spec.rb +1 -1
  555. data/spec/unit/knife/osc_user_show_spec.rb +1 -1
  556. data/spec/unit/knife/ssh_spec.rb +18 -0
  557. data/spec/unit/log/syslog_spec.rb +2 -4
  558. data/spec/unit/log/winevt_spec.rb +2 -3
  559. data/spec/unit/lwrp_spec.rb +4 -4
  560. data/spec/unit/mixin/homebrew_user_spec.rb +1 -5
  561. data/spec/unit/mixin/openssl_helper_spec.rb +252 -0
  562. data/spec/unit/mixin/powershell_exec_spec.rb +43 -0
  563. data/spec/unit/node/attribute_spec.rb +3 -3
  564. data/spec/unit/node/immutable_collections_spec.rb +11 -1
  565. data/spec/unit/node_map_spec.rb +2 -2
  566. data/spec/unit/node_spec.rb +11 -16
  567. data/spec/unit/platform/query_helpers_spec.rb +0 -13
  568. data/spec/unit/policy_builder/policyfile_spec.rb +79 -2
  569. data/spec/unit/property/validation_spec.rb +51 -4
  570. data/spec/unit/provider/apt_repository_spec.rb +97 -32
  571. data/spec/unit/provider/cookbook_file_spec.rb +2 -1
  572. data/spec/unit/provider/cron/unix_spec.rb +8 -3
  573. data/spec/unit/provider/cron_spec.rb +27 -32
  574. data/spec/unit/provider/file_spec.rb +2 -1
  575. data/spec/unit/provider/group/dscl_spec.rb +7 -8
  576. data/spec/unit/provider/group/gpasswd_spec.rb +5 -2
  577. data/spec/unit/provider/group/groupmod_spec.rb +6 -3
  578. data/spec/unit/provider/group/pw_spec.rb +5 -2
  579. data/spec/unit/provider/link_spec.rb +6 -4
  580. data/spec/unit/provider/log_spec.rb +18 -13
  581. data/spec/unit/provider/mount/aix_spec.rb +1 -9
  582. data/spec/unit/provider/mount/mount_spec.rb +22 -0
  583. data/spec/unit/provider/osx_profile_spec.rb +3 -3
  584. data/spec/unit/provider/package/apt_spec.rb +431 -411
  585. data/spec/unit/provider/package/{aix_spec.rb → bff_spec.rb} +7 -5
  586. data/spec/unit/provider/package/chocolatey_spec.rb +0 -13
  587. data/spec/unit/provider/package/homebrew_spec.rb +2 -1
  588. data/spec/unit/provider/package/portage_spec.rb +11 -147
  589. data/spec/unit/provider/package/powershell_spec.rb +208 -57
  590. data/spec/unit/provider/package/rubygems_spec.rb +11 -2
  591. data/spec/unit/provider/package/windows_spec.rb +0 -19
  592. data/spec/unit/provider/package/yum/python_helper_spec.rb +29 -0
  593. data/spec/unit/provider/package/yum/yum_cache_spec.rb +86 -4
  594. data/spec/unit/provider/package/zypper_spec.rb +8 -0
  595. data/spec/unit/provider/package_spec.rb +47 -20
  596. data/spec/unit/provider/registry_key_spec.rb +7 -1
  597. data/spec/unit/provider/remote_directory_spec.rb +1 -1
  598. data/spec/unit/provider/remote_file_spec.rb +2 -1
  599. data/spec/unit/provider/service/macosx_spec.rb +4 -2
  600. data/spec/unit/provider/service/systemd_service_spec.rb +2 -10
  601. data/spec/unit/provider/service/windows_spec.rb +447 -30
  602. data/spec/unit/provider/systemd_unit_spec.rb +50 -13
  603. data/spec/unit/provider/template_spec.rb +2 -4
  604. data/spec/unit/provider/user/windows_spec.rb +3 -0
  605. data/spec/unit/provider/{env_spec.rb → windows_env_spec.rb} +102 -12
  606. data/spec/unit/provider/zypper_repository_spec.rb +4 -2
  607. data/spec/unit/provider_resolver_spec.rb +23 -38
  608. data/spec/unit/recipe_spec.rb +4 -4
  609. data/spec/unit/resource/apt_package_spec.rb +4 -0
  610. data/spec/unit/resource/apt_preference_spec.rb +0 -5
  611. data/spec/unit/resource/apt_repository_spec.rb +35 -10
  612. data/spec/unit/resource/apt_update_spec.rb +0 -5
  613. data/spec/unit/resource/bash_spec.rb +2 -3
  614. data/spec/unit/resource/batch_spec.rb +1 -4
  615. data/spec/unit/resource/{timestamped_deploy_spec.rb → build_essential_spec.rb} +10 -11
  616. data/spec/unit/resource/cab_package_spec.rb +1 -3
  617. data/{lib/chef/mixin/language_include_attribute.rb → spec/unit/resource/chef_handler_spec.rb} +13 -12
  618. data/spec/unit/resource/chocolatey_package_spec.rb +1 -3
  619. data/spec/unit/resource/cron_spec.rb +0 -5
  620. data/spec/unit/resource/csh_spec.rb +2 -3
  621. data/spec/unit/resource/directory_spec.rb +1 -6
  622. data/{lib/chef/resource/deploy_revision.rb → spec/unit/resource/dmg_package_spec.rb} +14 -10
  623. data/spec/unit/resource/dnf_package_spec.rb +20 -26
  624. data/spec/unit/resource/file_spec.rb +1 -1
  625. data/spec/unit/resource/freebsd_package_spec.rb +22 -23
  626. data/spec/unit/resource/gem_package_spec.rb +3 -5
  627. data/spec/unit/resource/git_spec.rb +1 -2
  628. data/spec/unit/resource/group_spec.rb +0 -5
  629. data/spec/unit/resource/homebrew_cask_spec.rb +35 -0
  630. data/spec/unit/resource/homebrew_package_spec.rb +4 -0
  631. data/spec/unit/resource/homebrew_tap_spec.rb +39 -0
  632. data/spec/unit/resource/hostname_spec.rb +43 -0
  633. data/spec/unit/resource/http_request_spec.rb +0 -5
  634. data/spec/unit/resource/ips_package_spec.rb +4 -0
  635. data/spec/unit/resource/ksh_spec.rb +2 -3
  636. data/spec/unit/resource/launchd_spec.rb +0 -5
  637. data/spec/unit/resource/link_spec.rb +1 -6
  638. data/spec/unit/resource/log_spec.rb +0 -5
  639. data/spec/unit/resource/macos_user_defaults_spec.rb +45 -0
  640. data/spec/unit/resource/mdadm_spec.rb +0 -5
  641. data/spec/unit/resource/mount_spec.rb +1 -6
  642. data/spec/unit/resource/msu_package_spec.rb +1 -3
  643. data/spec/unit/resource/ohai_hint_spec.rb +43 -0
  644. data/spec/unit/resource/ohai_spec.rb +0 -5
  645. data/spec/unit/resource/openbsd_package_spec.rb +8 -12
  646. data/spec/unit/resource/openssl_dhparam.rb +51 -0
  647. data/spec/unit/resource/openssl_rsa_private_key_spec.rb +59 -0
  648. data/spec/unit/resource/openssl_rsa_public_key_spec.rb +39 -0
  649. data/spec/unit/resource/osx_profile_spec.rb +0 -5
  650. data/spec/unit/resource/package_spec.rb +0 -5
  651. data/spec/unit/resource/perl_spec.rb +2 -3
  652. data/spec/unit/resource/portage_package_spec.rb +3 -7
  653. data/spec/unit/resource/powershell_package_spec.rb +11 -4
  654. data/spec/unit/resource/python_spec.rb +0 -5
  655. data/spec/unit/resource/reboot_spec.rb +0 -5
  656. data/spec/unit/resource/registry_key_spec.rb +5 -6
  657. data/spec/unit/resource/remote_directory_spec.rb +0 -5
  658. data/spec/unit/resource/remote_file_spec.rb +1 -5
  659. data/spec/unit/resource/rhsm_errata_level_spec.rb +46 -0
  660. data/{lib/chef/mixin/language_include_recipe.rb → spec/unit/resource/rhsm_errata_spec.rb} +14 -10
  661. data/spec/unit/resource/rhsm_register_spec.rb +199 -0
  662. data/spec/unit/resource/rhsm_repo_spec.rb +59 -0
  663. data/spec/unit/resource/rhsm_subscription_spec.rb +93 -0
  664. data/spec/unit/resource/route_spec.rb +1 -6
  665. data/spec/unit/resource/rpm_package_spec.rb +4 -0
  666. data/spec/unit/resource/ruby_block_spec.rb +0 -5
  667. data/spec/unit/resource/ruby_spec.rb +0 -5
  668. data/spec/unit/resource/scm_spec.rb +0 -15
  669. data/spec/unit/resource/service_spec.rb +0 -5
  670. data/spec/unit/resource/subversion_spec.rb +12 -0
  671. data/spec/unit/resource/sudo_spec.rb +92 -0
  672. data/spec/unit/resource/swap_file_spec.rb +40 -0
  673. data/spec/unit/resource/sysctl_spec.rb +56 -0
  674. data/spec/unit/resource/systemd_unit_spec.rb +5 -7
  675. data/spec/unit/resource/template_spec.rb +1 -3
  676. data/spec/unit/resource/user_spec.rb +0 -5
  677. data/spec/unit/resource/windows_ad_join.rb +45 -0
  678. data/spec/unit/resource/windows_auto_run_spec.rb +50 -0
  679. data/spec/unit/resource/{env_spec.rb → windows_env_spec.rb} +19 -21
  680. data/spec/unit/resource/windows_feature.rb +41 -0
  681. data/spec/unit/resource/windows_feature_dism.rb +51 -0
  682. data/spec/unit/resource/windows_feature_powershell.rb +51 -0
  683. data/spec/unit/resource/windows_font_spec.rb +44 -0
  684. data/spec/unit/resource/windows_package_spec.rb +2 -2
  685. data/spec/unit/resource/windows_pagefile_spec.rb +45 -0
  686. data/spec/unit/resource/windows_printer_port_spec.rb +45 -0
  687. data/spec/unit/resource/windows_printer_spec.rb +45 -0
  688. data/spec/unit/resource/windows_service_spec.rb +25 -4
  689. data/spec/unit/resource/windows_shortcut_spec.rb +39 -0
  690. data/spec/unit/resource/windows_task_spec.rb +0 -5
  691. data/spec/unit/resource/yum_repository_spec.rb +4 -0
  692. data/spec/unit/resource/zypper_repository_spec.rb +4 -0
  693. data/spec/unit/resource_inspector_spec.rb +60 -0
  694. data/spec/unit/resource_reporter_spec.rb +2 -2
  695. data/spec/unit/resource_spec.rb +0 -5
  696. data/spec/unit/shell/shell_session_spec.rb +0 -1
  697. data/spec/unit/user_spec.rb +1 -1
  698. data/spec/unit/util/windows/logon_session_spec.rb +2 -1
  699. data/spec/unit/win32/security_spec.rb +44 -1
  700. data/spec/unit/windows_service_spec.rb +4 -2
  701. data/tasks/announce.rb +1 -1
  702. data/tasks/cbgb.rb +84 -0
  703. data/tasks/dependencies.rb +38 -2
  704. data/tasks/maintainers.rb +7 -7
  705. data/tasks/rspec.rb +2 -2
  706. data/tasks/templates/prerelease.md.erb +2 -11
  707. data/tasks/templates/release.md.erb +1 -9
  708. metadata +225 -96
  709. data/lib/chef/knife/help.rb +0 -101
  710. data/lib/chef/knife/help_topics.rb +0 -4
  711. data/lib/chef/knife/index_rebuild.rb +0 -133
  712. data/lib/chef/mixin/language.rb +0 -48
  713. data/lib/chef/mixin/recipe_definition_dsl_core.rb +0 -35
  714. data/lib/chef/provider/deploy.rb +0 -470
  715. data/lib/chef/provider/deploy/revision.rb +0 -107
  716. data/lib/chef/provider/deploy/timestamped.rb +0 -34
  717. data/lib/chef/provider/env/windows.rb +0 -76
  718. data/lib/chef/provider/erl_call.rb +0 -76
  719. data/lib/chef/provider/package/yum/yum-dump.py +0 -307
  720. data/lib/chef/resource/deploy.rb +0 -449
  721. data/lib/chef/resource/erl_call.rb +0 -90
  722. data/lib/chef/resource/timestamped_deploy.rb +0 -26
  723. data/spec/functional/assets/yumrepo/chef_rpm-1.10-1.fc24.i686.rpm +0 -0
  724. data/spec/functional/assets/yumrepo/chef_rpm-1.10-1.fc24.src.rpm +0 -0
  725. data/spec/functional/assets/yumrepo/chef_rpm-1.10-1.fc24.x86_64.rpm +0 -0
  726. data/spec/functional/assets/yumrepo/chef_rpm-1.2-1.fc24.i686.rpm +0 -0
  727. data/spec/functional/assets/yumrepo/chef_rpm-1.2-1.fc24.src.rpm +0 -0
  728. data/spec/functional/assets/yumrepo/chef_rpm-1.2-1.fc24.x86_64.rpm +0 -0
  729. data/spec/functional/assets/yumrepo/repodata/313329137b55fd333b2dc66394a6661a2befa6cc535d8460d92a4a78a9c581f0-primary.sqlite.bz2 +0 -0
  730. data/spec/functional/assets/yumrepo/repodata/31ac4db5d5ac593728fcc26aef82b7b93c4cc4dbec843786b1845b939b658553-other.xml.gz +0 -0
  731. data/spec/functional/assets/yumrepo/repodata/4ac40fa3c6728c1401318e2e20a997436624e83dcf7a5f952b851ef422637773-filelists.sqlite.bz2 +0 -0
  732. data/spec/functional/assets/yumrepo/repodata/66391e53f0510b98b3f0b79f40ba1048026d9a1ef20905d9c40ba6f5411f3243-primary.xml.gz +0 -0
  733. data/spec/functional/assets/yumrepo/repodata/8b34697595fcc87928e12d24644dda9462c3857bd932861e28bc77ae1f31be16-filelists.xml.gz +0 -0
  734. data/spec/functional/assets/yumrepo/repodata/b97cca3fe14bcf06c52be4449b6108f7731239ff221111dcce8aada5467f60dc-other.sqlite.bz2 +0 -0
  735. data/spec/functional/resource/deploy_revision_spec.rb +0 -881
  736. data/spec/functional/resource/env_spec.rb +0 -192
  737. data/spec/unit/knife/index_rebuild_spec.rb +0 -125
  738. data/spec/unit/knife/knife_help.rb +0 -92
  739. data/spec/unit/provider/deploy/revision_spec.rb +0 -110
  740. data/spec/unit/provider/deploy/timestamped_spec.rb +0 -40
  741. data/spec/unit/provider/deploy_spec.rb +0 -641
  742. data/spec/unit/provider/env/windows_spec.rb +0 -103
  743. data/spec/unit/provider/erl_call_spec.rb +0 -77
  744. data/spec/unit/provider/package/yum_spec.rb +0 -2294
  745. data/spec/unit/resource/deploy_revision_spec.rb +0 -42
  746. data/spec/unit/resource/deploy_spec.rb +0 -283
  747. data/spec/unit/resource/erl_call_spec.rb +0 -81
@@ -28,7 +28,7 @@ class Chef
28
28
 
29
29
  provides :package, platform: "nexentacore"
30
30
  provides :package, platform: "solaris2", platform_version: "< 5.11"
31
- provides :solaris_package, os: "solaris2"
31
+ provides :solaris_package
32
32
 
33
33
  # def initialize(*args)
34
34
  # super
@@ -54,7 +54,7 @@ class Chef
54
54
  if new_resource.source
55
55
  @package_source_found = ::File.exist?(new_resource.source)
56
56
  if @package_source_found
57
- Chef::Log.debug("#{new_resource} checking pkg status")
57
+ logger.trace("#{new_resource} checking pkg status")
58
58
  shell_out_compact_timeout("pkginfo", "-l", "-d", new_resource.source, new_resource.package_name).stdout.each_line do |line|
59
59
  case line
60
60
  when /VERSION:\s+(.+)/
@@ -64,12 +64,12 @@ class Chef
64
64
  end
65
65
  end
66
66
 
67
- Chef::Log.debug("#{new_resource} checking install state")
67
+ logger.trace("#{new_resource} checking install state")
68
68
  status = shell_out_compact_timeout("pkginfo", "-l", current_resource.package_name)
69
69
  status.stdout.each_line do |line|
70
70
  case line
71
71
  when /VERSION:\s+(.+)/
72
- Chef::Log.debug("#{new_resource} version #{$1} is already installed")
72
+ logger.trace("#{new_resource} version #{$1} is already installed")
73
73
  current_resource.version($1)
74
74
  end
75
75
  end
@@ -89,7 +89,7 @@ class Chef
89
89
  when /VERSION:\s+(.+)/
90
90
  @candidate_version = $1
91
91
  new_resource.version($1)
92
- Chef::Log.debug("#{new_resource} setting install candidate version to #{@candidate_version}")
92
+ logger.trace("#{new_resource} setting install candidate version to #{@candidate_version}")
93
93
  end
94
94
  end
95
95
  unless status.exitstatus == 0
@@ -99,7 +99,7 @@ class Chef
99
99
  end
100
100
 
101
101
  def install_package(name, version)
102
- Chef::Log.debug("#{new_resource} package install options: #{options}")
102
+ logger.trace("#{new_resource} package install options: #{options}")
103
103
  if options.nil?
104
104
  command = if ::File.directory?(new_resource.source) # CHEF-4469
105
105
  [ "pkgadd", "-n", "-d", new_resource.source, new_resource.package_name ]
@@ -107,7 +107,7 @@ class Chef
107
107
  [ "pkgadd", "-n", "-d", new_resource.source, "all" ]
108
108
  end
109
109
  shell_out_compact_timeout!(command)
110
- Chef::Log.debug("#{new_resource} installed version #{new_resource.version} from: #{new_resource.source}")
110
+ logger.trace("#{new_resource} installed version #{new_resource.version} from: #{new_resource.source}")
111
111
  else
112
112
  command = if ::File.directory?(new_resource.source) # CHEF-4469
113
113
  [ "pkgadd", "-n", options, "-d", new_resource.source, new_resource.package_name ]
@@ -115,7 +115,7 @@ class Chef
115
115
  [ "pkgadd", "-n", options, "-d", new_resource.source, "all" ]
116
116
  end
117
117
  shell_out_compact_timeout!(*command)
118
- Chef::Log.debug("#{new_resource} installed version #{new_resource.version} from: #{new_resource.source}")
118
+ logger.trace("#{new_resource} installed version #{new_resource.version} from: #{new_resource.source}")
119
119
  end
120
120
  end
121
121
 
@@ -124,10 +124,10 @@ class Chef
124
124
  def remove_package(name, version)
125
125
  if options.nil?
126
126
  shell_out_compact_timeout!( "pkgrm", "-n", name )
127
- Chef::Log.debug("#{new_resource} removed version #{new_resource.version}")
127
+ logger.trace("#{new_resource} removed version #{new_resource.version}")
128
128
  else
129
129
  shell_out_compact_timeout!( "pkgrm", "-n", options, name )
130
- Chef::Log.debug("#{new_resource} removed version #{new_resource.version}")
130
+ logger.trace("#{new_resource} removed version #{new_resource.version}")
131
131
  end
132
132
  end
133
133
 
@@ -30,7 +30,7 @@ class Chef
30
30
  include Chef::Mixin::Checksum
31
31
 
32
32
  provides :package, os: "windows"
33
- provides :windows_package, os: "windows"
33
+ provides :windows_package
34
34
 
35
35
  require "chef/provider/package/windows/registry_uninstall_entry.rb"
36
36
 
@@ -39,21 +39,13 @@ class Chef
39
39
  a.assertion { new_resource.source || msi? }
40
40
  a.failure_message Chef::Exceptions::NoWindowsPackageSource, "Source for package #{new_resource.name} must be specified in the resource's source property for package to be installed because the package_name property is used to test for the package installation state for this package type."
41
41
  end
42
-
43
- unless uri_scheme?(new_resource.source)
44
- requirements.assert(:install) do |a|
45
- a.assertion { ::File.exist?(new_resource.source) }
46
- a.failure_message Chef::Exceptions::Package, "Source for package #{new_resource.name} does not exist"
47
- a.whyrun "Assuming source file #{new_resource.source} would have been created."
48
- end
49
- end
50
42
  end
51
43
 
52
44
  # load_current_resource is run in Chef::Provider#run_action when not in whyrun_mode?
53
45
  def load_current_resource
54
46
  @current_resource = Chef::Resource::WindowsPackage.new(new_resource.name)
55
47
  if downloadable_file_missing?
56
- Chef::Log.debug("We do not know the version of #{new_resource.source} because the file is not downloaded")
48
+ logger.trace("We do not know the version of #{new_resource.source} because the file is not downloaded")
57
49
  current_resource.version(:unknown.to_s)
58
50
  else
59
51
  current_resource.version(package_provider.installed_version)
@@ -67,11 +59,11 @@ class Chef
67
59
  @package_provider ||= begin
68
60
  case installer_type
69
61
  when :msi
70
- Chef::Log.debug("#{new_resource} is MSI")
62
+ logger.trace("#{new_resource} is MSI")
71
63
  require "chef/provider/package/windows/msi"
72
64
  Chef::Provider::Package::Windows::MSI.new(resource_for_provider, uninstall_registry_entries)
73
65
  else
74
- Chef::Log.debug("#{new_resource} is EXE with type '#{installer_type}'")
66
+ logger.trace("#{new_resource} is EXE with type '#{installer_type}'")
75
67
  require "chef/provider/package/windows/exe"
76
68
  Chef::Provider::Package::Windows::Exe.new(resource_for_provider, installer_type, uninstall_registry_entries)
77
69
  end
@@ -177,7 +169,7 @@ class Chef
177
169
  end
178
170
 
179
171
  def version_equals?(current_version, new_version)
180
- Chef::Log.debug("Checking if #{new_resource} version '#{new_version}' is already installed. #{current_version} is currently installed")
172
+ logger.trace("Checking if #{new_resource} version '#{new_version}' is already installed. #{current_version} is currently installed")
181
173
  if current_version.is_a?(Array)
182
174
  current_version.include?(new_version)
183
175
  else
@@ -229,13 +221,12 @@ class Chef
229
221
  r.timeout(new_resource.timeout)
230
222
  r.returns(new_resource.returns)
231
223
  r.options(new_resource.options)
232
- r.sensitive(new_resource.sensitive)
233
224
  end
234
225
  end
235
226
 
236
227
  def download_source_file
237
228
  source_resource.run_action(:create)
238
- Chef::Log.debug("#{new_resource} fetched source file to #{source_resource.path}")
229
+ logger.trace("#{new_resource} fetched source file to #{source_resource.path}")
239
230
  end
240
231
 
241
232
  def source_resource
@@ -28,11 +28,13 @@ class Chef
28
28
 
29
29
  def initialize(resource, installer_type, uninstall_entries)
30
30
  @new_resource = resource
31
+ @logger = new_resource.logger
31
32
  @installer_type = installer_type
32
33
  @uninstall_entries = uninstall_entries
33
34
  end
34
35
 
35
36
  attr_reader :new_resource
37
+ attr_reader :logger
36
38
  attr_reader :installer_type
37
39
  attr_reader :uninstall_entries
38
40
 
@@ -43,7 +45,7 @@ class Chef
43
45
 
44
46
  # Returns a version if the package is installed or nil if it is not.
45
47
  def installed_version
46
- Chef::Log.debug("#{new_resource} checking package version")
48
+ logger.trace("#{new_resource} checking package version")
47
49
  current_installed_version
48
50
  end
49
51
 
@@ -52,7 +54,7 @@ class Chef
52
54
  end
53
55
 
54
56
  def install_package
55
- Chef::Log.debug("#{new_resource} installing #{new_resource.installer_type} package '#{new_resource.source}'")
57
+ logger.trace("#{new_resource} installing #{new_resource.installer_type} package '#{new_resource.source}'")
56
58
  shell_out!(
57
59
  [
58
60
  "start",
@@ -62,7 +64,7 @@ class Chef
62
64
  unattended_flags,
63
65
  expand_options(new_resource.options),
64
66
  "& exit %%%%ERRORLEVEL%%%%",
65
- ].join(" "), timeout: new_resource.timeout, returns: new_resource.returns, sensitive: new_resource.sensitive
67
+ ].join(" "), timeout: new_resource.timeout, returns: new_resource.returns
66
68
  )
67
69
  end
68
70
 
@@ -70,7 +72,7 @@ class Chef
70
72
  uninstall_version = new_resource.version || current_installed_version
71
73
  uninstall_entries.select { |entry| [uninstall_version].flatten.include?(entry.display_version) }
72
74
  .map(&:uninstall_string).uniq.each do |uninstall_string|
73
- Chef::Log.debug("Registry provided uninstall string for #{new_resource} is '#{uninstall_string}'")
75
+ logger.trace("Registry provided uninstall string for #{new_resource} is '#{uninstall_string}'")
74
76
  shell_out!(uninstall_command(uninstall_string), timeout: new_resource.timeout, returns: new_resource.returns)
75
77
  end
76
78
  end
@@ -31,10 +31,12 @@ class Chef
31
31
 
32
32
  def initialize(resource, uninstall_entries)
33
33
  @new_resource = resource
34
+ @logger = new_resource.logger
34
35
  @uninstall_entries = uninstall_entries
35
36
  end
36
37
 
37
38
  attr_reader :new_resource
39
+ attr_reader :logger
38
40
  attr_reader :uninstall_entries
39
41
 
40
42
  # From Chef::Provider::Package
@@ -45,9 +47,9 @@ class Chef
45
47
  # Returns a version if the package is installed or nil if it is not.
46
48
  def installed_version
47
49
  if !new_resource.source.nil? && ::File.exist?(new_resource.source)
48
- Chef::Log.debug("#{new_resource} getting product code for package at #{new_resource.source}")
50
+ logger.trace("#{new_resource} getting product code for package at #{new_resource.source}")
49
51
  product_code = get_product_property(new_resource.source, "ProductCode")
50
- Chef::Log.debug("#{new_resource} checking package status and version for #{product_code}")
52
+ logger.trace("#{new_resource} checking package status and version for #{product_code}")
51
53
  get_installed_version(product_code)
52
54
  else
53
55
  if uninstall_entries.count != 0
@@ -59,21 +61,21 @@ class Chef
59
61
  def package_version
60
62
  return new_resource.version if new_resource.version
61
63
  if !new_resource.source.nil? && ::File.exist?(new_resource.source)
62
- Chef::Log.debug("#{new_resource} getting product version for package at #{new_resource.source}")
64
+ logger.trace("#{new_resource} getting product version for package at #{new_resource.source}")
63
65
  get_product_property(new_resource.source, "ProductVersion")
64
66
  end
65
67
  end
66
68
 
67
69
  def install_package
68
70
  # We could use MsiConfigureProduct here, but we'll start off with msiexec
69
- Chef::Log.debug("#{new_resource} installing MSI package '#{new_resource.source}'")
71
+ logger.trace("#{new_resource} installing MSI package '#{new_resource.source}'")
70
72
  shell_out!("msiexec /qn /i \"#{new_resource.source}\" #{expand_options(new_resource.options)}", timeout: new_resource.timeout, returns: new_resource.returns)
71
73
  end
72
74
 
73
75
  def remove_package
74
76
  # We could use MsiConfigureProduct here, but we'll start off with msiexec
75
77
  if !new_resource.source.nil? && ::File.exist?(new_resource.source)
76
- Chef::Log.debug("#{new_resource} removing MSI package '#{new_resource.source}'")
78
+ logger.trace("#{new_resource} removing MSI package '#{new_resource.source}'")
77
79
  shell_out!("msiexec /qn /x \"#{new_resource.source}\" #{expand_options(new_resource.options)}", timeout: new_resource.timeout, returns: new_resource.returns)
78
80
  else
79
81
  uninstall_version = new_resource.version || installed_version
@@ -82,7 +84,7 @@ class Chef
82
84
  uninstall_string = "msiexec /x #{uninstall_string.match(/{.*}/)}"
83
85
  uninstall_string += expand_options(new_resource.options)
84
86
  uninstall_string += " /q" unless uninstall_string.downcase =~ / \/q/
85
- Chef::Log.debug("#{new_resource} removing MSI package version using '#{uninstall_string}'")
87
+ logger.trace("#{new_resource} removing MSI package version using '#{uninstall_string}'")
86
88
  shell_out!(uninstall_string, timeout: new_resource.timeout, returns: new_resource.returns)
87
89
  end
88
90
  end
@@ -26,7 +26,7 @@ class Chef
26
26
  class RegistryUninstallEntry
27
27
 
28
28
  def self.find_entries(package_name)
29
- Chef::Log.debug("Finding uninstall entries for #{package_name}")
29
+ logger.trace("Finding uninstall entries for #{package_name}")
30
30
  entries = []
31
31
  [
32
32
  [::Win32::Registry::HKEY_LOCAL_MACHINE, (::Win32::Registry::Constants::KEY_READ | 0x0100)],
@@ -45,12 +45,12 @@ class Chef
45
45
  entries.push(quiet_uninstall_string_key?(quiet_uninstall_string, hkey, key, entry))
46
46
  end
47
47
  rescue ::Win32::Registry::Error => ex
48
- Chef::Log.debug("Registry error opening key '#{key}' on node #{desired}: #{ex}")
48
+ logger.trace("Registry error opening key '#{key}' on node #{desired}: #{ex}")
49
49
  end
50
50
  end
51
51
  end
52
52
  rescue ::Win32::Registry::Error => ex
53
- Chef::Log.debug("Registry error opening hive '#{hkey[0]}' :: #{desired}: #{ex}")
53
+ logger.trace("Registry error opening hive '#{hkey[0]}' :: #{desired}: #{ex}")
54
54
  end
55
55
  end
56
56
  entries
@@ -63,13 +63,18 @@ class Chef
63
63
 
64
64
  def self.read_registry_property(data, property)
65
65
  data[property]
66
- rescue ::Win32::Registry::Error => ex
67
- Chef::Log.debug("Failure to read property '#{property}'")
66
+ rescue ::Win32::Registry::Error
67
+ logger.trace("Failure to read property '#{property}'")
68
68
  nil
69
69
  end
70
70
 
71
+ def self.logger
72
+ Chef::Log
73
+ end
74
+
71
75
  def initialize(hive, key, registry_data, uninstall_key = "UninstallString")
72
- Chef::Log.debug("Creating uninstall entry for #{hive}::#{key}")
76
+ @logger = Chef::Log.with_child({ subsystem: "registry_uninstall_entry" })
77
+ logger.trace("Creating uninstall entry for #{hive}::#{key}")
73
78
  @hive = hive
74
79
  @key = key
75
80
  @data = registry_data
@@ -84,6 +89,7 @@ class Chef
84
89
  attr_reader :display_version
85
90
  attr_reader :uninstall_string
86
91
  attr_reader :data
92
+ attr_reader :logger
87
93
 
88
94
  UNINSTALL_SUBKEY = 'Software\Microsoft\Windows\CurrentVersion\Uninstall'.freeze
89
95
  end
@@ -1,6 +1,5 @@
1
-
2
- # Author:: Adam Jacob (<adam@chef.io>)
3
- # Copyright:: Copyright 2008-2017, Chef Software Inc.
1
+ #
2
+ # Copyright:: Copyright 2016-2018, Chef Software Inc.
4
3
  # License:: Apache License, Version 2.0
5
4
  #
6
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,487 +15,264 @@
16
15
  # limitations under the License.
17
16
  #
18
17
 
19
- require "chef/config"
20
18
  require "chef/provider/package"
21
19
  require "chef/resource/yum_package"
20
+ require "chef/mixin/which"
21
+ require "chef/mixin/shell_out"
22
22
  require "chef/mixin/get_source_from_package"
23
- require "chef/provider/package/yum/rpm_utils"
23
+ require "chef/provider/package/yum/python_helper"
24
+ require "chef/provider/package/yum/version"
25
+ # the stubs in the YumCache class are still an external API
24
26
  require "chef/provider/package/yum/yum_cache"
25
27
 
26
28
  class Chef
27
29
  class Provider
28
30
  class Package
29
31
  class Yum < Chef::Provider::Package
32
+ extend Chef::Mixin::Which
33
+ extend Chef::Mixin::ShellOut
30
34
  include Chef::Mixin::GetSourceFromPackage
31
35
 
32
- provides :package, platform_family: %w{rhel fedora amazon}
33
- provides :yum_package, os: "linux"
34
-
35
- # Multipackage API
36
36
  allow_nils
37
37
  use_multipackage_api
38
38
  use_package_name_for_source
39
39
 
40
- # Overload the Package provider to keep track of the YumCache
41
- def initialize(new_resource, run_context)
42
- super
40
+ provides :package, platform_family: %w{fedora amazon rhel}
41
+
42
+ provides :yum_package
43
43
 
44
- @yum = YumCache.instance
45
- @yum.yum_binary = yum_binary
44
+ #
45
+ # Most of the magic in this class happens in the python helper script. The ruby side of this
46
+ # provider knows only enough to translate Chef-style new_resource name+package+version into
47
+ # a request to the python side. The python side is then responsible for knowing everything
48
+ # about RPMs and what is installed and what is available. The ruby side of this class should
49
+ # remain a lightweight translation layer to translate Chef requests into RPC requests to
50
+ # python. This class knows nothing about how to compare RPM versions, and does not maintain
51
+ # any cached state of installed/available versions and should be kept that way.
52
+ #
53
+ def python_helper
54
+ @python_helper ||= PythonHelper.instance
46
55
  end
47
56
 
48
- # @see Chef::Provider::Package#check_resource_semantics!
49
- def check_resource_semantics!
50
- super
57
+ def load_current_resource
58
+ flushcache if new_resource.flush_cache[:before]
51
59
 
52
- if !new_resource.version.nil? && package_name_array.length != new_version_array.length
53
- raise Chef::Exceptions::InvalidResourceSpecification, "Please provide a version for each package. Use `nil` for default version."
54
- end
60
+ @current_resource = Chef::Resource::YumPackage.new(new_resource.name)
61
+ current_resource.package_name(new_resource.package_name)
62
+ current_resource.version(get_current_versions)
55
63
 
56
- if !new_resource.arch.nil? && package_name_array.length != safe_arch_array.length
57
- raise Chef::Exceptions::InvalidResourceSpecification, "Please provide an architecture for each package. Use `nil` for default architecture."
58
- end
64
+ current_resource
59
65
  end
60
66
 
61
- # @see Chef::Provider#define_resource_requirements
62
67
  def define_resource_requirements
63
- super
64
-
65
- # Ensure that the source file (if specified) is present on the file system
66
68
  requirements.assert(:install, :upgrade, :remove, :purge) do |a|
67
69
  a.assertion { !new_resource.source || ::File.exist?(new_resource.source) }
68
70
  a.failure_message Chef::Exceptions::Package, "Package #{new_resource.package_name} not found: #{new_resource.source}"
69
71
  a.whyrun "assuming #{new_resource.source} would have previously been created"
70
72
  end
71
- end
72
-
73
- # @see Chef::Provider#load_current_resource
74
- def load_current_resource
75
- @yum.reload if flush_cache[:before]
76
- manage_extra_repo_control
77
-
78
- if new_resource.source
79
- query_source_file
80
- else
81
- # At this point package_name could be:
82
- #
83
- # 1) a package name, eg: "foo"
84
- # 2) a package name.arch, eg: "foo.i386"
85
- # 3) or a dependency, eg: "foo >= 1.1"
86
- #
87
- # In the third case, we want to convert those dependency strings into
88
- # packages that we can actually install
89
- convert_dependency_strings_into_packages
90
-
91
- # Fill out the rest of the details by querying the Yum Cache
92
- query_yum_cache
93
- end
94
73
 
95
- @current_resource = Chef::Resource::YumPackage.new(new_resource.name)
96
- current_resource.package_name(new_resource.package_name)
97
- current_resource.version(@installed_version)
98
- current_resource
74
+ super
99
75
  end
100
76
 
101
- # @see Chef::Provider::Package#package_locked
102
- def package_locked(name, version)
103
- islocked = false
104
- locked = shell_out_with_timeout!("yum versionlock")
105
- locked.stdout.each_line do |line|
106
- line_package = line.sub(/-[^-]*-[^-]*$/, "").split(":").last.strip
107
- if line_package == name
108
- islocked = true
109
- end
77
+ def candidate_version
78
+ package_name_array.each_with_index.map do |pkg, i|
79
+ available_version(i).version_with_arch
110
80
  end
111
- islocked
112
81
  end
113
82
 
114
- #
115
- # Package Action Classes
116
- #
117
-
118
- # @see Chef::Provider::Package#install_package
119
- def install_package(name, version)
120
- if new_resource.source
121
- yum_command("-d0 -e0 -y#{expand_options(new_resource.options)} localinstall #{new_resource.source}")
122
- else
123
- install_remote_package(name, version)
83
+ def get_current_versions
84
+ package_name_array.each_with_index.map do |pkg, i|
85
+ installed_version(i).version_with_arch
124
86
  end
125
-
126
- flush_cache[:after] ? @yum.reload : @yum.reload_installed
127
87
  end
128
88
 
129
- # @see Chef::Provider::Package#upgrade_package
130
- def upgrade_package(name, version)
131
- install_package(name, version)
132
- end
89
+ def install_package(names, versions)
90
+ method = nil
91
+ methods = []
92
+ names.each_with_index do |n, i|
93
+ next if n.nil?
133
94
 
134
- # @see Chef::Provider::Package#remove_package
135
- def remove_package(name, version)
136
- remove_str = full_package_name(name, version).join(" ")
137
- yum_command("-d0 -e0 -y#{expand_options(new_resource.options)} remove #{remove_str}")
95
+ av = available_version(i)
138
96
 
139
- flush_cache[:after] ? @yum.reload : @yum.reload_installed
140
- end
97
+ name = av.name # resolve the name via the available/candidate version
141
98
 
142
- # @see Chef::Provider::Package#purge_package
143
- def purge_package(name, version)
144
- remove_package(name, version)
145
- end
99
+ iv = python_helper.package_query(:whatinstalled, name)
146
100
 
147
- # @see Chef::Provider::Package#lock_package
148
- def lock_package(name, version)
149
- lock_str = full_package_name(name, as_array(name).map { nil }).join(" ")
150
- yum_command("-d0 -e0 -y#{expand_options(new_resource.options)} versionlock add #{lock_str}")
151
- end
152
-
153
- # @see Chef::Provider::Package#unlock_package
154
- def unlock_package(name, version)
155
- unlock_str = full_package_name(name, as_array(name).map { nil }).join(" ")
156
- yum_command("-d0 -e0 -y#{expand_options(new_resource.options)} versionlock delete #{unlock_str}")
157
- end
158
-
159
- private
101
+ method = "install"
160
102
 
161
- #
162
- # System Level Yum Operations
163
- #
164
-
165
- def yum_binary
166
- @yum_binary ||=
167
- begin
168
- yum_binary = new_resource.yum_binary if new_resource.is_a?(Chef::Resource::YumPackage)
169
- yum_binary ||= ::File.exist?("/usr/bin/yum-deprecated") ? "yum-deprecated" : "yum"
103
+ # If this is a package like the kernel that can be installed multiple times, we'll skip over this logic
104
+ if new_resource.allow_downgrade && version_gt?(iv.version_with_arch, av.version_with_arch) && !python_helper.install_only_packages(name)
105
+ # We allow downgrading only in the evenit of single-package
106
+ # rules where the user explicitly allowed it
107
+ method = "downgrade"
170
108
  end
171
- end
172
109
 
173
- def version_compare(v1, v2)
174
- RPMVersion.parse(v1) <=> RPMVersion.parse(v2)
175
- end
110
+ methods << method
111
+ end
176
112
 
177
- # Enable or disable YumCache extra_repo_control
178
- def manage_extra_repo_control
179
- if new_resource.options
180
- repo_control = []
181
- new_resource.options.each do |opt|
182
- repo_control << opt if opt =~ /--(enable|disable)repo=.+/
183
- end
113
+ # We could split this up into two commands if we wanted to, but
114
+ # for now, just don't support this.
115
+ if methods.uniq.length > 1
116
+ raise Chef::Exceptions::Package, "Multipackage rule has a mix of upgrade and downgrade packages. Cannot proceed."
117
+ end
184
118
 
185
- if !repo_control.empty?
186
- @yum.enable_extra_repo_control(repo_control.join(" "))
187
- else
188
- @yum.disable_extra_repo_control
189
- end
119
+ if new_resource.source
120
+ yum(options, "-y #{method}", new_resource.source)
190
121
  else
191
- @yum.disable_extra_repo_control
122
+ resolved_names = names.each_with_index.map { |name, i| available_version(i).to_s unless name.nil? }
123
+ yum(options, "-y #{method}", resolved_names)
192
124
  end
125
+ flushcache
193
126
  end
194
127
 
195
- # Query the Yum cache for information about potential packages
196
- def query_yum_cache
197
- installed_versions = []
198
- candidate_versions = []
199
-
200
- package_name_array.each_with_index do |n, idx|
201
- pkg_name, eval_pkg_arch = parse_arch(n)
128
+ # yum upgrade does not work on uninstalled packaged, while install will upgrade
129
+ alias upgrade_package install_package
202
130
 
203
- # Defer to the arch property for the desired package architecture
204
- pkg_arch = safe_arch_array[idx] || eval_pkg_arch
205
- set_package_name(idx, pkg_name)
206
- set_package_arch(idx, pkg_arch)
131
+ def remove_package(names, versions)
132
+ resolved_names = names.each_with_index.map { |name, i| installed_version(i).to_s unless name.nil? }
133
+ yum(options, "-y remove", resolved_names)
134
+ flushcache
135
+ end
207
136
 
208
- Chef::Log.debug("#{new_resource} checking yum info for #{yum_syntax(n, nil, pkg_arch)}")
209
- installed_versions << iv = @yum.installed_version(pkg_name, pkg_arch)
210
- candidate_versions << cv = @yum.candidate_version(pkg_name, pkg_arch)
137
+ alias purge_package remove_package
211
138
 
212
- Chef::Log.debug("Found Yum package: #{pkg_name} installed version: #{iv || '(none)'} candidate version: #{cv || '(none)'}")
213
- end
139
+ action :flush_cache do
140
+ flushcache
141
+ end
214
142
 
215
- @installed_version = installed_versions.length > 1 ? installed_versions : installed_versions[0]
216
- @candidate_version = candidate_versions.length > 1 ? candidate_versions : candidate_versions[0]
143
+ # NB: the yum_package provider manages individual single packages, please do not submit issues or PRs to try to add wildcard
144
+ # support to lock / unlock. The best solution is to write an execute resource which does a not_if `yum versionlock | grep '^pattern`` kind of approach
145
+ def lock_package(names, versions)
146
+ yum("-d0 -e0 -y", options, "versionlock add", resolved_package_lock_names(names))
217
147
  end
218
148
 
219
- # Query the provided source file for the package name and version
220
- def query_source_file
221
- Chef::Log.debug("#{new_resource} checking rpm status")
222
- shell_out_with_timeout!("rpm -qp --queryformat '%{NAME} %{VERSION}-%{RELEASE} %{ARCH}\n' #{new_resource.source}", timeout: Chef::Config[:yum_timeout]).stdout.each_line do |line|
223
- case line
224
- when /^(\S+)\s(\S+)\s(\S+)$/
225
- n = $1
226
- v = $2
227
- a = $3
228
-
229
- unless new_resource.package_name == n
230
- Chef::Log.debug("#{new_resource} updating package_name from #{new_resource.package_name} to #{n} (per #{new_resource.source})")
231
- new_resource.package_name(n)
232
- end
149
+ # NB: the yum_package provider manages individual single packages, please do not submit issues or PRs to try to add wildcard
150
+ # support to lock / unlock. The best solution is to write an execute resource which does a only_if `yum versionlock | grep '^pattern`` kind of approach
151
+ def unlock_package(names, versions)
152
+ # yum versionlock delete on rhel6 needs the glob nonsense in the following command
153
+ yum("-d0 -e0 -y", options, "versionlock delete", resolved_package_lock_names(names).map { |n| "'*:#{n}-*'" })
154
+ end
233
155
 
234
- unless new_resource.version == v
235
- Chef::Log.debug("#{new_resource} updating version from #{new_resource.version} to #{v} (per #{new_resource.source})")
236
- new_resource.version(v)
237
- end
156
+ private
238
157
 
239
- unless new_resource.arch == a
240
- Chef::Log.debug("#{new_resource} updating architecture from #{new_resource.arch} to #{a} (per #{new_resource.source})")
241
- new_resource.arch(a)
158
+ # this will resolve things like `/usr/bin/perl` or virtual packages like `mysql` -- it will not work (well? at all?) with globs that match multiple packages
159
+ def resolved_package_lock_names(names)
160
+ names.each_with_index.map do |name, i|
161
+ if !name.nil?
162
+ if installed_version(i).version.nil?
163
+ available_version(i).name
164
+ else
165
+ installed_version(i).name
242
166
  end
243
167
  end
244
168
  end
245
-
246
- @installed_version = @yum.installed_version(new_resource.package_name, new_resource.arch)
247
- @candidate_version = new_resource.version
248
169
  end
249
170
 
250
- def yum_command(command)
251
- command = "#{yum_binary} #{command}"
252
- Chef::Log.debug("#{new_resource}: yum command: \"#{command}\"")
253
- status = shell_out_with_timeout(command, timeout: Chef::Config[:yum_timeout])
254
-
255
- # This is fun: rpm can encounter errors in the %post/%postun scripts which aren't
256
- # considered fatal - meaning the rpm is still successfully installed. These issue
257
- # cause yum to emit a non fatal warning but still exit(1). As there's currently no
258
- # way to suppress this behavior and an exit(1) will break a Chef run we make an
259
- # effort to trap these and re-run the same install command - it will either fail a
260
- # second time or succeed.
261
- #
262
- # A cleaner solution would have to be done in python and better hook into
263
- # yum/rpm to handle exceptions as we see fit.
264
- if status.exitstatus == 1
265
- status.stdout.each_line do |l|
266
- # rpm-4.4.2.3 lib/psm.c line 2182
267
- next unless l =~ /^error: %(post|postun)\(.*\) scriptlet failed, exit status \d+$/
268
- Chef::Log.warn("#{new_resource} caught non-fatal scriptlet issue: \"#{l}\". Can't trust yum exit status " \
269
- "so running install again to verify.")
270
- status = shell_out_with_timeout(command, timeout: Chef::Config[:yum_timeout])
271
- break
171
+ def locked_packages
172
+ @locked_packages ||=
173
+ begin
174
+ locked = shell_out_with_timeout!("yum versionlock list")
175
+ locked.stdout.each_line.map do |line|
176
+ line.sub(/-[^-]*-[^-]*$/, "").split(":").last.strip
177
+ end
272
178
  end
273
- end
274
-
275
- if status.exitstatus > 0
276
- command_output = "STDOUT: #{status.stdout}\nSTDERR: #{status.stderr}"
277
- raise Chef::Exceptions::Exec, "#{command} returned #{status.exitstatus}:\n#{command_output}"
278
- end
279
179
  end
280
180
 
281
- def install_remote_package(name, version)
282
- # Work around yum not exiting with an error if a package doesn't exist for CHEF-2062.
283
- all_avail = as_array(name).zip(as_array(version), safe_arch_array).any? do |n, v, a|
284
- @yum.version_available?(n, v, a)
285
- end
286
-
287
- method = log_method = nil
288
- methods = []
289
- if all_avail
290
- # More Yum fun:
291
- #
292
- # yum install of an old name+version will exit(1)
293
- # yum install of an old name+version+arch will exit(0) for some reason
294
- #
295
- # Some packages can be installed multiple times like the kernel
296
- as_array(name).zip(current_version_array, as_array(version), safe_arch_array).each do |n, cv, v, a|
297
- next if n.nil?
298
-
299
- method = "install"
300
- log_method = "installing"
301
-
302
- unless @yum.allow_multi_install.include?(n)
303
- if RPMVersion.parse(cv) > RPMVersion.parse(v)
304
- # We allow downgrading only in the evenit of single-package
305
- # rules where the user explicitly allowed it
306
- if allow_downgrade
307
- method = "downgrade"
308
- log_method = "downgrading"
309
- else
310
- # we bail like yum when the package is older
311
- raise Chef::Exceptions::Package, "Installed package #{yum_syntax(n, cv, a)} is newer " \
312
- "than candidate package #{yum_syntax(n, v, a)}"
313
- end
314
- end
315
- end
316
- # methods don't count for packages we won't be touching
317
- next if RPMVersion.parse(cv) == RPMVersion.parse(v)
318
- methods << method
319
- end
181
+ def packages_all_locked?(names, versions)
182
+ resolved_package_lock_names(names).all? { |n| locked_packages.include? n }
183
+ end
320
184
 
321
- # We could split this up into two commands if we wanted to, but
322
- # for now, just don't support this.
323
- if methods.uniq.length > 1
324
- raise Chef::Exceptions::Package, "Multipackage rule #{name} has a mix of upgrade and downgrade packages. Cannot proceed."
325
- end
185
+ def packages_all_unlocked?(names, versions)
186
+ !resolved_package_lock_names(names).any? { |n| locked_packages.include? n }
187
+ end
326
188
 
327
- repos = []
328
- pkg_string_bits = []
329
- as_array(name).zip(current_version_array, as_array(version), safe_arch_array).each do |n, cv, v, a|
330
- next if n.nil?
331
- next if v == cv
332
- s = yum_syntax(n, v, a)
333
- repo = @yum.package_repository(n, v, a)
334
- repos << "#{s} from #{repo} repository"
335
- pkg_string_bits << s
336
- end
337
- pkg_string = pkg_string_bits.join(" ")
338
- Chef::Log.info("#{new_resource} #{log_method} #{repos.join(' ')}")
339
- yum_command("-d0 -e0 -y#{expand_options(new_resource.options)} #{method} #{pkg_string}")
340
- else
341
- raise Chef::Exceptions::Package, "Version #{version} of #{name} not found. Did you specify both version " \
342
- "and release? (version-release, e.g. 1.84-10.fc6)"
343
- end
189
+ def version_gt?(v1, v2)
190
+ return false if v1.nil? || v2.nil?
191
+ python_helper.compare_versions(v1, v2) == 1
344
192
  end
345
193
 
346
- # Allow for foo.x86_64 style package_name like yum uses in it's output
347
- def parse_arch(package_name)
348
- if package_name =~ /^(.*)\.(.*)$/
349
- new_package_name = $1
350
- new_arch = $2
351
- # foo.i386 and foo.beta1 are both valid package names or expressions of an arch.
352
- # Ensure we don't have an existing package matching package_name, then ensure we at
353
- # least have a match for the new_package+new_arch before we overwrite. If neither
354
- # then fall through to standard package handling.
355
- old_installed = @yum.installed_version(package_name)
356
- old_candidate = @yum.candidate_version(package_name)
357
- new_installed = @yum.installed_version(new_package_name, new_arch)
358
- new_candidate = @yum.candidate_version(new_package_name, new_arch)
359
- if (old_installed.nil? && old_candidate.nil?) && (new_installed || new_candidate)
360
- Chef::Log.debug("Parsed out arch #{new_arch}, new package name is #{new_package_name}")
361
- return new_package_name, new_arch
362
- end
363
- end
364
- [package_name, nil]
194
+ def version_equals?(v1, v2)
195
+ return false if v1.nil? || v2.nil?
196
+ python_helper.compare_versions(v1, v2) == 0
365
197
  end
366
198
 
367
- #
368
- # Dependency String Handling
369
- #
199
+ def version_compare(v1, v2)
200
+ return false if v1.nil? || v2.nil?
201
+ python_helper.compare_versions(v1, v2)
202
+ end
370
203
 
371
- # Iterate through the list of package_names given to us by the user and
372
- # see if any of them are in the depenency format ("foo >= 1.1"). Modify
373
- # the list of packages and versions to incorporate those values.
374
- def convert_dependency_strings_into_packages
375
- package_name_array.each_with_index do |n, index|
376
- next if @yum.package_available?(n)
377
- # If they aren't in the installed packages they could be a dependency.
378
- dep = parse_dependency(n, new_version_array[index])
379
- if dep
380
- if new_resource.package_name.is_a?(Array)
381
- new_resource.package_name(package_name_array - [n] + [dep.first])
382
- new_resource.version(new_version_array - [new_version_array[index]] + [dep.last]) if dep.last
383
- else
384
- new_resource.package_name(dep.first)
385
- new_resource.version(dep.last) if dep.last
386
- end
387
- end
388
- end
204
+ # Generate the yum syntax for the package
205
+ def yum_syntax(name, version, arch)
206
+ s = name
207
+ s += "-#{version}" if version
208
+ s += ".#{arch}" if arch
209
+ s
389
210
  end
390
211
 
391
- # If we don't have the package we could have been passed a 'whatprovides' feature
392
- #
393
- # eg: yum install "perl(Config)"
394
- # yum install "mtr = 2:0.71-3.1"
395
- # yum install "mtr > 2:0.71"
396
- #
397
- # We support resolving these out of the Provides data imported from yum-dump.py and
398
- # matching them up with an actual package so the standard resource handling can apply.
399
- #
400
- # There is currently no support for filename matching.
401
- #
402
- # Note: This was largely left alone during the multipackage refactor
403
- def parse_dependency(name, version)
404
- # Transform the package_name into a requirement
405
-
406
- # If we are passed a version or a version constraint we have to assume it's a requirement first. If it can't be
407
- # parsed only yum_require.name will be set and new_resource.version will be left intact
408
- require_string = if version
409
- "#{name} #{version}"
410
- else
411
- # Transform the package_name into a requirement, might contain a version, could just be
412
- # a match for virtual provides
413
- name
414
- end
415
- yum_require = RPMRequire.parse(require_string)
416
- # and gather all the packages that have a Provides feature satisfying the requirement.
417
- # It could be multiple be we can only manage one
418
- packages = @yum.packages_from_require(yum_require)
419
-
420
- if packages.empty?
421
- # Don't bother if we are just ensuring a package is removed - we don't need Provides data
422
- actions = Array(new_resource.action)
423
- unless actions.size == 1 && (actions[0] == :remove || actions[0] == :purge)
424
- Chef::Log.debug("#{new_resource} couldn't match #{new_resource.package_name} in " \
425
- "installed Provides, loading available Provides - this may take a moment")
426
- @yum.reload_provides
427
- packages = @yum.packages_from_require(yum_require)
212
+ def resolve_source_to_version_obj
213
+ shell_out_with_timeout!("rpm -qp --queryformat '%{NAME} %{EPOCH} %{VERSION} %{RELEASE} %{ARCH}\n' #{new_resource.source}").stdout.each_line do |line|
214
+ # this is another case of committing the sin of doing some lightweight mangling of RPM versions in ruby -- but the output of the rpm command
215
+ # does not match what the yum library accepts.
216
+ case line
217
+ when /^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)$/
218
+ return Version.new($1, "#{$2 == '(none)' ? '0' : $2}:#{$3}-#{$4}", $5)
428
219
  end
429
220
  end
221
+ end
430
222
 
431
- unless packages.empty?
432
- new_package_name = packages.first.name
433
- new_package_version = packages.first.version.to_s
434
- debug_msg = "#{name}: Unable to match package '#{name}' but matched #{packages.size} "
435
- debug_msg << (packages.size == 1 ? "package" : "packages")
436
- debug_msg << ", selected '#{new_package_name}' version '#{new_package_version}'"
437
- Chef::Log.debug(debug_msg)
438
-
439
- # Ensure it's not the same package under a different architecture
440
- unique_names = []
441
- packages.each do |pkg|
442
- unique_names << "#{pkg.name}-#{pkg.version.evr}"
443
- end
444
- unique_names.uniq!
223
+ # @returns Array<Version>
224
+ def available_version(index)
225
+ @available_version ||= []
445
226
 
446
- if unique_names.size > 1
447
- Chef::Log.warn("#{new_resource} matched multiple Provides for #{new_resource.package_name} " \
448
- "but we can only use the first match: #{new_package_name}. Please use a more " \
449
- "specific version.")
450
- end
227
+ @available_version[index] ||= if new_resource.source
228
+ resolve_source_to_version_obj
229
+ else
230
+ python_helper.package_query(:whatavailable, package_name_array[index], version: safe_version_array[index], arch: safe_arch_array[index], options: options)
231
+ end
451
232
 
452
- if yum_require.version.to_s.nil?
453
- new_package_version = nil
454
- end
455
-
456
- [new_package_name, new_package_version]
457
- end
233
+ @available_version[index]
458
234
  end
459
235
 
460
- #
461
- # Misc Helpers
462
- #
236
+ # @returns Array<Version>
237
+ def installed_version(index)
238
+ @installed_version ||= []
239
+ @installed_version[index] ||= if new_resource.source
240
+ python_helper.package_query(:whatinstalled, available_version(index).name, version: safe_version_array[index], arch: safe_arch_array[index])
241
+ else
242
+ python_helper.package_query(:whatinstalled, package_name_array[index], version: safe_version_array[index], arch: safe_arch_array[index])
243
+ end
244
+ @installed_version[index]
245
+ end
463
246
 
464
- # Given an list of names and versions, generate the full yum syntax package name
465
- def full_package_name(name, version)
466
- as_array(name).zip(as_array(version), safe_arch_array).map do |n, v, a|
467
- yum_syntax(n, v, a)
468
- end
247
+ # cache flushing is accomplished by simply restarting the python helper. this produces a roughly
248
+ # 15% hit to the runtime of installing/removing/upgrading packages. correctly using multipackage
249
+ # array installs (and the multipackage cookbook) can produce 600% improvements in runtime.
250
+ def flushcache
251
+ python_helper.restart
469
252
  end
470
253
 
471
- # Generate the yum syntax for the package
472
- def yum_syntax(name, version, arch)
473
- s = name
474
- s += "-#{version}" if version
475
- s += ".#{arch}" if arch
476
- s
254
+ def yum_binary
255
+ @yum_binary ||=
256
+ begin
257
+ yum_binary = new_resource.yum_binary if new_resource.is_a?(Chef::Resource::YumPackage)
258
+ yum_binary ||= ::File.exist?("/usr/bin/yum-deprecated") ? "yum-deprecated" : "yum"
259
+ end
477
260
  end
478
261
 
479
- # Set the package name correctly based on whether it is a String or Array
480
- def set_package_name(idx, name)
481
- if new_resource.package_name.is_a?(String)
482
- new_resource.package_name(name)
483
- else
484
- new_resource.package_name[idx] = name
485
- end
262
+ def yum(*args)
263
+ shell_out_with_timeout!(a_to_s(yum_binary, *args))
486
264
  end
487
265
 
488
- # Set the architecture correcly based on whether it is a String or Array
489
- def set_package_arch(idx, arch)
490
- if new_resource.package_name.is_a?(String)
491
- new_resource.arch(arch) unless arch.nil?
266
+ def safe_version_array
267
+ if new_resource.version.is_a?(Array)
268
+ new_resource.version
269
+ elsif new_resource.version.nil?
270
+ package_name_array.map { nil }
492
271
  else
493
- new_resource.arch ||= []
494
- new_resource.arch[idx] = arch
272
+ [ new_resource.version ]
495
273
  end
496
274
  end
497
275
 
498
- # A cousin of package_name_array, return a list of the architectures
499
- # defined in the resource.
500
276
  def safe_arch_array
501
277
  if new_resource.arch.is_a?(Array)
502
278
  new_resource.arch
@@ -507,13 +283,6 @@ class Chef
507
283
  end
508
284
  end
509
285
 
510
- def flush_cache
511
- if new_resource.respond_to?("flush_cache")
512
- new_resource.flush_cache
513
- else
514
- { before: false, after: false }
515
- end
516
- end
517
286
  end
518
287
  end
519
288
  end