chef 12.4.3-universal-mingw32 → 12.5.1-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +21 -25
- data/Gemfile +46 -0
- data/README.md +4 -4
- data/Rakefile +4 -110
- data/bin/chef-service-manager +3 -1
- data/distro/common/html/knife_cookbook_site.html +18 -18
- data/distro/common/man/man1/knife-cookbook-site.1 +11 -11
- data/lib/chef.rb +1 -1
- data/lib/chef/application.rb +1 -1
- data/lib/chef/application/apply.rb +19 -1
- data/lib/chef/application/client.rb +11 -5
- data/lib/chef/application/knife.rb +2 -2
- data/lib/chef/application/solo.rb +1 -1
- data/lib/chef/application/windows_service_manager.rb +19 -12
- data/lib/chef/chef_class.rb +46 -0
- data/lib/chef/chef_fs/config.rb +22 -24
- data/lib/chef/chef_fs/data_handler/client_data_handler.rb +3 -1
- data/lib/chef/chef_fs/file_pattern.rb +4 -15
- data/lib/chef/chef_fs/file_system/acl_dir.rb +3 -4
- data/lib/chef/chef_fs/file_system/acls_dir.rb +5 -1
- data/lib/chef/chef_fs/file_system/base_fs_dir.rb +0 -5
- data/lib/chef/chef_fs/file_system/base_fs_object.rb +5 -2
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_dir.rb +2 -9
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_entry.rb +2 -9
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbooks_dir.rb +10 -17
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +1 -12
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb +15 -11
- data/lib/chef/chef_fs/file_system/chef_server_root_dir.rb +8 -2
- data/lib/chef/chef_fs/file_system/cookbook_dir.rb +4 -4
- data/lib/chef/chef_fs/file_system/cookbooks_acl_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/cookbooks_dir.rb +3 -11
- data/lib/chef/chef_fs/file_system/data_bags_dir.rb +3 -5
- data/lib/chef/chef_fs/file_system/environments_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/file_system_entry.rb +7 -4
- data/lib/chef/chef_fs/file_system/memory_dir.rb +2 -3
- data/lib/chef/chef_fs/file_system/multiplexed_dir.rb +15 -0
- data/lib/chef/chef_fs/file_system/nodes_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/organization_members_entry.rb +2 -2
- data/lib/chef/chef_fs/file_system/rest_list_dir.rb +4 -9
- data/lib/chef/chef_fs/knife.rb +35 -7
- data/lib/chef/chef_fs/path_utils.rb +65 -34
- data/lib/chef/client.rb +2 -3
- data/lib/chef/config.rb +34 -2
- data/lib/chef/{mixin/wstring.rb → constants.rb} +9 -13
- data/lib/chef/cookbook/metadata.rb +25 -3
- data/lib/chef/cookbook/synchronizer.rb +1 -1
- data/lib/chef/cookbook_site_streaming_uploader.rb +1 -1
- data/lib/chef/cookbook_version.rb +3 -3
- data/lib/chef/delayed_evaluator.rb +21 -0
- data/lib/chef/deprecation/mixin/template.rb +1 -2
- data/lib/chef/deprecation/provider/cookbook_file.rb +1 -1
- data/lib/chef/deprecation/provider/file.rb +1 -1
- data/lib/chef/deprecation/provider/remote_directory.rb +52 -0
- data/lib/chef/deprecation/provider/remote_file.rb +1 -2
- data/lib/chef/deprecation/provider/template.rb +1 -1
- data/lib/chef/deprecation/warnings.rb +3 -4
- data/lib/chef/dsl/reboot_pending.rb +3 -2
- data/lib/chef/dsl/recipe.rb +26 -7
- data/lib/chef/dsl/resources.rb +2 -2
- data/lib/chef/event_dispatch/base.rb +51 -22
- data/lib/chef/event_dispatch/dispatcher.rb +21 -6
- data/lib/chef/event_dispatch/dsl.rb +64 -0
- data/lib/chef/exceptions.rb +28 -1
- data/lib/chef/file_content_management/tempfile.rb +1 -1
- data/lib/chef/formatters/base.rb +3 -0
- data/lib/chef/formatters/doc.rb +56 -6
- data/lib/chef/formatters/error_inspectors/compile_error_inspector.rb +36 -0
- data/lib/chef/formatters/minimal.rb +2 -2
- data/lib/chef/guard_interpreter/resource_guard_interpreter.rb +3 -1
- data/lib/chef/http/http_request.rb +1 -1
- data/lib/chef/knife.rb +35 -55
- data/lib/chef/knife/bootstrap.rb +41 -0
- data/lib/chef/knife/bootstrap/chef_vault_handler.rb +1 -0
- data/lib/chef/knife/bootstrap/client_builder.rb +16 -0
- data/lib/chef/knife/bootstrap/templates/README.md +3 -4
- data/lib/chef/knife/bootstrap/templates/chef-full.erb +1 -1
- data/lib/chef/knife/cookbook_create.rb +1 -1
- data/lib/chef/knife/cookbook_site_download.rb +1 -1
- data/lib/chef/knife/cookbook_site_install.rb +1 -1
- data/lib/chef/knife/cookbook_site_share.rb +6 -6
- data/lib/chef/knife/cookbook_site_unshare.rb +2 -2
- data/lib/chef/knife/core/bootstrap_context.rb +12 -4
- data/lib/chef/knife/core/custom_manifest_loader.rb +69 -0
- data/lib/chef/knife/core/gem_glob_loader.rb +138 -0
- data/lib/chef/knife/core/hashed_command_loader.rb +80 -0
- data/lib/chef/knife/core/node_presenter.rb +24 -1
- data/lib/chef/knife/core/object_loader.rb +1 -0
- data/lib/chef/knife/core/subcommand_loader.rb +131 -146
- data/lib/chef/knife/node_run_list_remove.rb +12 -1
- data/lib/chef/knife/null.rb +10 -0
- data/lib/chef/knife/rehash.rb +62 -0
- data/lib/chef/knife/search.rb +3 -3
- data/lib/chef/knife/ssh.rb +52 -30
- data/lib/chef/knife/ssl_check.rb +3 -2
- data/lib/chef/knife/user_edit.rb +1 -2
- data/lib/chef/local_mode.rb +5 -0
- data/lib/chef/log.rb +5 -1
- data/lib/chef/mixin/deprecation.rb +8 -8
- data/lib/chef/mixin/params_validate.rb +362 -135
- data/lib/chef/mixin/template.rb +48 -0
- data/lib/chef/mixin/which.rb +1 -1
- data/lib/chef/mixin/wide_string.rb +72 -0
- data/lib/chef/mixin/windows_architecture_helper.rb +15 -39
- data/lib/chef/mixin/windows_env_helper.rb +4 -1
- data/lib/chef/monkey_patches/webrick-utils.rb +51 -0
- data/lib/chef/monkey_patches/win32/registry.rb +72 -0
- data/lib/chef/node.rb +116 -3
- data/lib/chef/node_map.rb +2 -2
- data/lib/chef/platform/handler_map.rb +0 -5
- data/lib/chef/platform/provider_mapping.rb +5 -6
- data/lib/chef/platform/query_helpers.rb +46 -4
- data/lib/chef/platform/rebooter.rb +1 -1
- data/lib/chef/platform/service_helpers.rb +30 -32
- data/lib/chef/policy_builder.rb +1 -8
- data/lib/chef/policy_builder/dynamic.rb +186 -0
- data/lib/chef/policy_builder/expand_node_object.rb +30 -15
- data/lib/chef/policy_builder/policyfile.rb +155 -18
- data/lib/chef/property.rb +568 -0
- data/lib/chef/provider.rb +222 -13
- data/lib/chef/provider/batch.rb +8 -0
- data/lib/chef/provider/deploy.rb +5 -7
- data/lib/chef/provider/directory.rb +14 -2
- data/lib/chef/provider/dsc_resource.rb +5 -9
- data/lib/chef/provider/group/pw.rb +1 -1
- data/lib/chef/provider/ifconfig.rb +2 -2
- data/lib/chef/provider/lwrp_base.rb +1 -75
- data/lib/chef/provider/mount.rb +7 -3
- data/lib/chef/provider/package.rb +1 -1
- data/lib/chef/provider/package/dpkg.rb +5 -11
- data/lib/chef/provider/package/rpm.rb +2 -2
- data/lib/chef/provider/package/rubygems.rb +1 -1
- data/lib/chef/provider/package/windows/msi.rb +2 -2
- data/lib/chef/provider/package/yum.rb +17 -5
- data/lib/chef/provider/powershell_script.rb +59 -23
- data/lib/chef/provider/registry_key.rb +5 -5
- data/lib/chef/provider/remote_directory.rb +190 -102
- data/lib/chef/provider/service.rb +12 -2
- data/lib/chef/provider/service/aix.rb +1 -1
- data/lib/chef/provider/service/debian.rb +3 -5
- data/lib/chef/provider/service/freebsd.rb +1 -1
- data/lib/chef/provider/service/gentoo.rb +3 -3
- data/lib/chef/provider/service/init.rb +3 -3
- data/lib/chef/provider/service/insserv.rb +2 -4
- data/lib/chef/provider/service/invokercd.rb +2 -4
- data/lib/chef/provider/service/macosx.rb +5 -1
- data/lib/chef/provider/service/openbsd.rb +2 -1
- data/lib/chef/provider/service/redhat.rb +52 -16
- data/lib/chef/provider/service/simple.rb +2 -2
- data/lib/chef/provider/service/systemd.rb +3 -5
- data/lib/chef/provider/service/upstart.rb +4 -6
- data/lib/chef/provider/subversion.rb +13 -7
- data/lib/chef/provider/template/content.rb +16 -6
- data/lib/chef/provider/user/solaris.rb +32 -4
- data/lib/chef/provider/windows_script.rb +3 -5
- data/lib/chef/provider_resolver.rb +2 -2
- data/lib/chef/recipe.rb +1 -8
- data/lib/chef/resource.rb +563 -90
- data/lib/chef/resource/action_class.rb +83 -0
- data/lib/chef/resource/chef_gem.rb +3 -3
- data/lib/chef/resource/deploy.rb +8 -2
- data/lib/chef/resource/dsc_script.rb +2 -0
- data/lib/chef/resource/file/verification.rb +7 -1
- data/lib/chef/resource/lwrp_base.rb +1 -7
- data/lib/chef/resource/registry_key.rb +1 -1
- data/lib/chef/resource/service.rb +10 -2
- data/lib/chef/resource/subversion.rb +5 -0
- data/lib/chef/resource/windows_script.rb +6 -2
- data/lib/chef/resource/yum_package.rb +10 -1
- data/lib/chef/resource_resolver.rb +3 -3
- data/lib/chef/run_context.rb +402 -83
- data/lib/chef/run_list/versioned_recipe_list.rb +15 -0
- data/lib/chef/run_lock.rb +30 -21
- data/lib/chef/util/powershell/ps_credential.rb +4 -0
- data/lib/chef/util/windows.rb +0 -32
- data/lib/chef/util/windows/net_group.rb +85 -106
- data/lib/chef/util/windows/net_use.rb +35 -71
- data/lib/chef/util/windows/net_user.rb +0 -1
- data/lib/chef/util/windows/volume.rb +19 -19
- data/lib/chef/version.rb +3 -3
- data/lib/chef/win32/api.rb +1 -0
- data/lib/chef/win32/api/file.rb +20 -0
- data/lib/chef/win32/api/net.rb +163 -43
- data/lib/chef/win32/api/registry.rb +51 -0
- data/lib/chef/win32/api/system.rb +23 -0
- data/lib/chef/win32/api/unicode.rb +0 -43
- data/lib/chef/win32/crypto.rb +2 -1
- data/lib/chef/win32/file.rb +28 -3
- data/lib/chef/win32/mutex.rb +1 -2
- data/lib/chef/win32/net.rb +162 -8
- data/lib/chef/win32/process.rb +13 -0
- data/lib/chef/win32/registry.rb +35 -30
- data/lib/chef/win32/security.rb +1 -1
- data/lib/chef/win32/security/token.rb +1 -1
- data/lib/chef/win32/system.rb +62 -0
- data/lib/chef/win32/unicode.rb +7 -2
- data/lib/chef/win32/version.rb +0 -4
- data/lib/chef/workstation_config_loader.rb +3 -158
- data/spec/data/cookbooks/openldap/templates/default/helpers.erb +14 -0
- data/spec/data/cookbooks/openldap/templates/default/nested_openldap_partials.erb +1 -0
- data/spec/data/cookbooks/openldap/templates/default/nested_partial.erb +1 -0
- data/spec/data/dsc_lcm.pfx +0 -0
- data/spec/data/run_context/cookbooks/include/recipes/default.rb +24 -0
- data/spec/data/run_context/cookbooks/include/recipes/includee.rb +3 -0
- data/spec/functional/dsl/reboot_pending_spec.rb +33 -43
- data/spec/functional/knife/cookbook_delete_spec.rb +17 -7
- data/spec/functional/knife/ssh_spec.rb +16 -0
- data/spec/functional/rebooter_spec.rb +1 -1
- data/spec/functional/resource/deploy_revision_spec.rb +1 -1
- data/spec/functional/resource/dsc_resource_spec.rb +2 -0
- data/spec/functional/resource/dsc_script_spec.rb +91 -2
- data/spec/functional/resource/group_spec.rb +67 -44
- data/spec/functional/resource/{powershell_spec.rb → powershell_script_spec.rb} +107 -18
- data/spec/functional/resource/windows_service_spec.rb +1 -1
- data/spec/functional/run_lock_spec.rb +368 -189
- data/spec/functional/win32/{registry_helper_spec.rb → registry_spec.rb} +16 -23
- data/spec/functional/win32/service_manager_spec.rb +2 -2
- data/spec/integration/client/client_spec.rb +51 -0
- data/spec/integration/knife/chef_repo_path_spec.rb +13 -11
- data/spec/integration/knife/download_spec.rb +4 -0
- data/spec/integration/knife/list_spec.rb +8 -0
- data/spec/integration/knife/upload_spec.rb +1 -1
- data/spec/integration/recipes/recipe_dsl_spec.rb +1 -16
- data/spec/integration/recipes/remote_directory.rb +74 -0
- data/spec/integration/recipes/resource_action_spec.rb +363 -0
- data/spec/integration/recipes/resource_converge_if_changed_spec.rb +423 -0
- data/spec/integration/recipes/resource_load_spec.rb +206 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/support/platform_helpers.rb +13 -0
- data/spec/support/shared/context/win32.rb +34 -0
- data/spec/support/shared/functional/win32_service.rb +2 -1
- data/spec/support/shared/functional/windows_script.rb +63 -26
- data/spec/support/shared/unit/mock_shellout.rb +46 -0
- data/spec/support/shared/unit/provider/file.rb +10 -4
- data/spec/unit/application/client_spec.rb +16 -3
- data/spec/unit/application/knife_spec.rb +2 -2
- data/spec/unit/application/solo_spec.rb +4 -3
- data/spec/unit/chef_class_spec.rb +23 -4
- data/spec/unit/chef_fs/path_util_spec.rb +108 -0
- data/spec/unit/client_spec.rb +6 -1
- data/spec/unit/config_spec.rb +31 -0
- data/spec/unit/cookbook/metadata_spec.rb +23 -3
- data/spec/unit/cookbook/syntax_check_spec.rb +3 -0
- data/spec/unit/deprecation_spec.rb +3 -6
- data/spec/unit/dsl/reboot_pending_spec.rb +12 -6
- data/spec/unit/event_dispatch/dispatcher_spec.rb +65 -3
- data/spec/unit/event_dispatch/dsl_spec.rb +83 -0
- data/spec/unit/formatters/doc_spec.rb +32 -0
- data/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb +26 -0
- data/spec/unit/json_compat_spec.rb +4 -3
- data/spec/unit/knife/bootstrap/client_builder_spec.rb +27 -0
- data/spec/unit/knife/bootstrap_spec.rb +55 -3
- data/spec/unit/knife/cookbook_site_share_spec.rb +3 -3
- data/spec/unit/knife/core/bootstrap_context_spec.rb +21 -4
- data/spec/unit/knife/core/custom_manifest_loader_spec.rb +41 -0
- data/spec/unit/knife/core/gem_glob_loader_spec.rb +210 -0
- data/spec/unit/knife/core/hashed_command_loader_spec.rb +93 -0
- data/spec/unit/knife/core/subcommand_loader_spec.rb +16 -192
- data/spec/unit/knife/node_run_list_remove_spec.rb +17 -0
- data/spec/unit/knife/ssl_check_spec.rb +4 -0
- data/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb +10 -10
- data/spec/unit/mixin/params_validate_spec.rb +4 -2
- data/spec/unit/mixin/template_spec.rb +5 -1
- data/spec/unit/mixin/windows_architecture_helper_spec.rb +13 -8
- data/spec/unit/node_spec.rb +220 -0
- data/spec/unit/platform/query_helpers_spec.rb +146 -3
- data/spec/unit/policy_builder/dynamic_spec.rb +275 -0
- data/spec/unit/policy_builder/expand_node_object_spec.rb +37 -38
- data/spec/unit/policy_builder/policyfile_spec.rb +260 -46
- data/spec/unit/property/state_spec.rb +506 -0
- data/spec/unit/property/validation_spec.rb +663 -0
- data/spec/unit/property_spec.rb +1094 -0
- data/spec/unit/provider/deploy_spec.rb +5 -5
- data/spec/unit/provider/directory_spec.rb +35 -0
- data/spec/unit/provider/dsc_resource_spec.rb +3 -10
- data/spec/unit/provider/ifconfig_spec.rb +22 -2
- data/spec/unit/provider/mount/aix_spec.rb +2 -1
- data/spec/unit/provider/mount/mount_spec.rb +6 -0
- data/spec/unit/provider/mount/windows_spec.rb +14 -0
- data/spec/unit/provider/mount_spec.rb +12 -1
- data/spec/unit/provider/package/dpkg_spec.rb +8 -1
- data/spec/unit/provider/package/rpm_spec.rb +18 -1
- data/spec/unit/provider/package/rubygems_spec.rb +18 -0
- data/spec/unit/provider/package/yum_spec.rb +97 -24
- data/spec/unit/provider/powershell_script_spec.rb +106 -0
- data/spec/unit/provider/registry_key_spec.rb +12 -0
- data/spec/unit/provider/remote_directory_spec.rb +1 -2
- data/spec/unit/provider/service/aix_service_spec.rb +3 -3
- data/spec/unit/provider/service/gentoo_service_spec.rb +4 -4
- data/spec/unit/provider/service/macosx_spec.rb +4 -4
- data/spec/unit/provider/service/openbsd_service_spec.rb +10 -8
- data/spec/unit/provider/service/redhat_spec.rb +88 -8
- data/spec/unit/provider/service/upstart_service_spec.rb +11 -7
- data/spec/unit/provider/service/windows_spec.rb +211 -200
- data/spec/unit/provider/subversion_spec.rb +50 -31
- data/spec/unit/provider/template/content_spec.rb +93 -2
- data/spec/unit/provider/user/solaris_spec.rb +66 -9
- data/spec/unit/provider_resolver_spec.rb +707 -650
- data/spec/unit/provider_spec.rb +1 -3
- data/spec/unit/recipe_spec.rb +0 -4
- data/spec/unit/resource/deploy_spec.rb +7 -1
- data/spec/unit/resource/dsc_script_spec.rb +4 -0
- data/spec/unit/resource/file/verification_spec.rb +33 -5
- data/spec/unit/resource/{powershell_spec.rb → powershell_script_spec.rb} +17 -13
- data/spec/unit/resource/service_spec.rb +4 -4
- data/spec/unit/resource/subversion_spec.rb +4 -0
- data/spec/unit/resource/yum_package_spec.rb +10 -1
- data/spec/unit/resource_spec.rb +2 -2
- data/spec/unit/run_context/child_run_context_spec.rb +133 -0
- data/spec/unit/run_context_spec.rb +7 -0
- data/spec/unit/run_list/versioned_recipe_list_spec.rb +5 -0
- data/spec/unit/win32/registry_spec.rb +394 -0
- data/tasks/external_tests.rb +47 -23
- data/tasks/maintainers.rb +155 -14
- metadata +64 -53
- data/lib/chef/knife/bootstrap/templates/archlinux-gems.erb +0 -76
- data/lib/chef/knife/bootstrap/templates/chef-aix.erb +0 -72
- data/spec/unit/provider/powershell_spec.rb +0 -80
- data/spec/unit/registry_helper_spec.rb +0 -376
- data/spec/unit/workstation_config_loader_spec.rb +0 -283
@@ -27,6 +27,7 @@ describe Chef::Provider::Subversion do
|
|
27
27
|
@resource.revision "12345"
|
28
28
|
@resource.svn_arguments(false)
|
29
29
|
@resource.svn_info_args(false)
|
30
|
+
@resource.svn_binary "svn"
|
30
31
|
@node = Chef::Node.new
|
31
32
|
@events = Chef::EventDispatch::Dispatcher.new
|
32
33
|
@run_context = Chef::RunContext.new(@node, {}, @events)
|
@@ -63,28 +64,18 @@ describe Chef::Provider::Subversion do
|
|
63
64
|
"Last Changed Rev: 11410\n" + # Last Changed Rev is preferred to Revision
|
64
65
|
"Last Changed Date: 2009-03-25 06:09:56 -0600 (Wed, 25 Mar 2009)\n\n"
|
65
66
|
expect(::File).to receive(:exist?).at_least(1).times.with("/my/deploy/dir/.svn").and_return(true)
|
66
|
-
|
67
|
-
expect(
|
68
|
-
|
69
|
-
allow(@stderr).to receive(:string).and_return("")
|
70
|
-
allow(@exitstatus).to receive(:exitstatus).and_return(0)
|
71
|
-
expected_command = ["svn info", {:cwd=>"/my/deploy/dir"}]
|
72
|
-
expect(@provider).to receive(:popen4).with(*expected_command).
|
73
|
-
and_yield("no-pid", "no-stdin", @stdout,@stderr).
|
74
|
-
and_return(@exitstatus)
|
67
|
+
expected_command = ["svn info", {:cwd => '/my/deploy/dir', :returns => [0,1]}]
|
68
|
+
expect(@provider).to receive(:shell_out!).with(*expected_command).
|
69
|
+
and_return(double("ShellOut result", :stdout => example_svn_info, :stderr => ""))
|
75
70
|
expect(@provider.find_current_revision).to eql("11410")
|
76
71
|
end
|
77
72
|
|
78
73
|
it "gives nil as the current revision if the deploy dir isn't a SVN working copy" do
|
79
74
|
example_svn_info = "svn: '/tmp/deploydir' is not a working copy\n"
|
80
75
|
expect(::File).to receive(:exist?).with("/my/deploy/dir/.svn").and_return(true)
|
81
|
-
|
82
|
-
expect(
|
83
|
-
|
84
|
-
allow(@stderr).to receive(:string).and_return("")
|
85
|
-
allow(@exitstatus).to receive(:exitstatus).and_return(1)
|
86
|
-
expect(@provider).to receive(:popen4).and_yield("no-pid", "no-stdin", @stdout,@stderr).
|
87
|
-
and_return(@exitstatus)
|
76
|
+
expected_command = ["svn info", {:cwd => '/my/deploy/dir', :returns => [0,1]}]
|
77
|
+
expect(@provider).to receive(:shell_out!).with(*expected_command).
|
78
|
+
and_return(double("ShellOut result", :stdout => example_svn_info, :stderr => ""))
|
88
79
|
expect(@provider.find_current_revision).to be_nil
|
89
80
|
end
|
90
81
|
|
@@ -127,28 +118,20 @@ describe Chef::Provider::Subversion do
|
|
127
118
|
"Last Changed Author: codeninja\n" +
|
128
119
|
"Last Changed Rev: 11410\n" + # Last Changed Rev is preferred to Revision
|
129
120
|
"Last Changed Date: 2009-03-25 06:09:56 -0600 (Wed, 25 Mar 2009)\n\n"
|
130
|
-
exitstatus = double("exitstatus")
|
131
|
-
allow(exitstatus).to receive(:exitstatus).and_return(0)
|
132
121
|
@resource.revision "HEAD"
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
expect(@provider).to receive(:popen4).with(*expected_command).
|
137
|
-
and_yield("no-pid","no-stdin",@stdout,@stderr).
|
138
|
-
and_return(exitstatus)
|
122
|
+
expected_command = ["svn info http://svn.example.org/trunk/ --no-auth-cache -rHEAD", {:cwd => '/my/deploy/dir', :returns => [0,1]}]
|
123
|
+
expect(@provider).to receive(:shell_out!).with(*expected_command).
|
124
|
+
and_return(double("ShellOut result", :stdout => example_svn_info, :stderr => ""))
|
139
125
|
expect(@provider.revision_int).to eql("11410")
|
140
126
|
end
|
141
127
|
|
142
128
|
it "returns a helpful message if data from `svn info` can't be parsed" do
|
143
129
|
example_svn_info = "some random text from an error message\n"
|
144
|
-
exitstatus = double("exitstatus")
|
145
|
-
allow(exitstatus).to receive(:exitstatus).and_return(0)
|
146
130
|
@resource.revision "HEAD"
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
expect {@provider.revision_int}.to raise_error(RuntimeError, "Could not parse `svn info` data: some random text from an error message")
|
131
|
+
expected_command = ["svn info http://svn.example.org/trunk/ --no-auth-cache -rHEAD", {:cwd => '/my/deploy/dir', :returns => [0,1]}]
|
132
|
+
expect(@provider).to receive(:shell_out!).with(*expected_command).
|
133
|
+
and_return(double("ShellOut result", :stdout => example_svn_info, :stderr => ""))
|
134
|
+
expect {@provider.revision_int}.to raise_error(RuntimeError, "Could not parse `svn info` data: some random text from an error message\n")
|
152
135
|
|
153
136
|
end
|
154
137
|
|
@@ -277,4 +260,40 @@ describe Chef::Provider::Subversion do
|
|
277
260
|
expect(@resource).to be_updated
|
278
261
|
end
|
279
262
|
|
263
|
+
context "selects the correct svn binary" do
|
264
|
+
before do
|
265
|
+
end
|
266
|
+
|
267
|
+
it "selects 'svn' as the binary by default" do
|
268
|
+
@resource.svn_binary nil
|
269
|
+
allow(ChefConfig).to receive(:windows?) { false }
|
270
|
+
expect(@provider).to receive(:svn_binary).and_return('svn')
|
271
|
+
expect(@provider.export_command).to eql(
|
272
|
+
'svn export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir')
|
273
|
+
end
|
274
|
+
|
275
|
+
it "selects an svn binary with an exe extension on windows" do
|
276
|
+
@resource.svn_binary nil
|
277
|
+
allow(ChefConfig).to receive(:windows?) { true }
|
278
|
+
expect(@provider).to receive(:svn_binary).and_return('svn.exe')
|
279
|
+
expect(@provider.export_command).to eql(
|
280
|
+
'svn.exe export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir')
|
281
|
+
end
|
282
|
+
|
283
|
+
it "uses a custom svn binary as part of the svn command" do
|
284
|
+
@resource.svn_binary 'teapot'
|
285
|
+
expect(@provider).to receive(:svn_binary).and_return('teapot')
|
286
|
+
expect(@provider.export_command).to eql(
|
287
|
+
'teapot export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir')
|
288
|
+
end
|
289
|
+
|
290
|
+
it "wraps custom svn binary with quotes if it contains whitespace" do
|
291
|
+
@resource.svn_binary 'c:/program files (x86)/subversion/svn.exe'
|
292
|
+
expect(@provider).to receive(:svn_binary).and_return('c:/program files (x86)/subversion/svn.exe')
|
293
|
+
expect(@provider.export_command).to eql(
|
294
|
+
'"c:/program files (x86)/subversion/svn.exe" export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir')
|
295
|
+
end
|
296
|
+
|
297
|
+
end
|
298
|
+
|
280
299
|
end
|
@@ -20,10 +20,24 @@ require 'spec_helper'
|
|
20
20
|
|
21
21
|
describe Chef::Provider::Template::Content do
|
22
22
|
|
23
|
+
let(:enclosing_directory) {
|
24
|
+
canonicalize_path(Dir.mktmpdir)
|
25
|
+
}
|
26
|
+
|
27
|
+
let(:resource_path) {
|
28
|
+
canonicalize_path(File.expand_path(File.join(enclosing_directory, "openldap_stuff.conf")))
|
29
|
+
}
|
30
|
+
|
23
31
|
let(:new_resource) do
|
24
32
|
double("Chef::Resource::Template (new)",
|
25
33
|
:cookbook_name => 'openldap',
|
34
|
+
:recipe_name => 'default',
|
35
|
+
:source_line => "/Users/lamont/solo/cookbooks/openldap/recipes/default.rb:2:in `from_file'",
|
36
|
+
:source_line_file => "/Users/lamont/solo/cookbooks/openldap/recipes/default.rb",
|
37
|
+
:source_line_number => "2",
|
26
38
|
:source => 'openldap_stuff.conf.erb',
|
39
|
+
:name => 'openldap_stuff.conf',
|
40
|
+
:path => resource_path,
|
27
41
|
:local => false,
|
28
42
|
:cookbook => nil,
|
29
43
|
:variables => {},
|
@@ -32,7 +46,10 @@ describe Chef::Provider::Template::Content do
|
|
32
46
|
:helper_modules => [])
|
33
47
|
end
|
34
48
|
|
35
|
-
let(:
|
49
|
+
let(:rendered_file_locations) {
|
50
|
+
[Dir.tmpdir + '/openldap_stuff.conf',
|
51
|
+
enclosing_directory + '/openldap_stuff.conf']
|
52
|
+
}
|
36
53
|
|
37
54
|
let(:run_context) do
|
38
55
|
cookbook_repo = File.expand_path(File.join(CHEF_SPEC_DATA, "cookbooks"))
|
@@ -50,7 +67,9 @@ describe Chef::Provider::Template::Content do
|
|
50
67
|
end
|
51
68
|
|
52
69
|
after do
|
53
|
-
|
70
|
+
rendered_file_locations.each do |file|
|
71
|
+
FileUtils.rm(file) if ::File.exist?(file)
|
72
|
+
end
|
54
73
|
end
|
55
74
|
|
56
75
|
it "finds the template file in the cookbook cache if it isn't local" do
|
@@ -70,9 +89,81 @@ describe Chef::Provider::Template::Content do
|
|
70
89
|
expect(content.template_location).to eq(CHEF_SPEC_DATA + '/cookbooks/openldap/templates/default/test.erb')
|
71
90
|
end
|
72
91
|
|
92
|
+
it "returns a tempfile in the tempdir when :file_staging_uses_destdir is not set" do
|
93
|
+
Chef::Config[:file_staging_uses_destdir] = false
|
94
|
+
expect(content.tempfile.path.start_with?(Dir::tmpdir)).to be true
|
95
|
+
expect(canonicalize_path(content.tempfile.path).start_with?(enclosing_directory)).to be false
|
96
|
+
end
|
97
|
+
|
98
|
+
it "returns a tempfile in the destdir when :file_staging_uses_destdir is set" do
|
99
|
+
Chef::Config[:file_staging_uses_destdir] = true
|
100
|
+
expect(canonicalize_path(content.tempfile.path).start_with?(enclosing_directory)).to be true
|
101
|
+
end
|
102
|
+
|
103
|
+
context "when creating a tempfile in destdir fails" do
|
104
|
+
let(:enclosing_directory) {
|
105
|
+
canonicalize_path("/nonexisting/path")
|
106
|
+
}
|
107
|
+
|
108
|
+
it "returns a tempfile in the tempdir when :file_deployment_uses_destdir is set to :auto" do
|
109
|
+
Chef::Config[:file_staging_uses_destdir] = :auto
|
110
|
+
expect(content.tempfile.path.start_with?(Dir::tmpdir)).to be true
|
111
|
+
expect(canonicalize_path(content.tempfile.path).start_with?(enclosing_directory)).to be false
|
112
|
+
end
|
113
|
+
|
114
|
+
it "fails when :file_desployment_uses_destdir is set" do
|
115
|
+
Chef::Config[:file_staging_uses_destdir] = true
|
116
|
+
expect{content.tempfile}.to raise_error(Chef::Exceptions::FileContentStagingError)
|
117
|
+
end
|
118
|
+
|
119
|
+
it "returns a tempfile in the tempdir when :file_desployment_uses_destdir is not set" do
|
120
|
+
expect(content.tempfile.path.start_with?(Dir::tmpdir)).to be true
|
121
|
+
expect(canonicalize_path(content.tempfile.path).start_with?(enclosing_directory)).to be false
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
73
125
|
it "creates the template with the rendered content" do
|
74
126
|
run_context.node.normal[:slappiness] = "a warm gun"
|
75
127
|
expect(IO.read(content.tempfile.path)).to eq("slappiness is a warm gun")
|
76
128
|
end
|
77
129
|
|
130
|
+
describe "when using location helpers" do
|
131
|
+
let(:new_resource) do
|
132
|
+
double("Chef::Resource::Template (new)",
|
133
|
+
:cookbook_name => 'openldap',
|
134
|
+
:recipe_name => 'default',
|
135
|
+
:source_line => CHEF_SPEC_DATA + "/cookbooks/openldap/recipes/default.rb:2:in `from_file'",
|
136
|
+
:source_line_file => CHEF_SPEC_DATA + "/cookbooks/openldap/recipes/default.rb",
|
137
|
+
:source_line_number => "2",
|
138
|
+
:source => 'helpers.erb',
|
139
|
+
:name => 'helpers.erb',
|
140
|
+
:path => CHEF_SPEC_DATA + '/cookbooks/openldap/templates/default/helpers.erb',
|
141
|
+
:local => false,
|
142
|
+
:cookbook => nil,
|
143
|
+
:variables => {},
|
144
|
+
:inline_helper_blocks => {},
|
145
|
+
:inline_helper_modules => [],
|
146
|
+
:helper_modules => [])
|
147
|
+
end
|
148
|
+
|
149
|
+
it "creates the template with the rendered content" do
|
150
|
+
expect(IO.read(content.tempfile.path)).to eql <<EOF
|
151
|
+
openldap
|
152
|
+
default
|
153
|
+
#{CHEF_SPEC_DATA}/cookbooks/openldap/recipes/default.rb:2:in `from_file'
|
154
|
+
#{CHEF_SPEC_DATA}/cookbooks/openldap/recipes/default.rb
|
155
|
+
2
|
156
|
+
helpers.erb
|
157
|
+
#{CHEF_SPEC_DATA}/cookbooks/openldap/templates/default/helpers.erb
|
158
|
+
openldap
|
159
|
+
default
|
160
|
+
#{CHEF_SPEC_DATA}/cookbooks/openldap/recipes/default.rb:2:in `from_file'
|
161
|
+
#{CHEF_SPEC_DATA}/cookbooks/openldap/recipes/default.rb
|
162
|
+
2
|
163
|
+
helpers.erb
|
164
|
+
#{CHEF_SPEC_DATA}/cookbooks/openldap/templates/default/helpers.erb
|
165
|
+
EOF
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
78
169
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
3
|
# Author:: Daniel DeLeo (<dan@opscode.com>)
|
4
|
+
# Author:: Dave Eddy (<dave@daveeddy.com>)
|
4
5
|
# Copyright:: Copyright (c) 2008, 2010 Opscode, Inc.
|
6
|
+
# Copyright:: Copyright (c) 2015, Dave Eddy
|
5
7
|
#
|
6
8
|
# License:: Apache License, Version 2.0
|
7
9
|
#
|
@@ -18,6 +20,9 @@
|
|
18
20
|
# limitations under the License.
|
19
21
|
#
|
20
22
|
|
23
|
+
ShellCmdResult = Struct.new(:stdout, :stderr, :exitstatus)
|
24
|
+
|
25
|
+
require 'mixlib/shellout'
|
21
26
|
require 'spec_helper'
|
22
27
|
|
23
28
|
describe Chef::Provider::User::Solaris do
|
@@ -31,15 +36,6 @@ describe Chef::Provider::User::Solaris do
|
|
31
36
|
p
|
32
37
|
end
|
33
38
|
|
34
|
-
supported_useradd_options = {
|
35
|
-
'comment' => "-c",
|
36
|
-
'gid' => "-g",
|
37
|
-
'uid' => "-u",
|
38
|
-
'shell' => "-s"
|
39
|
-
}
|
40
|
-
|
41
|
-
include_examples "a useradd-based user provider", supported_useradd_options
|
42
|
-
|
43
39
|
describe "when we want to set a password" do
|
44
40
|
before(:each) do
|
45
41
|
@node = Chef::Node.new
|
@@ -77,4 +73,65 @@ describe Chef::Provider::User::Solaris do
|
|
77
73
|
end
|
78
74
|
end
|
79
75
|
|
76
|
+
describe 'when managing user locked status' do
|
77
|
+
before(:each) do
|
78
|
+
@node = Chef::Node.new
|
79
|
+
@events = Chef::EventDispatch::Dispatcher.new
|
80
|
+
@run_context = Chef::RunContext.new(@node, {}, @events)
|
81
|
+
|
82
|
+
@new_resource = Chef::Resource::User.new('dave')
|
83
|
+
@current_resource = @new_resource.dup
|
84
|
+
|
85
|
+
@provider = Chef::Provider::User::Solaris.new(@new_resource, @run_context)
|
86
|
+
@provider.current_resource = @current_resource
|
87
|
+
end
|
88
|
+
describe 'when determining if the user is locked' do
|
89
|
+
|
90
|
+
# locked shadow lines
|
91
|
+
[
|
92
|
+
'dave:LK:::::::',
|
93
|
+
'dave:*LK*:::::::',
|
94
|
+
'dave:*LK*foobar:::::::',
|
95
|
+
'dave:*LK*bahamas10:::::::',
|
96
|
+
'dave:*LK*L....:::::::',
|
97
|
+
].each do |shadow|
|
98
|
+
it "should return true if user is locked with #{shadow}" do
|
99
|
+
shell_return = ShellCmdResult.new(shadow + "\n", '', 0)
|
100
|
+
expect(provider).to receive(:shell_out!).with('getent', 'shadow', @new_resource.username).and_return(shell_return)
|
101
|
+
expect(provider.check_lock).to eql(true)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
# unlocked shadow lines
|
106
|
+
[
|
107
|
+
'dave:NP:::::::',
|
108
|
+
'dave:*NP*:::::::',
|
109
|
+
'dave:foobar:::::::',
|
110
|
+
'dave:bahamas10:::::::',
|
111
|
+
'dave:L...:::::::',
|
112
|
+
].each do |shadow|
|
113
|
+
it "should return false if user is unlocked with #{shadow}" do
|
114
|
+
shell_return = ShellCmdResult.new(shadow + "\n", '', 0)
|
115
|
+
expect(provider).to receive(:shell_out!).with('getent', 'shadow', @new_resource.username).and_return(shell_return)
|
116
|
+
expect(provider.check_lock).to eql(false)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
describe 'when locking the user' do
|
122
|
+
it 'should run passwd -l with the new resources username' do
|
123
|
+
shell_return = ShellCmdResult.new('', '', 0)
|
124
|
+
expect(provider).to receive(:shell_out!).with('passwd', '-l', @new_resource.username).and_return(shell_return)
|
125
|
+
provider.lock_user
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
describe 'when unlocking the user' do
|
130
|
+
it 'should run passwd -u with the new resources username' do
|
131
|
+
shell_return = ShellCmdResult.new('', '', 0)
|
132
|
+
expect(provider).to receive(:shell_out!).with('passwd', '-u', @new_resource.username).and_return(shell_return)
|
133
|
+
provider.unlock_user
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
80
137
|
end
|
@@ -20,6 +20,9 @@ require 'spec_helper'
|
|
20
20
|
require 'chef/mixin/convert_to_class_name'
|
21
21
|
require 'chef/provider_resolver'
|
22
22
|
require 'chef/platform/service_helpers'
|
23
|
+
require 'support/shared/integration/integration_helper'
|
24
|
+
require 'tmpdir'
|
25
|
+
require 'fileutils'
|
23
26
|
|
24
27
|
include Chef::Mixin::ConvertToClassName
|
25
28
|
|
@@ -27,833 +30,887 @@ include Chef::Mixin::ConvertToClassName
|
|
27
30
|
#module Chef::Provider
|
28
31
|
|
29
32
|
describe Chef::ProviderResolver do
|
33
|
+
include IntegrationSupport
|
30
34
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
let(:node) do
|
36
|
-
node = Chef::Node.new
|
37
|
-
node.automatic[:os] = os
|
38
|
-
node.automatic[:platform_family] = platform_family
|
39
|
-
node.automatic[:platform] = platform
|
40
|
-
node.automatic[:platform_version] = platform_version
|
41
|
-
node.automatic[:kernel] = { machine: 'i386' }
|
42
|
-
node
|
43
|
-
end
|
44
|
-
let(:run_context) { Chef::RunContext.new(node, nil, nil) }
|
45
|
-
|
46
|
-
let(:provider_resolver) { Chef::ProviderResolver.new(node, resource, action) }
|
47
|
-
let(:resolved_provider) do
|
48
|
-
begin
|
49
|
-
resource ? resource.provider_for_action(action).class : nil
|
50
|
-
rescue Chef::Exceptions::ProviderNotFound
|
51
|
-
nil
|
35
|
+
# Root the filesystem under a temp directory so Chef.path_to will point at it
|
36
|
+
when_the_repository "is empty" do
|
37
|
+
before do
|
38
|
+
allow(Chef).to receive(:path_to) { |path| File.join(path_to(""), path) }
|
52
39
|
end
|
53
|
-
end
|
54
40
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
41
|
+
let(:resource_name) { :service }
|
42
|
+
let(:provider) { nil }
|
43
|
+
let(:action) { :start }
|
44
|
+
|
45
|
+
let(:node) do
|
46
|
+
node = Chef::Node.new
|
47
|
+
node.automatic[:os] = os
|
48
|
+
node.automatic[:platform_family] = platform_family
|
49
|
+
node.automatic[:platform] = platform
|
50
|
+
node.automatic[:platform_version] = platform_version
|
51
|
+
node.automatic[:kernel] = { machine: 'i386' }
|
52
|
+
node
|
60
53
|
end
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
Array(platform).each do |platform|
|
70
|
-
Array(platform_version).each do |platform_version|
|
71
|
-
on_one_platform(platform, platform_version, platform_family || platform, os || platform_family || platform, *tags, &block)
|
54
|
+
let(:run_context) { Chef::RunContext.new(node, nil, nil) }
|
55
|
+
|
56
|
+
let(:provider_resolver) { Chef::ProviderResolver.new(node, resource, action) }
|
57
|
+
let(:resolved_provider) do
|
58
|
+
begin
|
59
|
+
resource ? resource.provider_for_action(action).class : nil
|
60
|
+
rescue Chef::Exceptions::ProviderNotFound
|
61
|
+
nil
|
72
62
|
end
|
73
63
|
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def self.on_one_platform(platform, platform_version, platform_family, os, *tags, &block)
|
77
|
-
describe "on #{platform} #{platform_version}, platform_family: #{platform_family}, os: #{os}", *tags do
|
78
|
-
let(:os) { os }
|
79
|
-
let(:platform) { platform }
|
80
|
-
let(:platform_family) { platform_family }
|
81
|
-
let(:platform_version) { platform_version }
|
82
64
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
65
|
+
let(:service_name) { "test" }
|
66
|
+
let(:resource) do
|
67
|
+
resource_class = Chef::ResourceResolver.resolve(resource_name, node: node)
|
68
|
+
if resource_class
|
69
|
+
resource = resource_class.new(service_name, run_context)
|
70
|
+
resource.provider = provider if provider
|
71
|
+
end
|
72
|
+
resource
|
89
73
|
end
|
90
|
-
end
|
91
74
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
Array(expected).each do |p|
|
101
|
-
if p.is_a?(Class) && p <= Chef::Provider
|
102
|
-
expected_provider = p
|
103
|
-
elsif p.is_a?(Class) && p <= Chef::Resource
|
104
|
-
expected_resource = p
|
105
|
-
else
|
106
|
-
tags << p
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
if expected_resource && expected_provider
|
111
|
-
it "'#{name}' resolves to resource #{expected_resource} and provider #{expected_provider}", *tags do
|
112
|
-
expect(resource.class).to eql(expected_resource)
|
113
|
-
provider = double(expected_provider, class: expected_provider)
|
114
|
-
expect(provider).to receive(:action=).with(action)
|
115
|
-
expect(expected_provider).to receive(:new).with(resource, run_context).and_return(provider)
|
116
|
-
expect(resolved_provider).to eql(expected_provider)
|
117
|
-
end
|
118
|
-
elsif expected_provider
|
119
|
-
it "'#{name}' resolves to provider #{expected_provider}", *tags do
|
120
|
-
provider = double(expected_provider)
|
121
|
-
expect(provider).to receive(:action=).with(action)
|
122
|
-
expect(expected_provider).to receive(:new).with(resource, run_context).and_return(provider)
|
123
|
-
expect(resolved_provider).to eql(expected_provider)
|
124
|
-
end
|
125
|
-
else
|
126
|
-
it "'#{name}' fails to resolve (since #{name.inspect} is unsupported on #{platform} #{platform_version})", *tags do
|
127
|
-
expect(resolved_provider).to be_nil
|
128
|
-
end
|
75
|
+
def self.on_platform(platform, *tags,
|
76
|
+
platform_version: '11.0.1',
|
77
|
+
platform_family: nil,
|
78
|
+
os: nil,
|
79
|
+
&block)
|
80
|
+
Array(platform).each do |platform|
|
81
|
+
Array(platform_version).each do |platform_version|
|
82
|
+
on_one_platform(platform, platform_version, platform_family || platform, os || platform_family || platform, *tags, &block)
|
129
83
|
end
|
130
84
|
end
|
131
85
|
end
|
132
|
-
end
|
133
|
-
|
134
|
-
describe "resolving service resource" do
|
135
|
-
def stub_service_providers(*services)
|
136
|
-
services ||= []
|
137
|
-
allow(Chef::Platform::ServiceHelpers).to receive(:service_resource_providers)
|
138
|
-
.and_return(services)
|
139
|
-
end
|
140
|
-
|
141
|
-
def stub_service_configs(*configs)
|
142
|
-
configs ||= []
|
143
|
-
allow(Chef::Platform::ServiceHelpers).to receive(:config_for_service).with("ntp")
|
144
|
-
.and_return(configs)
|
145
|
-
end
|
146
|
-
|
147
|
-
before do
|
148
|
-
allow(resource).to receive(:service_name).and_return("ntp")
|
149
|
-
end
|
150
|
-
|
151
|
-
shared_examples_for "an ubuntu platform with upstart, update-rc.d and systemd" do
|
152
|
-
before do
|
153
|
-
stub_service_providers(:debian, :invokercd, :upstart, :systemd)
|
154
|
-
end
|
155
86
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
it "when both SysV and Upstart scripts exist, it returns a Service::Upstart provider" do
|
163
|
-
allow(Chef::Platform::ServiceHelpers).to receive(:config_for_service).with("ntp")
|
164
|
-
.and_return( [ :initd, :upstart, :systemd ] )
|
165
|
-
expect(resolved_provider).to eql(Chef::Provider::Service::Systemd)
|
166
|
-
end
|
87
|
+
def self.on_one_platform(platform, platform_version, platform_family, os, *tags, &block)
|
88
|
+
describe "on #{platform} #{platform_version}, platform_family: #{platform_family}, os: #{os}", *tags do
|
89
|
+
let(:os) { os }
|
90
|
+
let(:platform) { platform }
|
91
|
+
let(:platform_family) { platform_family }
|
92
|
+
let(:platform_version) { platform_version }
|
167
93
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
end
|
94
|
+
define_singleton_method(:os) { os }
|
95
|
+
define_singleton_method(:platform) { platform }
|
96
|
+
define_singleton_method(:platform_family) { platform_family }
|
97
|
+
define_singleton_method(:platform_version) { platform_version }
|
173
98
|
|
174
|
-
|
175
|
-
allow(Chef::Platform::ServiceHelpers).to receive(:config_for_service).with("ntp")
|
176
|
-
.and_return( [ :systemd ] )
|
177
|
-
expect(resolved_provider).to eql(Chef::Provider::Service::Systemd)
|
178
|
-
end
|
179
|
-
it "when only the SysV init script exists, it returns a Service::Debian provider" do
|
180
|
-
allow(Chef::Platform::ServiceHelpers).to receive(:config_for_service).with("ntp")
|
181
|
-
.and_return( [ :initd ] )
|
182
|
-
expect(resolved_provider).to eql(Chef::Provider::Service::Debian)
|
99
|
+
instance_eval(&block)
|
183
100
|
end
|
101
|
+
end
|
184
102
|
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
103
|
+
def self.expect_providers(**providers)
|
104
|
+
providers.each do |name, expected|
|
105
|
+
describe name.to_s do
|
106
|
+
let(:resource_name) { name }
|
107
|
+
|
108
|
+
tags = []
|
109
|
+
expected_provider = nil
|
110
|
+
expected_resource = nil
|
111
|
+
Array(expected).each do |p|
|
112
|
+
if p.is_a?(Class) && p <= Chef::Provider
|
113
|
+
expected_provider = p
|
114
|
+
elsif p.is_a?(Class) && p <= Chef::Resource
|
115
|
+
expected_resource = p
|
116
|
+
else
|
117
|
+
tags << p
|
118
|
+
end
|
119
|
+
end
|
190
120
|
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
121
|
+
if expected_resource && expected_provider
|
122
|
+
it "'#{name}' resolves to resource #{expected_resource} and provider #{expected_provider}", *tags do
|
123
|
+
expect(resource.class).to eql(expected_resource)
|
124
|
+
provider = double(expected_provider, class: expected_provider)
|
125
|
+
expect(provider).to receive(:action=).with(action)
|
126
|
+
expect(expected_provider).to receive(:new).with(resource, run_context).and_return(provider)
|
127
|
+
expect(resolved_provider).to eql(expected_provider)
|
128
|
+
end
|
129
|
+
elsif expected_provider
|
130
|
+
it "'#{name}' resolves to provider #{expected_provider}", *tags do
|
131
|
+
provider = double(expected_provider)
|
132
|
+
expect(provider).to receive(:action=).with(action)
|
133
|
+
expect(expected_provider).to receive(:new).with(resource, run_context).and_return(provider)
|
134
|
+
expect(resolved_provider).to eql(expected_provider)
|
135
|
+
end
|
136
|
+
else
|
137
|
+
it "'#{name}' fails to resolve (since #{name.inspect} is unsupported on #{platform} #{platform_version})", *tags do
|
138
|
+
expect(resolved_provider).to be_nil
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
195
142
|
end
|
143
|
+
end
|
196
144
|
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
145
|
+
describe "resolving service resource" do
|
146
|
+
def stub_service_providers(*services)
|
147
|
+
services.each do |service|
|
148
|
+
case service
|
149
|
+
when :debian
|
150
|
+
directory 'usr/sbin/update-rc.d'
|
151
|
+
when :invokercd
|
152
|
+
directory 'usr/sbin/invoke-rc.d'
|
153
|
+
when :insserv
|
154
|
+
directory 'sbin/insserv'
|
155
|
+
when :upstart
|
156
|
+
directory 'etc/init'
|
157
|
+
directory 'sbin/start'
|
158
|
+
when :redhat
|
159
|
+
directory 'sbin/chkconfig'
|
160
|
+
when :systemd
|
161
|
+
file 'bin/systemctl', ''
|
162
|
+
# Make systemctl executable
|
163
|
+
File.chmod(0755, path_to('bin/systemctl'))
|
164
|
+
# Windows doesn't respect executable bit, do this to let Windows users see if they've broken the resolver
|
165
|
+
allow(::File).to receive(:executable?) { |p| p == path_to('bin/systemctl') } if windows?
|
166
|
+
file 'proc/1/comm', "systemd\n"
|
167
|
+
mock_shellout_command("/bin/systemctl --all", stdout: "")
|
168
|
+
mock_shellout_command("/bin/systemctl list-unit-files", stdout: "")
|
169
|
+
else
|
170
|
+
raise ArgumentError, service
|
171
|
+
end
|
172
|
+
end
|
201
173
|
end
|
202
|
-
end
|
203
174
|
|
204
|
-
|
205
|
-
|
206
|
-
|
175
|
+
def stub_service_configs(*configs)
|
176
|
+
configs.each do |config|
|
177
|
+
case config
|
178
|
+
when :initd
|
179
|
+
file "etc/init.d/#{service_name}", ""
|
180
|
+
when :upstart
|
181
|
+
file "etc/init/#{service_name}.conf", ""
|
182
|
+
when :xinetd
|
183
|
+
file "etc/xinetd.d/#{service_name}", ""
|
184
|
+
when :etc_rcd
|
185
|
+
file "etc/rc.d/#{service_name}", ""
|
186
|
+
when :usr_local_etc_rcd
|
187
|
+
file "usr/local/etc/rc.d/#{service_name}", ""
|
188
|
+
when :systemd
|
189
|
+
file 'bin/systemctl', ''
|
190
|
+
# Make systemctl executable
|
191
|
+
File.chmod(0755, path_to("bin/systemctl"))
|
192
|
+
# Windows doesn't respect executable bit, do this to let Windows users see if they've broken the resolver
|
193
|
+
allow(::File).to receive(:executable?) { |p| p == path_to('bin/systemctl') } if windows?
|
194
|
+
file 'proc/1/comm', "systemd\n"
|
195
|
+
mock_shellout_command("/bin/systemctl --all", stdout: <<-EOM)
|
196
|
+
superv loaded
|
197
|
+
stinky something-else
|
198
|
+
#{service_name} loaded
|
199
|
+
blargh not-found
|
200
|
+
EOM
|
201
|
+
mock_shellout_command("/bin/systemctl list-unit-files", stdout: <<-EOM)
|
202
|
+
usuperv loaded
|
203
|
+
ustinky something-else
|
204
|
+
u#{service_name} loaded
|
205
|
+
ublargh not-found
|
206
|
+
EOM
|
207
|
+
else
|
208
|
+
raise ArgumentError, config
|
209
|
+
end
|
210
|
+
end
|
207
211
|
end
|
208
212
|
|
209
|
-
|
210
|
-
context "when only the SysV init script exists" do
|
213
|
+
shared_examples_for "an ubuntu platform with upstart, update-rc.d and systemd" do
|
211
214
|
before do
|
212
|
-
|
213
|
-
.and_return( [ :initd ] )
|
215
|
+
stub_service_providers(:debian, :invokercd, :upstart, :systemd)
|
214
216
|
end
|
215
217
|
|
216
|
-
it "
|
217
|
-
|
218
|
-
|
219
|
-
Chef::Provider::Service::Init,
|
220
|
-
Chef::Provider::Service::Invokercd,
|
221
|
-
Chef::Provider::Service::Upstart,
|
222
|
-
)
|
218
|
+
it "when only the SysV init script exists, it returns a Service::Debian provider" do
|
219
|
+
stub_service_configs(:initd, :systemd)
|
220
|
+
expect(resolved_provider).to eql(Chef::Provider::Service::Systemd)
|
223
221
|
end
|
224
222
|
|
225
|
-
it "
|
226
|
-
|
227
|
-
|
228
|
-
Chef::Provider::Service::Init,
|
229
|
-
Chef::Provider::Service::Invokercd,
|
230
|
-
)
|
231
|
-
expect(provider_resolver.supported_handlers).to_not include(
|
232
|
-
Chef::Provider::Service::Upstart,
|
233
|
-
)
|
223
|
+
it "when both SysV and Upstart scripts exist, it returns a Service::Upstart provider" do
|
224
|
+
stub_service_configs(:initd, :upstart, :systemd)
|
225
|
+
expect(resolved_provider).to eql(Chef::Provider::Service::Systemd)
|
234
226
|
end
|
235
227
|
|
236
|
-
it "returns a Service::
|
237
|
-
|
228
|
+
it "when only the Upstart script exists, it returns a Service::Upstart provider" do
|
229
|
+
stub_service_configs(:upstart, :systemd)
|
230
|
+
expect(resolved_provider).to eql(Chef::Provider::Service::Systemd)
|
238
231
|
end
|
239
|
-
end
|
240
232
|
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
allow(Chef::Platform::ServiceHelpers).to receive(:config_for_service).with("ntp")
|
245
|
-
.and_return( [ :initd, :upstart ] )
|
233
|
+
it "when both do not exist, it calls the old style provider resolver and returns a Debian Provider" do
|
234
|
+
stub_service_configs(:systemd)
|
235
|
+
expect(resolved_provider).to eql(Chef::Provider::Service::Systemd)
|
246
236
|
end
|
247
237
|
|
248
|
-
it "
|
249
|
-
|
250
|
-
|
251
|
-
Chef::Provider::Service::Init,
|
252
|
-
Chef::Provider::Service::Invokercd,
|
253
|
-
Chef::Provider::Service::Upstart,
|
254
|
-
)
|
238
|
+
it "when only the SysV init script exists, it returns a Service::Debian provider" do
|
239
|
+
stub_service_configs(:initd)
|
240
|
+
expect(resolved_provider).to eql(Chef::Provider::Service::Debian)
|
255
241
|
end
|
256
242
|
|
257
|
-
it "
|
258
|
-
|
259
|
-
|
260
|
-
Chef::Provider::Service::Init,
|
261
|
-
Chef::Provider::Service::Invokercd,
|
262
|
-
Chef::Provider::Service::Upstart,
|
263
|
-
)
|
243
|
+
it "when both SysV and Upstart scripts exist, it returns a Service::Upstart provider" do
|
244
|
+
stub_service_configs(:initd, :upstart)
|
245
|
+
expect(resolved_provider).to eql(Chef::Provider::Service::Upstart)
|
264
246
|
end
|
265
247
|
|
266
|
-
it "returns a Service::Upstart provider" do
|
248
|
+
it "when only the Upstart script exists, it returns a Service::Upstart provider" do
|
249
|
+
stub_service_configs(:upstart)
|
267
250
|
expect(resolved_provider).to eql(Chef::Provider::Service::Upstart)
|
268
251
|
end
|
252
|
+
|
253
|
+
it "when both do not exist, it calls the old style provider resolver and returns a Debian Provider" do
|
254
|
+
stub_service_configs
|
255
|
+
expect(resolved_provider).to eql(Chef::Provider::Service::Systemd)
|
256
|
+
end
|
269
257
|
end
|
270
258
|
|
271
|
-
|
272
|
-
context "when only the Upstart script exists" do
|
259
|
+
shared_examples_for "an ubuntu platform with upstart and update-rc.d" do
|
273
260
|
before do
|
274
|
-
|
275
|
-
.and_return( [ :upstart ] )
|
261
|
+
stub_service_providers(:debian, :invokercd, :upstart)
|
276
262
|
end
|
277
263
|
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
Chef::Provider::Service::Upstart,
|
284
|
-
)
|
285
|
-
end
|
264
|
+
# needs to be handled by the highest priority init.d handler
|
265
|
+
context "when only the SysV init script exists" do
|
266
|
+
before do
|
267
|
+
stub_service_configs(:initd)
|
268
|
+
end
|
286
269
|
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
)
|
296
|
-
end
|
270
|
+
it "enables init, invokercd, debian and upstart providers" do
|
271
|
+
expect(provider_resolver.enabled_handlers).to include(
|
272
|
+
Chef::Provider::Service::Debian,
|
273
|
+
Chef::Provider::Service::Init,
|
274
|
+
Chef::Provider::Service::Invokercd,
|
275
|
+
Chef::Provider::Service::Upstart,
|
276
|
+
)
|
277
|
+
end
|
297
278
|
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
279
|
+
it "supports all the enabled handlers except for upstart" do
|
280
|
+
expect(provider_resolver.supported_handlers).to include(
|
281
|
+
Chef::Provider::Service::Debian,
|
282
|
+
Chef::Provider::Service::Init,
|
283
|
+
Chef::Provider::Service::Invokercd,
|
284
|
+
)
|
285
|
+
expect(provider_resolver.supported_handlers).to_not include(
|
286
|
+
Chef::Provider::Service::Upstart,
|
287
|
+
)
|
288
|
+
end
|
302
289
|
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
allow(Chef::Platform::ServiceHelpers).to receive(:config_for_service).with("ntp")
|
307
|
-
.and_return( [ ] )
|
290
|
+
it "returns a Service::Debian provider" do
|
291
|
+
expect(resolved_provider).to eql(Chef::Provider::Service::Debian)
|
292
|
+
end
|
308
293
|
end
|
309
294
|
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
Chef::Provider::Service::Upstart,
|
316
|
-
)
|
317
|
-
end
|
295
|
+
# on ubuntu this must be handled by upstart, the init script will exit 1 and fail
|
296
|
+
context "when both SysV and Upstart scripts exist" do
|
297
|
+
before do
|
298
|
+
stub_service_configs(:initd, :upstart)
|
299
|
+
end
|
318
300
|
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
301
|
+
it "enables init, invokercd, debian and upstart providers" do
|
302
|
+
expect(provider_resolver.enabled_handlers).to include(
|
303
|
+
Chef::Provider::Service::Debian,
|
304
|
+
Chef::Provider::Service::Init,
|
305
|
+
Chef::Provider::Service::Invokercd,
|
306
|
+
Chef::Provider::Service::Upstart,
|
307
|
+
)
|
308
|
+
end
|
327
309
|
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
310
|
+
it "supports all the enabled handlers" do
|
311
|
+
expect(provider_resolver.supported_handlers).to include(
|
312
|
+
Chef::Provider::Service::Debian,
|
313
|
+
Chef::Provider::Service::Init,
|
314
|
+
Chef::Provider::Service::Invokercd,
|
315
|
+
Chef::Provider::Service::Upstart,
|
316
|
+
)
|
317
|
+
end
|
333
318
|
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
stub_service_providers(:debian, :invokercd, :insserv)
|
319
|
+
it "returns a Service::Upstart provider" do
|
320
|
+
expect(resolved_provider).to eql(Chef::Provider::Service::Upstart)
|
321
|
+
end
|
338
322
|
end
|
339
323
|
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
324
|
+
# this case is a pure-upstart script which is easy
|
325
|
+
context "when only the Upstart script exists" do
|
326
|
+
before do
|
327
|
+
stub_service_configs(:upstart)
|
328
|
+
end
|
345
329
|
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
330
|
+
it "enables init, invokercd, debian and upstart providers" do
|
331
|
+
expect(provider_resolver.enabled_handlers).to include(
|
332
|
+
Chef::Provider::Service::Debian,
|
333
|
+
Chef::Provider::Service::Init,
|
334
|
+
Chef::Provider::Service::Invokercd,
|
335
|
+
Chef::Provider::Service::Upstart,
|
336
|
+
)
|
337
|
+
end
|
352
338
|
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
339
|
+
it "supports only the upstart handler" do
|
340
|
+
expect(provider_resolver.supported_handlers).to include(
|
341
|
+
Chef::Provider::Service::Upstart,
|
342
|
+
)
|
343
|
+
expect(provider_resolver.supported_handlers).to_not include(
|
344
|
+
Chef::Provider::Service::Debian,
|
345
|
+
Chef::Provider::Service::Init,
|
346
|
+
Chef::Provider::Service::Invokercd,
|
347
|
+
)
|
348
|
+
end
|
357
349
|
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
expect(resolved_provider).to eql(Chef::Provider::Service::Insserv)
|
350
|
+
it "returns a Service::Upstart provider" do
|
351
|
+
expect(resolved_provider).to eql(Chef::Provider::Service::Upstart)
|
352
|
+
end
|
362
353
|
end
|
363
354
|
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
355
|
+
# this case is important to get correct for why-run when no config is setup
|
356
|
+
context "when both do not exist" do
|
357
|
+
before do
|
358
|
+
stub_service_configs
|
359
|
+
end
|
369
360
|
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
361
|
+
it "enables init, invokercd, debian and upstart providers" do
|
362
|
+
expect(provider_resolver.enabled_handlers).to include(
|
363
|
+
Chef::Provider::Service::Debian,
|
364
|
+
Chef::Provider::Service::Init,
|
365
|
+
Chef::Provider::Service::Invokercd,
|
366
|
+
Chef::Provider::Service::Upstart,
|
367
|
+
)
|
368
|
+
end
|
375
369
|
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
370
|
+
it "no providers claim to support the resource" do
|
371
|
+
expect(provider_resolver.supported_handlers).to_not include(
|
372
|
+
Chef::Provider::Service::Upstart,
|
373
|
+
Chef::Provider::Service::Debian,
|
374
|
+
Chef::Provider::Service::Init,
|
375
|
+
Chef::Provider::Service::Invokercd,
|
376
|
+
)
|
377
|
+
end
|
378
|
+
|
379
|
+
it "returns a Debian Provider" do
|
380
|
+
expect(resolved_provider).to eql(Chef::Provider::Service::Upstart)
|
381
|
+
end
|
380
382
|
end
|
381
383
|
end
|
382
|
-
end
|
383
384
|
|
384
|
-
|
385
|
-
|
386
|
-
|
385
|
+
shared_examples_for "a debian platform using the insserv provider" do
|
386
|
+
context "with a default install" do
|
387
|
+
before do
|
388
|
+
stub_service_providers(:debian, :invokercd, :insserv)
|
389
|
+
end
|
387
390
|
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
+
it "uses the Service::Insserv Provider to manage sysv init scripts" do
|
392
|
+
stub_service_configs(:initd)
|
393
|
+
expect(resolved_provider).to eql(Chef::Provider::Service::Insserv)
|
394
|
+
end
|
391
395
|
|
392
|
-
|
393
|
-
|
394
|
-
|
396
|
+
it "uses the Service::Insserv Provider when there is no config" do
|
397
|
+
stub_service_configs
|
398
|
+
expect(resolved_provider).to eql(Chef::Provider::Service::Insserv)
|
399
|
+
end
|
400
|
+
end
|
395
401
|
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
402
|
+
context "when the user has installed upstart" do
|
403
|
+
before do
|
404
|
+
stub_service_providers(:debian, :invokercd, :insserv, :upstart)
|
405
|
+
end
|
400
406
|
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
407
|
+
it "when only the SysV init script exists, it returns an Insserv provider" do
|
408
|
+
stub_service_configs(:initd)
|
409
|
+
expect(resolved_provider).to eql(Chef::Provider::Service::Insserv)
|
410
|
+
end
|
411
|
+
|
412
|
+
it "when both SysV and Upstart scripts exist, it returns a Service::Upstart provider" do
|
413
|
+
stub_service_configs(:initd, :upstart)
|
414
|
+
expect(resolved_provider).to eql(Chef::Provider::Service::Upstart)
|
415
|
+
end
|
416
|
+
|
417
|
+
it "when only the Upstart script exists, it returns a Service::Upstart provider" do
|
418
|
+
stub_service_configs(:upstart)
|
419
|
+
expect(resolved_provider).to eql(Chef::Provider::Service::Upstart)
|
420
|
+
end
|
405
421
|
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
422
|
+
it "when both do not exist, it calls the old style provider resolver and returns a Debian Provider" do
|
423
|
+
stub_service_configs
|
424
|
+
expect(resolved_provider).to eql(Chef::Provider::Service::Upstart)
|
425
|
+
end
|
426
|
+
end
|
411
427
|
end
|
412
428
|
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
429
|
+
on_platform "ubuntu", platform_version: "15.10", platform_family: "debian", os: "linux" do
|
430
|
+
it_behaves_like "an ubuntu platform with upstart, update-rc.d and systemd"
|
431
|
+
|
432
|
+
it "when the unit-files are missing and system-ctl list-unit-files returns an error" do
|
433
|
+
stub_service_providers(:debian, :invokercd, :upstart, :systemd)
|
434
|
+
stub_service_configs(:initd, :upstart)
|
435
|
+
mock_shellout_command("/bin/systemctl list-unit-files", exitstatus: 1)
|
436
|
+
expect(resolved_provider).to eql(Chef::Provider::Service::Upstart)
|
437
|
+
end
|
418
438
|
end
|
419
|
-
end
|
420
439
|
|
421
|
-
|
422
|
-
|
423
|
-
stub_service_providers
|
424
|
-
stub_service_configs
|
425
|
-
expect(resolved_provider).to eql(Chef::Provider::Service::Windows)
|
440
|
+
on_platform "ubuntu", platform_version: "14.10", platform_family: "debian", os: "linux" do
|
441
|
+
it_behaves_like "an ubuntu platform with upstart, update-rc.d and systemd"
|
426
442
|
end
|
427
443
|
|
428
|
-
|
429
|
-
|
430
|
-
stub_service_providers(:debian, :invokercd, :insserv, :upstart, :redhat, :systemd)
|
431
|
-
stub_service_configs(:initd, :upstart, :xinetd, :user_local_etc_rcd, :systemd)
|
432
|
-
expect(resolved_provider).to eql(Chef::Provider::Service::Windows)
|
444
|
+
on_platform "ubuntu", platform_version: "14.04", platform_family: "debian", os: "linux" do
|
445
|
+
it_behaves_like "an ubuntu platform with upstart and update-rc.d"
|
433
446
|
end
|
434
|
-
end
|
435
447
|
|
436
|
-
|
437
|
-
|
438
|
-
stub_service_providers
|
439
|
-
stub_service_configs
|
440
|
-
expect(resolved_provider).to eql(Chef::Provider::Service::Macosx)
|
448
|
+
on_platform "ubuntu", platform_version: "10.04", platform_family: "debian", os: "linux" do
|
449
|
+
it_behaves_like "an ubuntu platform with upstart and update-rc.d"
|
441
450
|
end
|
442
451
|
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
stub_service_configs(:initd, :upstart, :xinetd, :user_local_etc_rcd, :systemd)
|
447
|
-
expect(resolved_provider).to eql(Chef::Provider::Service::Macosx)
|
452
|
+
# old debian uses the Debian provider (does not have insserv or upstart, or update-rc.d???)
|
453
|
+
on_platform "debian", platform_version: "4.0", os: "linux" do
|
454
|
+
#it_behaves_like "a debian platform using the debian provider"
|
448
455
|
end
|
449
|
-
end
|
450
456
|
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
stub_service_configs(:usr_local_etc_rcd)
|
455
|
-
expect(resolved_provider).to eql(Chef::Provider::Service::Freebsd)
|
457
|
+
# Debian replaced the debian provider with insserv in the FIXME:VERSION distro
|
458
|
+
on_platform "debian", platform_version: "7.0", os: "linux" do
|
459
|
+
it_behaves_like "a debian platform using the insserv provider"
|
456
460
|
end
|
457
461
|
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
+
on_platform %w{solaris2 openindiana opensolaris nexentacore omnios smartos}, os: "solaris2", platform_version: "5.11" do
|
463
|
+
it "returns a Solaris provider" do
|
464
|
+
stub_service_providers
|
465
|
+
stub_service_configs
|
466
|
+
expect(resolved_provider).to eql(Chef::Provider::Service::Solaris)
|
467
|
+
end
|
468
|
+
|
469
|
+
it "always returns a Solaris provider" do
|
470
|
+
# no matter what we stub on the next two lines we should get a Solaris provider
|
471
|
+
stub_service_providers(:debian, :invokercd, :insserv, :upstart, :redhat, :systemd)
|
472
|
+
stub_service_configs(:initd, :upstart, :xinetd, :usr_local_etc_rcd, :systemd)
|
473
|
+
expect(resolved_provider).to eql(Chef::Provider::Service::Solaris)
|
474
|
+
end
|
462
475
|
end
|
463
476
|
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
477
|
+
on_platform %w{mswin mingw32 windows}, platform_family: "windows", platform_version: "5.11" do
|
478
|
+
it "returns a Windows provider" do
|
479
|
+
stub_service_providers
|
480
|
+
stub_service_configs
|
481
|
+
expect(resolved_provider).to eql(Chef::Provider::Service::Windows)
|
482
|
+
end
|
483
|
+
|
484
|
+
it "always returns a Windows provider" do
|
485
|
+
# no matter what we stub on the next two lines we should get a Windows provider
|
486
|
+
stub_service_providers(:debian, :invokercd, :insserv, :upstart, :redhat, :systemd)
|
487
|
+
stub_service_configs(:initd, :upstart, :xinetd, :usr_local_etc_rcd, :systemd)
|
488
|
+
expect(resolved_provider).to eql(Chef::Provider::Service::Windows)
|
489
|
+
end
|
469
490
|
end
|
470
491
|
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
492
|
+
on_platform %w{mac_os_x mac_os_x_server}, os: "darwin", platform_family: "mac_os_x", platform_version: "10.9.2" do
|
493
|
+
it "returns a Macosx provider" do
|
494
|
+
stub_service_providers
|
495
|
+
stub_service_configs
|
496
|
+
expect(resolved_provider).to eql(Chef::Provider::Service::Macosx)
|
497
|
+
end
|
498
|
+
|
499
|
+
it "always returns a Macosx provider" do
|
500
|
+
# no matter what we stub on the next two lines we should get a Macosx provider
|
501
|
+
stub_service_providers(:debian, :invokercd, :insserv, :upstart, :redhat, :systemd)
|
502
|
+
stub_service_configs(:initd, :upstart, :xinetd, :usr_local_etc_rcd, :systemd)
|
503
|
+
expect(resolved_provider).to eql(Chef::Provider::Service::Macosx)
|
504
|
+
end
|
476
505
|
end
|
477
506
|
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
507
|
+
on_platform %w(freebsd netbsd), platform_version: '3.1.4' do
|
508
|
+
it "returns a Freebsd provider if it finds the /usr/local/etc/rc.d initscript" do
|
509
|
+
stub_service_providers
|
510
|
+
stub_service_configs(:usr_local_etc_rcd)
|
511
|
+
expect(resolved_provider).to eql(Chef::Provider::Service::Freebsd)
|
512
|
+
end
|
513
|
+
|
514
|
+
it "returns a Freebsd provider if it finds the /etc/rc.d initscript" do
|
515
|
+
stub_service_providers
|
516
|
+
stub_service_configs(:etc_rcd)
|
517
|
+
expect(resolved_provider).to eql(Chef::Provider::Service::Freebsd)
|
518
|
+
end
|
519
|
+
|
520
|
+
it "always returns a Freebsd provider if it finds the /usr/local/etc/rc.d initscript" do
|
521
|
+
# should only care about :usr_local_etc_rcd stub in the service configs
|
522
|
+
stub_service_providers(:debian, :invokercd, :insserv, :upstart, :redhat, :systemd)
|
523
|
+
stub_service_configs(:usr_local_etc_rcd, :initd, :upstart, :xinetd, :systemd)
|
524
|
+
expect(resolved_provider).to eql(Chef::Provider::Service::Freebsd)
|
525
|
+
end
|
526
|
+
|
527
|
+
it "always returns a Freebsd provider if it finds the /usr/local/etc/rc.d initscript" do
|
528
|
+
# should only care about :etc_rcd stub in the service configs
|
529
|
+
stub_service_providers(:debian, :invokercd, :insserv, :upstart, :redhat, :systemd)
|
530
|
+
stub_service_configs(:etc_rcd, :initd, :upstart, :xinetd, :systemd)
|
531
|
+
expect(resolved_provider).to eql(Chef::Provider::Service::Freebsd)
|
532
|
+
end
|
533
|
+
|
534
|
+
it "foo" do
|
535
|
+
stub_service_providers
|
536
|
+
stub_service_configs
|
537
|
+
expect(resolved_provider).to eql(Chef::Provider::Service::Freebsd)
|
538
|
+
end
|
482
539
|
end
|
483
|
-
end
|
484
540
|
|
485
|
-
|
541
|
+
end
|
486
542
|
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
"debian" => {
|
550
|
-
ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig::Debian ],
|
551
|
-
package: [ Chef::Resource::AptPackage, Chef::Provider::Package::Apt ],
|
552
|
-
# service: [ Chef::Resource::DebianService, Chef::Provider::Service::Debian ],
|
543
|
+
PROVIDERS =
|
544
|
+
{
|
545
|
+
bash: [ Chef::Resource::Bash, Chef::Provider::Script ],
|
546
|
+
breakpoint: [ Chef::Resource::Breakpoint, Chef::Provider::Breakpoint ],
|
547
|
+
chef_gem: [ Chef::Resource::ChefGem, Chef::Provider::Package::Rubygems ],
|
548
|
+
cookbook_file: [ Chef::Resource::CookbookFile, Chef::Provider::CookbookFile ],
|
549
|
+
csh: [ Chef::Resource::Csh, Chef::Provider::Script ],
|
550
|
+
deploy: [ Chef::Resource::Deploy, Chef::Provider::Deploy::Timestamped ],
|
551
|
+
deploy_revision: [ Chef::Resource::DeployRevision, Chef::Provider::Deploy::Revision ],
|
552
|
+
directory: [ Chef::Resource::Directory, Chef::Provider::Directory ],
|
553
|
+
easy_install_package: [ Chef::Resource::EasyInstallPackage, Chef::Provider::Package::EasyInstall ],
|
554
|
+
erl_call: [ Chef::Resource::ErlCall, Chef::Provider::ErlCall ],
|
555
|
+
execute: [ Chef::Resource::Execute, Chef::Provider::Execute ],
|
556
|
+
file: [ Chef::Resource::File, Chef::Provider::File ],
|
557
|
+
gem_package: [ Chef::Resource::GemPackage, Chef::Provider::Package::Rubygems ],
|
558
|
+
git: [ Chef::Resource::Git, Chef::Provider::Git ],
|
559
|
+
group: [ Chef::Resource::Group, Chef::Provider::Group::Gpasswd ],
|
560
|
+
homebrew_package: [ Chef::Resource::HomebrewPackage, Chef::Provider::Package::Homebrew ],
|
561
|
+
http_request: [ Chef::Resource::HttpRequest, Chef::Provider::HttpRequest ],
|
562
|
+
ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig ],
|
563
|
+
link: [ Chef::Resource::Link, Chef::Provider::Link ],
|
564
|
+
log: [ Chef::Resource::Log, Chef::Provider::Log::ChefLog ],
|
565
|
+
macports_package: [ Chef::Resource::MacportsPackage, Chef::Provider::Package::Macports ],
|
566
|
+
mdadm: [ Chef::Resource::Mdadm, Chef::Provider::Mdadm ],
|
567
|
+
mount: [ Chef::Resource::Mount, Chef::Provider::Mount::Mount ],
|
568
|
+
perl: [ Chef::Resource::Perl, Chef::Provider::Script ],
|
569
|
+
portage_package: [ Chef::Resource::PortagePackage, Chef::Provider::Package::Portage ],
|
570
|
+
python: [ Chef::Resource::Python, Chef::Provider::Script ],
|
571
|
+
remote_directory: [ Chef::Resource::RemoteDirectory, Chef::Provider::RemoteDirectory ],
|
572
|
+
route: [ Chef::Resource::Route, Chef::Provider::Route ],
|
573
|
+
ruby: [ Chef::Resource::Ruby, Chef::Provider::Script ],
|
574
|
+
ruby_block: [ Chef::Resource::RubyBlock, Chef::Provider::RubyBlock ],
|
575
|
+
script: [ Chef::Resource::Script, Chef::Provider::Script ],
|
576
|
+
subversion: [ Chef::Resource::Subversion, Chef::Provider::Subversion ],
|
577
|
+
template: [ Chef::Resource::Template, Chef::Provider::Template ],
|
578
|
+
timestamped_deploy: [ Chef::Resource::TimestampedDeploy, Chef::Provider::Deploy::Timestamped ],
|
579
|
+
user: [ Chef::Resource::User, Chef::Provider::User::Useradd ],
|
580
|
+
whyrun_safe_ruby_block: [ Chef::Resource::WhyrunSafeRubyBlock, Chef::Provider::WhyrunSafeRubyBlock ],
|
581
|
+
|
582
|
+
# We want to check that these are unsupported:
|
583
|
+
apt_package: nil,
|
584
|
+
bff_package: nil,
|
585
|
+
dpkg_package: nil,
|
586
|
+
dsc_script: nil,
|
587
|
+
ips_package: nil,
|
588
|
+
pacman_package: nil,
|
589
|
+
paludis_package: nil,
|
590
|
+
rpm_package: nil,
|
591
|
+
smartos_package: nil,
|
592
|
+
solaris_package: nil,
|
593
|
+
yum_package: nil,
|
594
|
+
windows_package: nil,
|
595
|
+
windows_service: nil,
|
596
|
+
|
597
|
+
"linux" => {
|
598
|
+
apt_package: [ Chef::Resource::AptPackage, Chef::Provider::Package::Apt ],
|
599
|
+
dpkg_package: [ Chef::Resource::DpkgPackage, Chef::Provider::Package::Dpkg ],
|
600
|
+
pacman_package: [ Chef::Resource::PacmanPackage, Chef::Provider::Package::Pacman ],
|
601
|
+
paludis_package: [ Chef::Resource::PaludisPackage, Chef::Provider::Package::Paludis ],
|
602
|
+
rpm_package: [ Chef::Resource::RpmPackage, Chef::Provider::Package::Rpm ],
|
603
|
+
yum_package: [ Chef::Resource::YumPackage, Chef::Provider::Package::Yum ],
|
553
604
|
|
554
605
|
"debian" => {
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
606
|
+
ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig::Debian ],
|
607
|
+
package: [ Chef::Resource::AptPackage, Chef::Provider::Package::Apt ],
|
608
|
+
# service: [ Chef::Resource::DebianService, Chef::Provider::Service::Debian ],
|
609
|
+
|
610
|
+
"debian" => {
|
611
|
+
"7.0" => {
|
612
|
+
},
|
613
|
+
"6.0" => {
|
614
|
+
ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig ],
|
615
|
+
# service: [ Chef::Resource::InsservService, Chef::Provider::Service::Insserv ],
|
616
|
+
},
|
617
|
+
"5.0" => {
|
618
|
+
ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig ],
|
619
|
+
},
|
620
|
+
},
|
621
|
+
"gcel" => {
|
622
|
+
"3.1.4" => {
|
623
|
+
ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig ],
|
624
|
+
},
|
625
|
+
},
|
626
|
+
"linaro" => {
|
627
|
+
"3.1.4" => {
|
628
|
+
ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig ],
|
629
|
+
},
|
630
|
+
},
|
631
|
+
"linuxmint" => {
|
632
|
+
"3.1.4" => {
|
633
|
+
ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig ],
|
634
|
+
# service: [ Chef::Resource::UpstartService, Chef::Provider::Service::Upstart ],
|
635
|
+
},
|
636
|
+
},
|
637
|
+
"raspbian" => {
|
638
|
+
"3.1.4" => {
|
639
|
+
ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig ],
|
640
|
+
},
|
641
|
+
},
|
642
|
+
"ubuntu" => {
|
643
|
+
"11.10" => {
|
644
|
+
},
|
645
|
+
"10.04" => {
|
646
|
+
ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig ],
|
647
|
+
},
|
563
648
|
},
|
564
649
|
},
|
565
|
-
"gcel" => {
|
566
|
-
"3.1.4" => {
|
567
|
-
ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig ],
|
568
|
-
},
|
569
|
-
},
|
570
|
-
"linaro" => {
|
571
|
-
"3.1.4" => {
|
572
|
-
ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig ],
|
573
|
-
},
|
574
|
-
},
|
575
|
-
"linuxmint" => {
|
576
|
-
"3.1.4" => {
|
577
|
-
ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig ],
|
578
|
-
# service: [ Chef::Resource::UpstartService, Chef::Provider::Service::Upstart ],
|
579
|
-
},
|
580
|
-
},
|
581
|
-
"raspbian" => {
|
582
|
-
"3.1.4" => {
|
583
|
-
ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig ],
|
584
|
-
},
|
585
|
-
},
|
586
|
-
"ubuntu" => {
|
587
|
-
"11.10" => {
|
588
|
-
},
|
589
|
-
"10.04" => {
|
590
|
-
ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig ],
|
591
|
-
},
|
592
|
-
},
|
593
|
-
},
|
594
|
-
|
595
|
-
"arch" => {
|
596
|
-
# TODO should be Chef::Resource::PacmanPackage
|
597
|
-
package: [ Chef::Resource::Package, Chef::Provider::Package::Pacman ],
|
598
650
|
|
599
651
|
"arch" => {
|
600
|
-
|
601
|
-
|
602
|
-
},
|
603
|
-
},
|
652
|
+
# TODO should be Chef::Resource::PacmanPackage
|
653
|
+
package: [ Chef::Resource::Package, Chef::Provider::Package::Pacman ],
|
604
654
|
|
605
|
-
|
606
|
-
|
607
|
-
|
655
|
+
"arch" => {
|
656
|
+
"3.1.4" => {
|
657
|
+
}
|
658
|
+
},
|
659
|
+
},
|
608
660
|
|
609
661
|
"freebsd" => {
|
610
|
-
|
662
|
+
group: [ Chef::Resource::Group, Chef::Provider::Group::Pw ],
|
663
|
+
user: [ Chef::Resource::User, Chef::Provider::User::Pw ],
|
664
|
+
|
665
|
+
"freebsd" => {
|
666
|
+
"3.1.4" => {
|
667
|
+
},
|
611
668
|
},
|
612
669
|
},
|
613
|
-
},
|
614
|
-
"suse" => {
|
615
|
-
group: [ Chef::Resource::Group, Chef::Provider::Group::Gpasswd ],
|
616
670
|
"suse" => {
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
671
|
+
group: [ Chef::Resource::Group, Chef::Provider::Group::Gpasswd ],
|
672
|
+
"suse" => {
|
673
|
+
"12.0" => {
|
674
|
+
},
|
675
|
+
%w(11.1 11.2 11.3) => {
|
676
|
+
group: [ Chef::Resource::Group, Chef::Provider::Group::Suse ],
|
677
|
+
},
|
678
|
+
},
|
679
|
+
"opensuse" => {
|
680
|
+
# service: [ Chef::Resource::RedhatService, Chef::Provider::Service::Redhat ],
|
681
|
+
package: [ Chef::Resource::ZypperPackage, Chef::Provider::Package::Zypper ],
|
682
|
+
group: [ Chef::Resource::Group, Chef::Provider::Group::Usermod ],
|
683
|
+
"12.3" => {
|
684
|
+
},
|
685
|
+
"12.2" => {
|
686
|
+
group: [ Chef::Resource::Group, Chef::Provider::Group::Suse ],
|
687
|
+
},
|
631
688
|
},
|
632
689
|
},
|
633
|
-
},
|
634
|
-
|
635
|
-
"gentoo" => {
|
636
|
-
# TODO should be Chef::Resource::PortagePackage
|
637
|
-
package: [ Chef::Resource::Package, Chef::Provider::Package::Portage ],
|
638
|
-
portage_package: [ Chef::Resource::PortagePackage, Chef::Provider::Package::Portage ],
|
639
|
-
# service: [ Chef::Resource::GentooService, Chef::Provider::Service::Gentoo ],
|
640
690
|
|
641
691
|
"gentoo" => {
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
692
|
+
# TODO should be Chef::Resource::PortagePackage
|
693
|
+
package: [ Chef::Resource::Package, Chef::Provider::Package::Portage ],
|
694
|
+
portage_package: [ Chef::Resource::PortagePackage, Chef::Provider::Package::Portage ],
|
695
|
+
# service: [ Chef::Resource::GentooService, Chef::Provider::Service::Gentoo ],
|
646
696
|
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig::Redhat ],
|
651
|
-
|
652
|
-
%w(amazon xcp xenserver ibm_powerkvm cloudlinux parallels) => {
|
653
|
-
"3.1.4" => {
|
654
|
-
# service: [ Chef::Resource::RedhatService, Chef::Provider::Service::Redhat ],
|
697
|
+
"gentoo" => {
|
698
|
+
"3.1.4" => {
|
699
|
+
},
|
655
700
|
},
|
656
701
|
},
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
702
|
+
|
703
|
+
"rhel" => {
|
704
|
+
# service: [ Chef::Resource::SystemdService, Chef::Provider::Service::Systemd ],
|
705
|
+
package: [ Chef::Resource::YumPackage, Chef::Provider::Package::Yum ],
|
706
|
+
ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig::Redhat ],
|
707
|
+
|
708
|
+
%w(amazon xcp xenserver ibm_powerkvm cloudlinux parallels) => {
|
709
|
+
"3.1.4" => {
|
710
|
+
# service: [ Chef::Resource::RedhatService, Chef::Provider::Service::Redhat ],
|
711
|
+
},
|
712
|
+
},
|
713
|
+
%w(redhat centos scientific oracle) => {
|
714
|
+
"7.0" => {
|
715
|
+
},
|
716
|
+
"6.0" => {
|
717
|
+
# service: [ Chef::Resource::RedhatService, Chef::Provider::Service::Redhat ],
|
718
|
+
},
|
719
|
+
},
|
720
|
+
"fedora" => {
|
721
|
+
"15.0" => {
|
722
|
+
},
|
723
|
+
"14.0" => {
|
724
|
+
# service: [ Chef::Resource::RedhatService, Chef::Provider::Service::Redhat ],
|
725
|
+
},
|
669
726
|
},
|
670
727
|
},
|
671
|
-
},
|
672
728
|
|
673
|
-
|
729
|
+
},
|
674
730
|
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
731
|
+
"darwin" => {
|
732
|
+
%w(mac_os_x mac_os_x_server) => {
|
733
|
+
group: [ Chef::Resource::Group, Chef::Provider::Group::Dscl ],
|
734
|
+
package: [ Chef::Resource::HomebrewPackage, Chef::Provider::Package::Homebrew ],
|
735
|
+
user: [ Chef::Resource::User, Chef::Provider::User::Dscl ],
|
680
736
|
|
681
|
-
|
682
|
-
|
737
|
+
"mac_os_x" => {
|
738
|
+
"10.9.2" => {
|
739
|
+
},
|
683
740
|
},
|
684
741
|
},
|
685
742
|
},
|
686
|
-
},
|
687
|
-
|
688
|
-
"windows" => {
|
689
|
-
batch: [ Chef::Resource::Batch, Chef::Provider::Batch ],
|
690
|
-
dsc_script: [ Chef::Resource::DscScript, Chef::Provider::DscScript ],
|
691
|
-
env: [ Chef::Resource::Env, Chef::Provider::Env::Windows ],
|
692
|
-
group: [ Chef::Resource::Group, Chef::Provider::Group::Windows ],
|
693
|
-
mount: [ Chef::Resource::Mount, Chef::Provider::Mount::Windows ],
|
694
|
-
package: [ Chef::Resource::WindowsPackage, Chef::Provider::Package::Windows ],
|
695
|
-
powershell_script: [ Chef::Resource::PowershellScript, Chef::Provider::PowershellScript ],
|
696
|
-
service: [ Chef::Resource::WindowsService, Chef::Provider::Service::Windows ],
|
697
|
-
user: [ Chef::Resource::User, Chef::Provider::User::Windows ],
|
698
|
-
windows_package: [ Chef::Resource::WindowsPackage, Chef::Provider::Package::Windows ],
|
699
|
-
windows_service: [ Chef::Resource::WindowsService, Chef::Provider::Service::Windows ],
|
700
743
|
|
701
744
|
"windows" => {
|
702
|
-
|
703
|
-
|
745
|
+
batch: [ Chef::Resource::Batch, Chef::Provider::Batch ],
|
746
|
+
dsc_script: [ Chef::Resource::DscScript, Chef::Provider::DscScript ],
|
747
|
+
env: [ Chef::Resource::Env, Chef::Provider::Env::Windows ],
|
748
|
+
group: [ Chef::Resource::Group, Chef::Provider::Group::Windows ],
|
749
|
+
mount: [ Chef::Resource::Mount, Chef::Provider::Mount::Windows ],
|
750
|
+
package: [ Chef::Resource::WindowsPackage, Chef::Provider::Package::Windows ],
|
751
|
+
powershell_script: [ Chef::Resource::PowershellScript, Chef::Provider::PowershellScript ],
|
752
|
+
service: [ Chef::Resource::WindowsService, Chef::Provider::Service::Windows ],
|
753
|
+
user: [ Chef::Resource::User, Chef::Provider::User::Windows ],
|
754
|
+
windows_package: [ Chef::Resource::WindowsPackage, Chef::Provider::Package::Windows ],
|
755
|
+
windows_service: [ Chef::Resource::WindowsService, Chef::Provider::Service::Windows ],
|
756
|
+
|
757
|
+
"windows" => {
|
758
|
+
%w(mswin mingw32 windows) => {
|
759
|
+
"10.9.2" => {
|
760
|
+
},
|
704
761
|
},
|
705
762
|
},
|
706
763
|
},
|
707
|
-
},
|
708
|
-
|
709
|
-
"aix" => {
|
710
|
-
bff_package: [ Chef::Resource::BffPackage, Chef::Provider::Package::Aix ],
|
711
|
-
cron: [ Chef::Resource::Cron, Chef::Provider::Cron::Aix ],
|
712
|
-
group: [ Chef::Resource::Group, Chef::Provider::Group::Aix ],
|
713
|
-
ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig::Aix ],
|
714
|
-
mount: [ Chef::Resource::Mount, Chef::Provider::Mount::Aix ],
|
715
|
-
# TODO should be Chef::Resource::BffPackage
|
716
|
-
package: [ Chef::Resource::Package, Chef::Provider::Package::Aix ],
|
717
|
-
rpm_package: [ Chef::Resource::RpmPackage, Chef::Provider::Package::Rpm ],
|
718
|
-
user: [ Chef::Resource::User, Chef::Provider::User::Aix ],
|
719
|
-
# service: [ Chef::Resource::AixService, Chef::Provider::Service::Aix ],
|
720
764
|
|
721
765
|
"aix" => {
|
766
|
+
bff_package: [ Chef::Resource::BffPackage, Chef::Provider::Package::Aix ],
|
767
|
+
cron: [ Chef::Resource::Cron, Chef::Provider::Cron::Aix ],
|
768
|
+
group: [ Chef::Resource::Group, Chef::Provider::Group::Aix ],
|
769
|
+
ifconfig: [ Chef::Resource::Ifconfig, Chef::Provider::Ifconfig::Aix ],
|
770
|
+
mount: [ Chef::Resource::Mount, Chef::Provider::Mount::Aix ],
|
771
|
+
# TODO should be Chef::Resource::BffPackage
|
772
|
+
package: [ Chef::Resource::Package, Chef::Provider::Package::Aix ],
|
773
|
+
rpm_package: [ Chef::Resource::RpmPackage, Chef::Provider::Package::Rpm ],
|
774
|
+
user: [ Chef::Resource::User, Chef::Provider::User::Aix ],
|
775
|
+
# service: [ Chef::Resource::AixService, Chef::Provider::Service::Aix ],
|
776
|
+
|
722
777
|
"aix" => {
|
723
|
-
"
|
778
|
+
"aix" => {
|
779
|
+
"5.6" => {
|
780
|
+
},
|
724
781
|
},
|
725
782
|
},
|
726
783
|
},
|
727
|
-
},
|
728
784
|
|
729
|
-
"hpux" => {
|
730
785
|
"hpux" => {
|
731
786
|
"hpux" => {
|
732
|
-
"
|
733
|
-
|
787
|
+
"hpux" => {
|
788
|
+
"3.1.4" => {
|
789
|
+
group: [ Chef::Resource::Group, Chef::Provider::Group::Usermod ]
|
790
|
+
}
|
734
791
|
}
|
735
792
|
}
|
736
|
-
}
|
737
|
-
},
|
793
|
+
},
|
738
794
|
|
739
|
-
"netbsd" => {
|
740
795
|
"netbsd" => {
|
741
796
|
"netbsd" => {
|
742
|
-
"
|
743
|
-
|
797
|
+
"netbsd" => {
|
798
|
+
"3.1.4" => {
|
799
|
+
group: [ Chef::Resource::Group, Chef::Provider::Group::Groupmod ],
|
800
|
+
},
|
744
801
|
},
|
745
802
|
},
|
746
803
|
},
|
747
|
-
},
|
748
|
-
|
749
|
-
"openbsd" => {
|
750
|
-
group: [ Chef::Resource::Group, Chef::Provider::Group::Usermod ],
|
751
|
-
package: [ Chef::Resource::OpenbsdPackage, Chef::Provider::Package::Openbsd ],
|
752
804
|
|
753
805
|
"openbsd" => {
|
806
|
+
group: [ Chef::Resource::Group, Chef::Provider::Group::Usermod ],
|
807
|
+
package: [ Chef::Resource::OpenbsdPackage, Chef::Provider::Package::Openbsd ],
|
808
|
+
|
754
809
|
"openbsd" => {
|
755
|
-
"
|
810
|
+
"openbsd" => {
|
811
|
+
"3.1.4" => {
|
812
|
+
},
|
756
813
|
},
|
757
814
|
},
|
758
815
|
},
|
759
|
-
},
|
760
816
|
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
"smartos" => {
|
769
|
-
smartos_package: [ Chef::Resource::SmartosPackage, Chef::Provider::Package::SmartOS ],
|
770
|
-
package: [ Chef::Resource::SmartosPackage, Chef::Provider::Package::SmartOS ],
|
817
|
+
"solaris2" => {
|
818
|
+
group: [ Chef::Resource::Group, Chef::Provider::Group::Usermod ],
|
819
|
+
ips_package: [ Chef::Resource::IpsPackage, Chef::Provider::Package::Ips ],
|
820
|
+
package: [ Chef::Resource::SolarisPackage, Chef::Provider::Package::Solaris ],
|
821
|
+
mount: [ Chef::Resource::Mount, Chef::Provider::Mount::Solaris ],
|
822
|
+
solaris_package: [ Chef::Resource::SolarisPackage, Chef::Provider::Package::Solaris ],
|
771
823
|
|
772
824
|
"smartos" => {
|
773
|
-
|
825
|
+
smartos_package: [ Chef::Resource::SmartosPackage, Chef::Provider::Package::SmartOS ],
|
826
|
+
package: [ Chef::Resource::SmartosPackage, Chef::Provider::Package::SmartOS ],
|
827
|
+
|
828
|
+
"smartos" => {
|
829
|
+
"3.1.4" => {
|
830
|
+
},
|
774
831
|
},
|
775
832
|
},
|
776
|
-
},
|
777
833
|
|
778
|
-
|
779
|
-
|
780
|
-
|
834
|
+
"solaris2" => {
|
835
|
+
"nexentacore" => {
|
836
|
+
"3.1.4" => {
|
837
|
+
},
|
781
838
|
},
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
}
|
787
|
-
},
|
788
|
-
"openindiana" => {
|
789
|
-
"3.1.4" => {
|
839
|
+
"omnios" => {
|
840
|
+
"3.1.4" => {
|
841
|
+
user: [ Chef::Resource::User, Chef::Provider::User::Solaris ],
|
842
|
+
}
|
790
843
|
},
|
791
|
-
|
792
|
-
|
793
|
-
|
844
|
+
"openindiana" => {
|
845
|
+
"3.1.4" => {
|
846
|
+
},
|
794
847
|
},
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
"5.11" => {
|
799
|
-
package: [ Chef::Resource::IpsPackage, Chef::Provider::Package::Ips ],
|
848
|
+
"opensolaris" => {
|
849
|
+
"3.1.4" => {
|
850
|
+
},
|
800
851
|
},
|
801
|
-
"
|
852
|
+
"solaris2" => {
|
853
|
+
user: [ Chef::Resource::User, Chef::Provider::User::Solaris ],
|
854
|
+
"5.11" => {
|
855
|
+
package: [ Chef::Resource::IpsPackage, Chef::Provider::Package::Ips ],
|
856
|
+
},
|
857
|
+
"5.9" => {
|
858
|
+
},
|
802
859
|
},
|
803
860
|
},
|
804
|
-
},
|
805
861
|
|
806
|
-
|
862
|
+
},
|
807
863
|
|
808
|
-
"solaris" => {
|
809
864
|
"solaris" => {
|
810
865
|
"solaris" => {
|
811
|
-
"
|
866
|
+
"solaris" => {
|
867
|
+
"3.1.4" => {
|
868
|
+
},
|
812
869
|
},
|
813
870
|
},
|
814
871
|
},
|
815
|
-
},
|
816
872
|
|
817
|
-
"exherbo" => {
|
818
873
|
"exherbo" => {
|
819
874
|
"exherbo" => {
|
820
|
-
"
|
821
|
-
|
822
|
-
|
875
|
+
"exherbo" => {
|
876
|
+
"3.1.4" => {
|
877
|
+
# TODO should be Chef::Resource::PaludisPackage
|
878
|
+
package: [ Chef::Resource::Package, Chef::Provider::Package::Paludis ]
|
879
|
+
}
|
823
880
|
}
|
824
881
|
}
|
825
882
|
}
|
826
883
|
}
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
:platform_family
|
838
|
-
|
839
|
-
:platform
|
840
|
-
|
841
|
-
:platform_version
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
884
|
+
|
885
|
+
def self.create_provider_tests(providers, test, expected, filter)
|
886
|
+
expected = expected.merge(providers.select { |key, value| key.is_a?(Symbol) })
|
887
|
+
providers.each do |key, value|
|
888
|
+
if !key.is_a?(Symbol)
|
889
|
+
next_test = test.merge({ filter => key })
|
890
|
+
next_filter =
|
891
|
+
case filter
|
892
|
+
when :os
|
893
|
+
:platform_family
|
894
|
+
when :platform_family
|
895
|
+
:platform
|
896
|
+
when :platform
|
897
|
+
:platform_version
|
898
|
+
when :platform_version
|
899
|
+
nil
|
900
|
+
else
|
901
|
+
raise "Hash too deep; only os, platform_family, platform and platform_version supported"
|
902
|
+
end
|
903
|
+
create_provider_tests(value, next_test, expected, next_filter)
|
904
|
+
end
|
848
905
|
end
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
906
|
+
# If there is no filter, we're as deep as we need to go
|
907
|
+
if !filter
|
908
|
+
on_platform test.delete(:platform), test do
|
909
|
+
expect_providers(expected)
|
910
|
+
end
|
854
911
|
end
|
855
912
|
end
|
856
|
-
end
|
857
913
|
|
858
|
-
|
914
|
+
create_provider_tests(PROVIDERS, {}, {}, :os)
|
915
|
+
end
|
859
916
|
end
|