chef 12.13.37-universal-mingw32 → 12.14.60-universal-mingw32

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 (338) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +48 -95
  3. data/Gemfile +6 -1
  4. data/README.md +9 -11
  5. data/VERSION +1 -1
  6. data/acceptance/.shared/kitchen_acceptance/.kitchen.ec2.yml +0 -1
  7. data/acceptance/Gemfile +4 -7
  8. data/acceptance/Gemfile.lock +59 -92
  9. data/acceptance/basics/test/integration/helpers/serverspec/Gemfile +8 -0
  10. data/acceptance/data-collector/test/integration/helpers/serverspec/Gemfile +8 -0
  11. data/acceptance/fips/test/integration/fips-integration/serverspec/Gemfile +6 -0
  12. data/acceptance/fips/test/integration/fips-unit-functional/serverspec/Gemfile +4 -0
  13. data/chef.gemspec +3 -2
  14. data/lib/chef/application/client.rb +4 -4
  15. data/lib/chef/application/solo.rb +2 -2
  16. data/lib/chef/chef_fs/command_line.rb +36 -34
  17. data/lib/chef/chef_fs/data_handler/data_handler_base.rb +2 -2
  18. data/lib/chef/chef_fs/file_pattern.rb +1 -1
  19. data/lib/chef/chef_fs/file_system.rb +139 -137
  20. data/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb +2 -6
  21. data/lib/chef/cookbook/cookbook_version_loader.rb +27 -22
  22. data/lib/chef/cookbook/metadata.rb +1 -1
  23. data/lib/chef/cookbook/synchronizer.rb +3 -3
  24. data/lib/chef/cookbook_site_streaming_uploader.rb +3 -3
  25. data/lib/chef/cookbook_uploader.rb +1 -1
  26. data/lib/chef/cookbook_version.rb +6 -6
  27. data/lib/chef/dsl/powershell.rb +1 -1
  28. data/lib/chef/event_dispatch/base.rb +2 -2
  29. data/lib/chef/exceptions.rb +1 -1
  30. data/lib/chef/file_cache.rb +1 -1
  31. data/lib/chef/formatters/base.rb +2 -2
  32. data/lib/chef/formatters/doc.rb +2 -2
  33. data/lib/chef/http.rb +48 -18
  34. data/lib/chef/http/auth_credentials.rb +1 -1
  35. data/lib/chef/http/basic_client.rb +11 -2
  36. data/lib/chef/http/socketless_chef_zero_client.rb +2 -2
  37. data/lib/chef/key.rb +55 -56
  38. data/lib/chef/knife.rb +70 -61
  39. data/lib/chef/knife/client_delete.rb +2 -2
  40. data/lib/chef/knife/cookbook_bulk_delete.rb +1 -1
  41. data/lib/chef/knife/cookbook_show.rb +1 -1
  42. data/lib/chef/knife/core/gem_glob_loader.rb +3 -3
  43. data/lib/chef/knife/search.rb +2 -2
  44. data/lib/chef/knife/ssh.rb +19 -21
  45. data/lib/chef/knife/status.rb +2 -2
  46. data/lib/chef/mixin/command/unix.rb +2 -2
  47. data/lib/chef/mixin/powershell_type_coercions.rb +1 -1
  48. data/lib/chef/mixin/properties.rb +3 -0
  49. data/lib/chef/mixin/securable.rb +2 -2
  50. data/lib/chef/mixin/shell_out.rb +30 -0
  51. data/lib/chef/mixin/uris.rb +2 -1
  52. data/lib/chef/mixin/windows_architecture_helper.rb +3 -4
  53. data/lib/chef/monkey_patches/webrick-utils.rb +2 -2
  54. data/lib/chef/monologger.rb +1 -1
  55. data/lib/chef/node.rb +2 -2
  56. data/lib/chef/node/attribute.rb +3 -3
  57. data/lib/chef/platform/provider_mapping.rb +5 -2
  58. data/lib/chef/property.rb +14 -3
  59. data/lib/chef/provider/apt_repository.rb +3 -7
  60. data/lib/chef/provider/apt_update.rb +4 -6
  61. data/lib/chef/provider/cron.rb +1 -2
  62. data/lib/chef/provider/dsc_script.rb +4 -4
  63. data/lib/chef/provider/group/usermod.rb +1 -1
  64. data/lib/chef/provider/link.rb +10 -3
  65. data/lib/chef/provider/osx_profile.rb +10 -10
  66. data/lib/chef/provider/package.rb +2 -12
  67. data/lib/chef/provider/package/rubygems.rb +17 -16
  68. data/lib/chef/provider/package/windows.rb +2 -0
  69. data/lib/chef/provider/package/windows/exe.rb +1 -1
  70. data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +0 -2
  71. data/lib/chef/provider/package/yum/rpm_utils.rb +8 -8
  72. data/lib/chef/provider/package/yum/yum_cache.rb +1 -1
  73. data/lib/chef/provider/remote_file/ftp.rb +2 -2
  74. data/lib/chef/provider/remote_file/sftp.rb +2 -2
  75. data/lib/chef/provider/service/debian.rb +2 -2
  76. data/lib/chef/provider/service/simple.rb +4 -3
  77. data/lib/chef/provider/service/solaris.rb +1 -1
  78. data/lib/chef/provider/service/systemd.rb +2 -2
  79. data/lib/chef/provider/service/upstart.rb +8 -5
  80. data/lib/chef/provider/support/yum_repo.erb +125 -0
  81. data/lib/chef/provider/systemd_unit.rb +11 -2
  82. data/lib/chef/provider/template_finder.rb +1 -1
  83. data/lib/chef/provider/user.rb +20 -16
  84. data/lib/chef/provider/user/aix.rb +5 -2
  85. data/lib/chef/provider/user/dscl.rb +1 -0
  86. data/lib/chef/provider/user/linux.rb +128 -0
  87. data/lib/chef/provider/user/pw.rb +2 -1
  88. data/lib/chef/provider/user/solaris.rb +3 -2
  89. data/lib/chef/provider/user/useradd.rb +5 -4
  90. data/lib/chef/provider/user/windows.rb +1 -1
  91. data/lib/chef/provider/windows_script.rb +5 -2
  92. data/lib/chef/provider/yum_repository.rb +121 -0
  93. data/lib/chef/providers.rb +4 -2
  94. data/lib/chef/resource.rb +7 -9
  95. data/lib/chef/resource/conditional.rb +9 -1
  96. data/lib/chef/resource/launchd.rb +1 -1
  97. data/lib/chef/resource/user.rb +3 -3
  98. data/lib/chef/resource/user/aix_user.rb +31 -0
  99. data/lib/chef/resource/user/dscl_user.rb +31 -0
  100. data/lib/chef/resource/user/linux_user.rb +51 -0
  101. data/lib/chef/resource/user/pw_user.rb +31 -0
  102. data/lib/chef/resource/user/solaris_user.rb +31 -0
  103. data/lib/chef/resource/user/windows_user.rb +31 -0
  104. data/lib/chef/resource/yum_package.rb +13 -12
  105. data/lib/chef/resource/yum_repository.rb +76 -0
  106. data/lib/chef/resource_builder.rb +1 -1
  107. data/lib/chef/resource_collection/stepable_iterator.rb +1 -3
  108. data/lib/chef/resource_reporter.rb +5 -5
  109. data/lib/chef/resources.rb +7 -0
  110. data/lib/chef/run_context.rb +5 -3
  111. data/lib/chef/run_context/cookbook_compiler.rb +3 -2
  112. data/lib/chef/run_list.rb +2 -2
  113. data/lib/chef/search/query.rb +11 -8
  114. data/lib/chef/shell/ext.rb +2 -2
  115. data/lib/chef/shell/shell_session.rb +1 -1
  116. data/lib/chef/util/dsc/configuration_generator.rb +1 -1
  117. data/lib/chef/util/powershell/cmdlet.rb +5 -2
  118. data/lib/chef/util/selinux.rb +1 -1
  119. data/lib/chef/version.rb +1 -1
  120. data/lib/chef/version_class.rb +2 -2
  121. data/lib/chef/version_constraint.rb +2 -2
  122. data/lib/chef/win32/api/error.rb +2 -2
  123. data/lib/chef/win32/api/net.rb +1 -1
  124. data/lib/chef/win32/eventlog.rb +1 -1
  125. data/lib/chef/win32/net.rb +1 -1
  126. data/lib/chef/win32/security/sid.rb +1 -1
  127. data/spec/functional/assets/testchefsubsys +2 -3
  128. data/spec/functional/event_loggers/windows_eventlog_spec.rb +11 -8
  129. data/spec/functional/file_content_management/deploy_strategies_spec.rb +1 -1
  130. data/spec/functional/http/simple_spec.rb +2 -2
  131. data/spec/functional/knife/cookbook_delete_spec.rb +5 -5
  132. data/spec/functional/knife/exec_spec.rb +6 -6
  133. data/spec/functional/knife/ssh_spec.rb +4 -4
  134. data/spec/functional/notifications_spec.rb +2 -2
  135. data/spec/functional/provider/whyrun_safe_ruby_block_spec.rb +2 -2
  136. data/spec/functional/rebooter_spec.rb +5 -5
  137. data/spec/functional/resource/bash_spec.rb +2 -2
  138. data/spec/functional/resource/deploy_revision_spec.rb +1 -1
  139. data/spec/functional/resource/dpkg_package_spec.rb +2 -2
  140. data/spec/functional/resource/dsc_resource_spec.rb +5 -5
  141. data/spec/functional/resource/dsc_script_spec.rb +27 -22
  142. data/spec/functional/resource/env_spec.rb +4 -4
  143. data/spec/functional/resource/execute_spec.rb +4 -4
  144. data/spec/functional/resource/group_spec.rb +20 -8
  145. data/spec/functional/resource/link_spec.rb +34 -0
  146. data/spec/functional/resource/ohai_spec.rb +6 -6
  147. data/spec/functional/resource/reboot_spec.rb +2 -2
  148. data/spec/functional/resource/remote_file_spec.rb +16 -7
  149. data/spec/functional/resource/user/dscl_spec.rb +3 -3
  150. data/spec/functional/resource/user/useradd_spec.rb +32 -26
  151. data/spec/functional/resource/windows_service_spec.rb +15 -15
  152. data/spec/functional/rest_spec.rb +2 -2
  153. data/spec/functional/run_lock_spec.rb +9 -9
  154. data/spec/functional/tiny_server_spec.rb +9 -8
  155. data/spec/functional/win32/crypto_spec.rb +1 -1
  156. data/spec/functional/win32/security_spec.rb +8 -8
  157. data/spec/integration/client/client_spec.rb +6 -4
  158. data/spec/integration/knife/chef_repo_path_spec.rb +70 -1
  159. data/spec/integration/knife/upload_spec.rb +1 -1
  160. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +6 -6
  161. data/spec/integration/recipes/noop_resource_spec.rb +4 -4
  162. data/spec/integration/recipes/provider_choice.rb +3 -3
  163. data/spec/integration/recipes/recipe_dsl_spec.rb +318 -317
  164. data/spec/integration/recipes/resource_action_spec.rb +50 -54
  165. data/spec/integration/recipes/resource_converge_if_changed_spec.rb +34 -34
  166. data/spec/integration/recipes/resource_load_spec.rb +24 -24
  167. data/spec/integration/solo/solo_spec.rb +21 -30
  168. data/spec/scripts/ssl-serve.rb +1 -1
  169. data/spec/spec_helper.rb +1 -0
  170. data/spec/stress/win32/security_spec.rb +4 -4
  171. data/spec/support/chef_helpers.rb +22 -0
  172. data/spec/support/platform_helpers.rb +5 -1
  173. data/spec/support/shared/context/client.rb +3 -2
  174. data/spec/support/shared/functional/file_resource.rb +5 -4
  175. data/spec/support/shared/functional/http.rb +16 -16
  176. data/spec/support/shared/functional/securable_resource.rb +5 -5
  177. data/spec/support/shared/functional/win32_service.rb +5 -7
  178. data/spec/support/shared/integration/app_server_support.rb +1 -3
  179. data/spec/support/shared/integration/knife_support.rb +0 -2
  180. data/spec/support/shared/shared_examples.rb +2 -2
  181. data/spec/support/shared/unit/api_versioning.rb +2 -2
  182. data/spec/support/shared/unit/application_dot_d.rb +9 -6
  183. data/spec/support/shared/unit/provider/file.rb +2 -2
  184. data/spec/support/shared/unit/provider/useradd_based_user_provider.rb +49 -80
  185. data/spec/support/shared/unit/resource/static_provider_resolution.rb +2 -2
  186. data/spec/support/shared/unit/script_resource.rb +4 -4
  187. data/spec/support/shared/unit/user_and_client_shared.rb +4 -4
  188. data/spec/tiny_server.rb +51 -66
  189. data/spec/unit/api_client_v1_spec.rb +2 -2
  190. data/spec/unit/application_spec.rb +1 -1
  191. data/spec/unit/audit/audit_event_proxy_spec.rb +34 -27
  192. data/spec/unit/audit/audit_reporter_spec.rb +32 -23
  193. data/spec/unit/audit/control_group_data_spec.rb +19 -14
  194. data/spec/unit/chef_class_spec.rb +1 -1
  195. data/spec/unit/chef_fs/data_handler/group_handler_spec.rb +1 -1
  196. data/spec/unit/chef_fs/diff_spec.rb +4 -4
  197. data/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb +4 -4
  198. data/spec/unit/chef_fs/file_system_spec.rb +2 -2
  199. data/spec/unit/chef_fs/parallelizer.rb +5 -7
  200. data/spec/unit/cookbook/metadata_spec.rb +98 -98
  201. data/spec/unit/cookbook/synchronizer_spec.rb +7 -0
  202. data/spec/unit/cookbook_loader_spec.rb +24 -24
  203. data/spec/unit/cookbook_version_file_specificity_spec.rb +8 -8
  204. data/spec/unit/daemon_spec.rb +1 -1
  205. data/spec/unit/data_bag_item_spec.rb +18 -18
  206. data/spec/unit/data_bag_spec.rb +2 -2
  207. data/spec/unit/data_collector/messages/helpers_spec.rb +9 -9
  208. data/spec/unit/data_collector/messages_spec.rb +2 -2
  209. data/spec/unit/data_collector_spec.rb +19 -19
  210. data/spec/unit/dsl/audit_spec.rb +3 -3
  211. data/spec/unit/dsl/data_query_spec.rb +3 -2
  212. data/spec/unit/dsl/declare_resource_spec.rb +10 -10
  213. data/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb +3 -2
  214. data/spec/unit/encrypted_data_bag_item_spec.rb +3 -2
  215. data/spec/unit/environment_spec.rb +6 -6
  216. data/spec/unit/event_dispatch/dispatcher_spec.rb +2 -2
  217. data/spec/unit/file_access_control_spec.rb +3 -3
  218. data/spec/unit/file_content_management/tempfile_spec.rb +2 -2
  219. data/spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb +2 -2
  220. data/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb +2 -2
  221. data/spec/unit/http/basic_client_spec.rb +20 -0
  222. data/spec/unit/http/validate_content_length_spec.rb +8 -8
  223. data/spec/unit/http_spec.rb +14 -0
  224. data/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb +2 -2
  225. data/spec/unit/knife/bootstrap/client_builder_spec.rb +2 -2
  226. data/spec/unit/knife/bootstrap_spec.rb +8 -6
  227. data/spec/unit/knife/client_bulk_delete_spec.rb +8 -8
  228. data/spec/unit/knife/client_edit_spec.rb +2 -2
  229. data/spec/unit/knife/configure_client_spec.rb +2 -2
  230. data/spec/unit/knife/cookbook_metadata_spec.rb +4 -4
  231. data/spec/unit/knife/cookbook_site_install_spec.rb +6 -5
  232. data/spec/unit/knife/cookbook_site_share_spec.rb +2 -2
  233. data/spec/unit/knife/core/hashed_command_loader_spec.rb +5 -4
  234. data/spec/unit/knife/core/node_editor_spec.rb +3 -3
  235. data/spec/unit/knife/core/ui_spec.rb +2 -2
  236. data/spec/unit/knife/data_bag_from_file_spec.rb +4 -3
  237. data/spec/unit/knife/data_bag_show_spec.rb +3 -2
  238. data/spec/unit/knife/key_create_spec.rb +14 -14
  239. data/spec/unit/knife/key_delete_spec.rb +2 -2
  240. data/spec/unit/knife/key_edit_spec.rb +16 -16
  241. data/spec/unit/knife/key_list_spec.rb +6 -6
  242. data/spec/unit/knife/key_show_spec.rb +4 -4
  243. data/spec/unit/knife/status_spec.rb +3 -2
  244. data/spec/unit/knife/user_create_spec.rb +4 -4
  245. data/spec/unit/knife_spec.rb +7 -6
  246. data/spec/unit/lwrp_spec.rb +6 -6
  247. data/spec/unit/mixin/api_version_request_handling_spec.rb +2 -2
  248. data/spec/unit/mixin/command_spec.rb +17 -14
  249. data/spec/unit/mixin/deprecation_spec.rb +1 -1
  250. data/spec/unit/mixin/homebrew_user_spec.rb +2 -2
  251. data/spec/unit/mixin/params_validate_spec.rb +53 -52
  252. data/spec/unit/mixin/powershell_out_spec.rb +2 -2
  253. data/spec/unit/mixin/powershell_type_coercions_spec.rb +2 -2
  254. data/spec/unit/mixin/shell_out_spec.rb +1 -1
  255. data/spec/unit/mixin/xml_escape_spec.rb +3 -3
  256. data/spec/unit/node_spec.rb +2 -2
  257. data/spec/unit/platform/query_helpers_spec.rb +3 -3
  258. data/spec/unit/property_spec.rb +4 -4
  259. data/spec/unit/provider/cookbook_file_spec.rb +4 -4
  260. data/spec/unit/provider/cron/unix_spec.rb +4 -4
  261. data/spec/unit/provider/cron_spec.rb +2 -2
  262. data/spec/unit/provider/deploy_spec.rb +8 -8
  263. data/spec/unit/provider/dsc_resource_spec.rb +11 -10
  264. data/spec/unit/provider/dsc_script_spec.rb +9 -9
  265. data/spec/unit/provider/env/windows_spec.rb +8 -8
  266. data/spec/unit/provider/file/content_spec.rb +6 -6
  267. data/spec/unit/provider/file_spec.rb +4 -4
  268. data/spec/unit/provider/launchd_spec.rb +2 -1
  269. data/spec/unit/provider/link_spec.rb +155 -0
  270. data/spec/unit/provider/mount/mount_spec.rb +5 -5
  271. data/spec/unit/provider/mount/solaris_spec.rb +48 -48
  272. data/spec/unit/provider/osx_profile_spec.rb +6 -0
  273. data/spec/unit/provider/package/chocolatey_spec.rb +4 -4
  274. data/spec/unit/provider/package/freebsd/port_spec.rb +4 -4
  275. data/spec/unit/provider/package/rubygems_spec.rb +50 -44
  276. data/spec/unit/provider/package/windows/exe_spec.rb +9 -0
  277. data/spec/unit/provider/package/yum_spec.rb +61 -60
  278. data/spec/unit/provider/package_spec.rb +2 -2
  279. data/spec/unit/provider/powershell_script_spec.rb +4 -4
  280. data/spec/unit/provider/remote_directory_spec.rb +1 -1
  281. data/spec/unit/provider/remote_file/ftp_spec.rb +4 -4
  282. data/spec/unit/provider/remote_file/local_file_spec.rb +4 -2
  283. data/spec/unit/provider/remote_file/sftp_spec.rb +4 -4
  284. data/spec/unit/provider/remote_file_spec.rb +4 -4
  285. data/spec/unit/provider/script_spec.rb +4 -4
  286. data/spec/unit/provider/service/debian_service_spec.rb +4 -4
  287. data/spec/unit/provider/service/freebsd_service_spec.rb +12 -8
  288. data/spec/unit/provider/service/openbsd_service_spec.rb +12 -8
  289. data/spec/unit/provider/service/systemd_service_spec.rb +4 -4
  290. data/spec/unit/provider/service/upstart_service_spec.rb +27 -12
  291. data/spec/unit/provider/service/windows_spec.rb +10 -10
  292. data/spec/unit/provider/systemd_unit_spec.rb +2 -2
  293. data/spec/unit/provider/template/content_spec.rb +8 -8
  294. data/spec/unit/provider/template_spec.rb +8 -8
  295. data/spec/unit/provider/user/dscl_spec.rb +51 -51
  296. data/spec/unit/provider/user/linux_spec.rb +76 -0
  297. data/spec/unit/provider/user/pw_spec.rb +3 -6
  298. data/spec/unit/provider/user/solaris_spec.rb +5 -5
  299. data/spec/unit/provider/user/windows_spec.rb +3 -3
  300. data/spec/unit/provider/user_spec.rb +2 -2
  301. data/spec/unit/provider/yum_repository_spec.rb +35 -0
  302. data/spec/unit/provider_resolver_spec.rb +306 -264
  303. data/spec/unit/recipe_spec.rb +8 -7
  304. data/spec/unit/resource/apt_repository_spec.rb +4 -4
  305. data/spec/unit/resource/apt_update_spec.rb +4 -4
  306. data/spec/unit/resource/conditional_spec.rb +46 -0
  307. data/spec/unit/resource/dsc_resource_spec.rb +8 -8
  308. data/spec/unit/resource/dsc_script_spec.rb +4 -4
  309. data/spec/unit/resource/freebsd_package_spec.rb +6 -6
  310. data/spec/unit/resource/launchd_spec.rb +3 -2
  311. data/spec/unit/resource/osx_profile_spec.rb +3 -2
  312. data/spec/unit/resource/remote_file_spec.rb +6 -6
  313. data/spec/unit/resource/service_spec.rb +14 -14
  314. data/spec/unit/resource/user_spec.rb +1 -1
  315. data/spec/unit/resource/yum_repository_spec.rb +49 -0
  316. data/spec/unit/resource_collection_spec.rb +4 -4
  317. data/spec/unit/resource_definition_spec.rb +11 -11
  318. data/spec/unit/resource_reporter_spec.rb +4 -4
  319. data/spec/unit/resource_resolver_spec.rb +6 -6
  320. data/spec/unit/resource_spec.rb +36 -16
  321. data/spec/unit/run_context/child_run_context_spec.rb +4 -4
  322. data/spec/unit/run_context/cookbook_compiler_spec.rb +43 -1
  323. data/spec/unit/run_context_spec.rb +8 -8
  324. data/spec/unit/run_list/run_list_expansion_spec.rb +2 -2
  325. data/spec/unit/runner_spec.rb +2 -2
  326. data/spec/unit/search/query_spec.rb +15 -14
  327. data/spec/unit/user_v1_spec.rb +8 -8
  328. data/spec/unit/util/dsc/configuration_generator_spec.rb +12 -12
  329. data/spec/unit/util/dsc/local_configuration_manager_spec.rb +12 -9
  330. data/spec/unit/util/dsc/resource_store.rb +8 -6
  331. data/spec/unit/util/editor_spec.rb +6 -6
  332. data/spec/unit/util/powershell/cmdlet_spec.rb +10 -10
  333. data/tasks/bin/bundle-platform +1 -0
  334. data/tasks/bin/bundler_patch.rb +27 -0
  335. data/tasks/cbgb.rb +2 -2
  336. data/tasks/maintainers.rb +2 -2
  337. metadata +37 -8
  338. data/spec/unit/provider/user/useradd_spec.rb +0 -51
@@ -14,11 +14,14 @@
14
14
  # See the License for the specific language governing permissions and
15
15
  # limitations under the License.
16
16
 
17
+ require "chef/provider/user/useradd"
18
+
17
19
  class Chef
18
20
  class Provider
19
21
  class User
20
22
  class Aix < Chef::Provider::User::Useradd
21
- provides :user, platform: %w{aix}
23
+ provides :user, os: "aix"
24
+ provides :aix_user
22
25
 
23
26
  UNIVERSAL_OPTIONS = [[:comment, "-c"], [:gid, "-g"], [:shell, "-s"], [:uid, "-u"]]
24
27
 
@@ -66,7 +69,7 @@ class Chef
66
69
  shell_out!("chuser account_locked=false #{new_resource.username}")
67
70
  end
68
71
 
69
- private
72
+ private
70
73
 
71
74
  def add_password
72
75
  if @current_resource.password != @new_resource.password && @new_resource.password
@@ -48,6 +48,7 @@ class Chef
48
48
  attr_accessor :authentication_authority
49
49
  attr_accessor :password_shadow_conversion_algorithm
50
50
 
51
+ provides :dscl_user
51
52
  provides :user, os: "darwin"
52
53
 
53
54
  def define_resource_requirements
@@ -0,0 +1,128 @@
1
+ #
2
+ # Copyright:: Copyright 2016, Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require "chef/provider/user"
18
+
19
+ class Chef
20
+ class Provider
21
+ class User
22
+ class Linux < Chef::Provider::User
23
+ provides :linux_user
24
+ provides :user, os: "linux"
25
+
26
+ def create_user
27
+ shell_out!(*clean_array("useradd", universal_options, useradd_options, new_resource.username))
28
+ end
29
+
30
+ def manage_user
31
+ shell_out!(*clean_array("usermod", universal_options, usermod_options, new_resource.username))
32
+ end
33
+
34
+ def remove_user
35
+ shell_out!(*clean_array("userdel", userdel_options, new_resource.username))
36
+ end
37
+
38
+ def lock_user
39
+ shell_out!(*clean_array("usermod", "-L", new_resource.username))
40
+ end
41
+
42
+ def unlock_user
43
+ shell_out!(*clean_array("usermod", "-U", new_resource.username))
44
+ end
45
+
46
+ # common to usermod and useradd
47
+ def universal_options
48
+ opts = []
49
+ opts << "-c" << new_resource.comment if should_set?(:comment)
50
+ opts << "-g" << new_resource.gid if should_set?(:gid)
51
+ opts << "-p" << new_resource.password if should_set?(:password)
52
+ opts << "-s" << new_resource.shell if should_set?(:shell)
53
+ opts << "-u" << new_resource.uid if should_set?(:uid)
54
+ opts << "-d" << new_resource.home if updating_home?
55
+ opts << "-o" if new_resource.non_unique
56
+ opts
57
+ end
58
+
59
+ def usermod_options
60
+ opts = []
61
+ if updating_home?
62
+ if new_resource.manage_home
63
+ opts << "-m"
64
+ end
65
+ end
66
+ opts
67
+ end
68
+
69
+ def useradd_options
70
+ opts = []
71
+ opts << "-r" if new_resource.system
72
+ if new_resource.manage_home
73
+ opts << "-m"
74
+ else
75
+ opts << "-M"
76
+ end
77
+ opts
78
+ end
79
+
80
+ def userdel_options
81
+ opts = []
82
+ opts << "-r" if new_resource.manage_home
83
+ opts << "-f" if new_resource.force
84
+ opts
85
+ end
86
+
87
+ def should_set?(sym)
88
+ current_resource.send(sym).to_s != new_resource.send(sym).to_s && new_resource.send(sym)
89
+ end
90
+
91
+ def updating_home?
92
+ return false unless new_resource.home
93
+ return true unless current_resource.home
94
+ new_resource.home && Pathname.new(current_resource.home).cleanpath != Pathname.new(new_resource.home).cleanpath
95
+ end
96
+
97
+ def check_lock
98
+ # there's an old bug in rhel (https://bugzilla.redhat.com/show_bug.cgi?id=578534)
99
+ # which means that both 0 and 1 can be success.
100
+ passwd_s = shell_out("passwd", "-S", new_resource.username, returns: [ 0, 1 ])
101
+
102
+ # checking "does not exist" has to come before exit code handling since centos and ubuntu differ in exit codes
103
+ if passwd_s.stderr =~ /does not exist/
104
+ if whyrun_mode?
105
+ return false
106
+ else
107
+ raise Chef::Exceptions::User, "User #{new_resource.username} does not exist when checking lock status for #{new_resource}"
108
+ end
109
+ end
110
+
111
+ # now raise if we didn't get a 0 or 1 (see above)
112
+ passwd_s.error!
113
+
114
+ # now the actual output parsing
115
+ @locked = nil
116
+ status_line = passwd_s.stdout.split(" ")
117
+ @locked = false if status_line[1] =~ /^[PN]/
118
+ @locked = true if status_line[1] =~ /^L/
119
+
120
+ raise Chef::Exceptions::User, "Cannot determine if user #{new_resource.username} is locked for #{new_resource}" if @locked.nil?
121
+
122
+ # FIXME: should probably go on the current_resource
123
+ @locked
124
+ end
125
+ end
126
+ end
127
+ end
128
+ end
@@ -22,7 +22,8 @@ class Chef
22
22
  class Provider
23
23
  class User
24
24
  class Pw < Chef::Provider::User
25
- provides :user, platform: %w{freebsd}
25
+ provides :pw_user
26
+ provides :user, os: "freebsd"
26
27
 
27
28
  def load_current_resource
28
29
  super
@@ -24,7 +24,8 @@ class Chef
24
24
  class Provider
25
25
  class User
26
26
  class Solaris < Chef::Provider::User::Useradd
27
- provides :user, platform: %w{omnios solaris2}
27
+ provides :solaris_user
28
+ provides :user, os: %w{omnios solaris2}
28
29
  UNIVERSAL_OPTIONS = [[:comment, "-c"], [:gid, "-g"], [:shell, "-s"], [:uid, "-u"]]
29
30
 
30
31
  attr_writer :password_file
@@ -70,7 +71,7 @@ class Chef
70
71
  shell_out!("passwd", "-u", new_resource.username)
71
72
  end
72
73
 
73
- private
74
+ private
74
75
 
75
76
  def manage_password
76
77
  if @current_resource.password != @new_resource.password && @new_resource.password
@@ -23,7 +23,7 @@ class Chef
23
23
  class Provider
24
24
  class User
25
25
  class Useradd < Chef::Provider::User
26
- provides :user
26
+ # MAJOR XXX: this should become the base class of all Useradd providers instead of the linux implementation
27
27
 
28
28
  UNIVERSAL_OPTIONS = [[:comment, "-c"], [:gid, "-g"], [:password, "-p"], [:shell, "-s"], [:uid, "-u"]]
29
29
 
@@ -116,15 +116,15 @@ class Chef
116
116
  update_options(field, option, opts)
117
117
  end
118
118
  if updating_home?
119
+ opts << "-d" << new_resource.home
119
120
  if managing_home_dir?
120
121
  Chef::Log.debug("#{new_resource} managing the users home directory")
121
- opts << "-d" << new_resource.home << "-m"
122
+ opts << "-m"
122
123
  else
123
124
  Chef::Log.debug("#{new_resource} setting home to #{new_resource.home}")
124
- opts << "-d" << new_resource.home
125
125
  end
126
126
  end
127
- opts << "-o" if new_resource.non_unique || new_resource.supports[:non_unique]
127
+ opts << "-o" if new_resource.non_unique
128
128
  opts
129
129
  end
130
130
  end
@@ -141,6 +141,7 @@ class Chef
141
141
  def useradd_options
142
142
  opts = []
143
143
  opts << "-r" if new_resource.system
144
+ opts << "-M" unless managing_home_dir?
144
145
  opts
145
146
  end
146
147
 
@@ -26,7 +26,7 @@ class Chef
26
26
  class Provider
27
27
  class User
28
28
  class Windows < Chef::Provider::User
29
-
29
+ provides :windows_user
30
30
  provides :user, os: "windows"
31
31
 
32
32
  def initialize(new_resource, run_context)
@@ -33,8 +33,11 @@ class Chef
33
33
  super( new_resource, run_context )
34
34
  @script_extension = script_extension
35
35
 
36
- target_architecture = new_resource.architecture.nil? ?
37
- node_windows_architecture(run_context.node) : new_resource.architecture
36
+ target_architecture = if new_resource.architecture.nil?
37
+ node_windows_architecture(run_context.node)
38
+ else
39
+ new_resource.architecture
40
+ end
38
41
 
39
42
  @is_wow64 = wow64_architecture_override_required?(run_context.node, target_architecture)
40
43
 
@@ -0,0 +1,121 @@
1
+ #
2
+ # Author:: Thom May (<thom@chef.io>)
3
+ # Copyright:: Copyright (c) 2016 Chef Software, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require "chef/resource"
20
+ require "chef/dsl/declare_resource"
21
+ require "chef/mixin/shell_out"
22
+ require "chef/mixin/which"
23
+ require "chef/http/simple"
24
+ require "chef/provider/noop"
25
+
26
+ class Chef
27
+ class Provider
28
+ class YumRepository < Chef::Provider
29
+ use_inline_resources
30
+
31
+ extend Chef::Mixin::Which
32
+
33
+ provides :yum_repository do
34
+ which "yum"
35
+ end
36
+
37
+ def whyrun_supported?; true; end
38
+
39
+ def load_current_resource; end
40
+
41
+ action :create do
42
+ declare_resource(:template, "/etc/yum.repos.d/#{new_resource.repositoryid}.repo") do
43
+ if template_available?(new_resource.source)
44
+ source new_resource.source
45
+ else
46
+ source ::File.expand_path("../support/yum_repo.erb", __FILE__)
47
+ local true
48
+ end
49
+ sensitive new_resource.sensitive
50
+ variables(config: new_resource)
51
+ mode new_resource.mode
52
+ if new_resource.make_cache
53
+ notifies :run, "execute[yum clean metadata #{new_resource.repositoryid}]", :immediately if new_resource.clean_metadata || new_resource.clean_headers
54
+ notifies :run, "execute[yum-makecache-#{new_resource.repositoryid}]", :immediately
55
+ notifies :create, "ruby_block[yum-cache-reload-#{new_resource.repositoryid}]", :immediately
56
+ end
57
+ end
58
+
59
+ declare_resource(:execute, "yum clean metadata #{new_resource.repositoryid}") do
60
+ command "yum clean metadata --disablerepo=* --enablerepo=#{new_resource.repositoryid}"
61
+ action :nothing
62
+ end
63
+
64
+ # get the metadata for this repo only
65
+ declare_resource(:execute, "yum-makecache-#{new_resource.repositoryid}") do
66
+ command "yum -q -y makecache --disablerepo=* --enablerepo=#{new_resource.repositoryid}"
67
+ action :nothing
68
+ only_if { new_resource.enabled }
69
+ end
70
+
71
+ # reload internal Chef yum cache
72
+ declare_resource(:ruby_block, "yum-cache-reload-#{new_resource.repositoryid}") do
73
+ block { Chef::Provider::Package::Yum::YumCache.instance.reload }
74
+ action :nothing
75
+ end
76
+ end
77
+
78
+ action :delete do
79
+ declare_resource(:file, "/etc/yum.repos.d/#{new_resource.repositoryid}.repo") do
80
+ action :delete
81
+ notifies :run, "execute[yum clean all #{new_resource.repositoryid}]", :immediately
82
+ notifies :create, "ruby_block[yum-cache-reload-#{new_resource.repositoryid}]", :immediately
83
+ end
84
+
85
+ declare_resource(:execute, "yum clean all #{new_resource.repositoryid}") do
86
+ command "yum clean all --disablerepo=* --enablerepo=#{new_resource.repositoryid}"
87
+ only_if "yum repolist | grep -P '^#{new_resource.repositoryid}([ \t]|$)'"
88
+ action :nothing
89
+ end
90
+
91
+ declare_resource(:ruby_block, "yum-cache-reload-#{new_resource.repositoryid}") do
92
+ block { Chef::Provider::Package::Yum::YumCache.instance.reload }
93
+ action :nothing
94
+ end
95
+ end
96
+
97
+ action :makecache do
98
+ declare_resource(:execute, "yum-makecache-#{new_resource.repositoryid}") do
99
+ command "yum -q -y makecache --disablerepo=* --enablerepo=#{new_resource.repositoryid}"
100
+ action :run
101
+ only_if { new_resource.enabled }
102
+ end
103
+
104
+ declare_resource(:ruby_block, "yum-cache-reload-#{new_resource.repositoryid}") do
105
+ block { Chef::Provider::Package::Yum::YumCache.instance.reload }
106
+ action :run
107
+ end
108
+ end
109
+
110
+ alias_method :action_add, :action_create
111
+ alias_method :action_remove, :action_delete
112
+
113
+ def template_available?(path)
114
+ !path.nil? && run_context.has_template_in_cookbook?(new_resource.cookbook_name, path)
115
+ end
116
+
117
+ end
118
+ end
119
+ end
120
+
121
+ Chef::Provider::Noop.provides :yum_repository
@@ -58,6 +58,7 @@ require "chef/provider/systemd_unit"
58
58
  require "chef/provider/template"
59
59
  require "chef/provider/user"
60
60
  require "chef/provider/whyrun_safe_ruby_block"
61
+ require "chef/provider/yum_repository"
61
62
 
62
63
  require "chef/provider/env/windows"
63
64
 
@@ -101,12 +102,13 @@ require "chef/provider/service/macosx"
101
102
  require "chef/provider/service/aixinit"
102
103
  require "chef/provider/service/aix"
103
104
 
105
+ require "chef/provider/user/aix"
104
106
  require "chef/provider/user/dscl"
107
+ require "chef/provider/user/linux"
105
108
  require "chef/provider/user/pw"
109
+ require "chef/provider/user/solaris"
106
110
  require "chef/provider/user/useradd"
107
111
  require "chef/provider/user/windows"
108
- require "chef/provider/user/solaris"
109
- require "chef/provider/user/aix"
110
112
 
111
113
  require "chef/provider/group/aix"
112
114
  require "chef/provider/group/dscl"
@@ -497,7 +497,7 @@ class Chef
497
497
  state_properties = self.class.state_properties
498
498
  state_properties.each do |property|
499
499
  if property.identity? || property.is_set?(self)
500
- state[property.name] = send(property.name)
500
+ state[property.name] = property.sensitive? ? "*sensitive value suppressed*" : send(property.name)
501
501
  end
502
502
  end
503
503
  state
@@ -1276,15 +1276,15 @@ class Chef
1276
1276
  # resolve_resource_reference on each in turn, causing them to
1277
1277
  # resolve lazy/forward references.
1278
1278
  def resolve_notification_references
1279
- run_context.before_notifications(self).each { |n|
1279
+ run_context.before_notifications(self).each do |n|
1280
1280
  n.resolve_resource_reference(run_context.resource_collection)
1281
- }
1282
- run_context.immediate_notifications(self).each { |n|
1281
+ end
1282
+ run_context.immediate_notifications(self).each do |n|
1283
1283
  n.resolve_resource_reference(run_context.resource_collection)
1284
- }
1285
- run_context.delayed_notifications(self).each {|n|
1284
+ end
1285
+ run_context.delayed_notifications(self).each do |n|
1286
1286
  n.resolve_resource_reference(run_context.resource_collection)
1287
- }
1287
+ end
1288
1288
  end
1289
1289
 
1290
1290
  # Helper for #notifies
@@ -1575,8 +1575,6 @@ class Chef
1575
1575
  end
1576
1576
  end
1577
1577
 
1578
- private
1579
-
1580
1578
  def self.remove_canonical_dsl
1581
1579
  if @resource_name
1582
1580
  remaining = Chef.resource_handler_map.delete_canonical(@resource_name, self)
@@ -103,7 +103,15 @@ class Chef
103
103
  end
104
104
 
105
105
  def evaluate_block
106
- @block.call
106
+ @block.call.tap do |rv|
107
+ if rv.is_a?(String) && !rv.empty?
108
+ # This is probably a mistake:
109
+ # not_if { "command" }
110
+ sanitized_rv = @parent_resource.sensitive ? "a string" : rv.inspect
111
+ Chef::Log.warn("#{@positivity} block for #{@parent_resource} returned #{sanitized_rv}, did you mean to run a command?" +
112
+ (@parent_resource.sensitive ? "" : " If so use '#{@positivity} #{sanitized_rv}' in your code."))
113
+ end
114
+ end
107
115
  end
108
116
 
109
117
  def short_description