chef 12.4.0.rc.0-universal-mingw32 → 12.4.0.rc.2-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +12 -1
- data/lib/chef/api_client.rb +130 -26
- data/lib/chef/application.rb +0 -1
- data/lib/chef/application/client.rb +8 -19
- data/lib/chef/audit/audit_reporter.rb +12 -7
- data/lib/chef/audit/logger.rb +36 -0
- data/lib/chef/audit/runner.rb +4 -2
- data/lib/chef/chef_class.rb +62 -11
- data/lib/chef/client.rb +587 -207
- data/lib/chef/config.rb +0 -1
- data/lib/chef/dsl/recipe.rb +45 -56
- data/lib/chef/dsl/resources.rb +3 -2
- data/lib/chef/event_dispatch/base.rb +7 -2
- data/lib/chef/exceptions.rb +4 -1
- data/lib/chef/file_content_management/deploy/mv_windows.rb +16 -6
- data/lib/chef/formatters/doc.rb +15 -7
- data/lib/chef/formatters/error_inspectors/api_error_formatting.rb +10 -7
- data/lib/chef/guard_interpreter/default_guard_interpreter.rb +2 -0
- data/lib/chef/guard_interpreter/resource_guard_interpreter.rb +4 -1
- data/lib/chef/http/authenticator.rb +7 -2
- data/lib/chef/knife.rb +16 -4
- data/lib/chef/knife/client_create.rb +55 -31
- data/lib/chef/knife/core/generic_presenter.rb +1 -1
- data/lib/chef/knife/core/subcommand_loader.rb +1 -1
- data/lib/chef/knife/osc_user_create.rb +97 -0
- data/lib/chef/knife/osc_user_delete.rb +51 -0
- data/lib/chef/knife/osc_user_edit.rb +58 -0
- data/lib/chef/knife/osc_user_list.rb +47 -0
- data/lib/chef/knife/osc_user_reregister.rb +64 -0
- data/lib/chef/knife/osc_user_show.rb +54 -0
- data/lib/chef/knife/user_create.rb +95 -36
- data/lib/chef/knife/user_delete.rb +52 -2
- data/lib/chef/knife/user_edit.rb +37 -7
- data/lib/chef/knife/user_list.rb +3 -0
- data/lib/chef/knife/user_reregister.rb +39 -8
- data/lib/chef/knife/user_show.rb +30 -1
- data/lib/chef/mixin/api_version_request_handling.rb +66 -0
- data/lib/chef/mixin/convert_to_class_name.rb +10 -4
- data/lib/chef/mixin/deprecation.rb +24 -0
- data/lib/chef/mixin/powershell_out.rb +98 -0
- data/lib/chef/mixin/provides.rb +5 -18
- data/lib/chef/mixin/uris.rb +11 -0
- data/lib/chef/mixin/windows_architecture_helper.rb +5 -2
- data/lib/chef/mixin/windows_env_helper.rb +11 -2
- data/lib/chef/node_map.rb +130 -75
- data/lib/chef/osc_user.rb +194 -0
- data/lib/chef/platform/provider_mapping.rb +2 -269
- data/lib/chef/platform/provider_priority_map.rb +6 -69
- data/lib/chef/platform/query_helpers.rb +5 -0
- data/lib/chef/platform/resource_priority_map.rb +12 -15
- data/lib/chef/policy_builder/policyfile.rb +1 -0
- data/lib/chef/provider.rb +19 -0
- data/lib/chef/provider/directory.rb +3 -0
- data/lib/chef/provider/dsc_resource.rb +8 -1
- data/lib/chef/provider/file.rb +1 -0
- data/lib/chef/provider/group/aix.rb +1 -0
- data/lib/chef/provider/group/dscl.rb +1 -1
- data/lib/chef/provider/group/gpasswd.rb +1 -0
- data/lib/chef/provider/group/groupmod.rb +1 -1
- data/lib/chef/provider/group/pw.rb +1 -0
- data/lib/chef/provider/group/suse.rb +2 -0
- data/lib/chef/provider/group/usermod.rb +2 -1
- data/lib/chef/provider/group/windows.rb +1 -1
- data/lib/chef/provider/ifconfig.rb +2 -0
- data/lib/chef/provider/ifconfig/aix.rb +1 -0
- data/lib/chef/provider/ifconfig/debian.rb +2 -0
- data/lib/chef/provider/ifconfig/redhat.rb +1 -0
- data/lib/chef/provider/lwrp_base.rb +4 -0
- data/lib/chef/provider/mount.rb +0 -1
- data/lib/chef/provider/mount/aix.rb +1 -0
- data/lib/chef/provider/mount/mount.rb +2 -0
- data/lib/chef/provider/mount/solaris.rb +2 -0
- data/lib/chef/provider/package.rb +55 -0
- data/lib/chef/provider/package/aix.rb +7 -7
- data/lib/chef/provider/package/apt.rb +3 -3
- data/lib/chef/provider/package/dpkg.rb +4 -4
- data/lib/chef/provider/package/easy_install.rb +5 -5
- data/lib/chef/provider/package/freebsd/base.rb +2 -2
- data/lib/chef/provider/package/freebsd/pkg.rb +6 -6
- data/lib/chef/provider/package/freebsd/pkgng.rb +5 -5
- data/lib/chef/provider/package/freebsd/port.rb +4 -4
- data/lib/chef/provider/package/homebrew.rb +2 -2
- data/lib/chef/provider/package/ips.rb +4 -4
- data/lib/chef/provider/package/macports.rb +5 -6
- data/lib/chef/provider/package/openbsd.rb +4 -5
- data/lib/chef/provider/package/pacman.rb +4 -4
- data/lib/chef/provider/package/portage.rb +2 -0
- data/lib/chef/provider/package/rpm.rb +7 -8
- data/lib/chef/provider/package/rubygems.rb +5 -12
- data/lib/chef/provider/package/smartos.rb +4 -4
- data/lib/chef/provider/package/solaris.rb +7 -7
- data/lib/chef/provider/package/windows/msi.rb +1 -1
- data/lib/chef/provider/package/yum.rb +4 -6
- data/lib/chef/provider/package/zypper.rb +16 -14
- data/lib/chef/provider/powershell_script.rb +129 -47
- data/lib/chef/provider/remote_file/content.rb +4 -1
- data/lib/chef/provider/remote_file/local_file.rb +10 -4
- data/lib/chef/provider/service.rb +44 -0
- data/lib/chef/provider/service/freebsd.rb +1 -1
- data/lib/chef/provider/service/init.rb +1 -0
- data/lib/chef/provider/service/macosx.rb +1 -1
- data/lib/chef/provider/service/windows.rb +0 -1
- data/lib/chef/provider/user.rb +1 -1
- data/lib/chef/provider/user/aix.rb +3 -2
- data/lib/chef/provider/user/pw.rb +1 -0
- data/lib/chef/provider/user/solaris.rb +2 -0
- data/lib/chef/provider/user/useradd.rb +1 -0
- data/lib/chef/provider_resolver.rb +87 -134
- data/lib/chef/resource.rb +274 -68
- data/lib/chef/resource/apt_package.rb +0 -2
- data/lib/chef/resource/bash.rb +0 -2
- data/lib/chef/resource/batch.rb +1 -1
- data/lib/chef/resource/bff_package.rb +0 -7
- data/lib/chef/resource/breakpoint.rb +3 -6
- data/lib/chef/resource/chef_gem.rb +0 -3
- data/lib/chef/resource/cookbook_file.rb +1 -3
- data/lib/chef/resource/cron.rb +2 -4
- data/lib/chef/resource/csh.rb +0 -2
- data/lib/chef/resource/deploy.rb +9 -6
- data/lib/chef/resource/deploy_revision.rb +0 -14
- data/lib/chef/resource/directory.rb +2 -4
- data/lib/chef/resource/dpkg_package.rb +0 -5
- data/lib/chef/resource/dsc_resource.rb +2 -3
- data/lib/chef/resource/dsc_script.rb +2 -3
- data/lib/chef/resource/easy_install_package.rb +0 -7
- data/lib/chef/resource/env.rb +3 -3
- data/lib/chef/resource/erl_call.rb +2 -5
- data/lib/chef/resource/execute.rb +2 -4
- data/lib/chef/resource/file.rb +2 -4
- data/lib/chef/resource/freebsd_package.rb +0 -5
- data/lib/chef/resource/gem_package.rb +0 -3
- data/lib/chef/resource/git.rb +0 -3
- data/lib/chef/resource/group.rb +2 -4
- data/lib/chef/resource/homebrew_package.rb +0 -2
- data/lib/chef/resource/http_request.rb +3 -4
- data/lib/chef/resource/ifconfig.rb +3 -4
- data/lib/chef/resource/ips_package.rb +2 -2
- data/lib/chef/resource/link.rb +3 -5
- data/lib/chef/resource/log.rb +2 -4
- data/lib/chef/resource/lwrp_base.rb +10 -61
- data/lib/chef/resource/macosx_service.rb +1 -2
- data/lib/chef/resource/macports_package.rb +0 -7
- data/lib/chef/resource/mdadm.rb +2 -5
- data/lib/chef/resource/mount.rb +2 -4
- data/lib/chef/resource/ohai.rb +2 -4
- data/lib/chef/resource/openbsd_package.rb +0 -6
- data/lib/chef/resource/package.rb +9 -6
- data/lib/chef/resource/pacman_package.rb +0 -7
- data/lib/chef/resource/paludis_package.rb +2 -3
- data/lib/chef/resource/perl.rb +0 -3
- data/lib/chef/resource/portage_package.rb +0 -3
- data/lib/chef/resource/powershell_script.rb +1 -2
- data/lib/chef/resource/python.rb +0 -3
- data/lib/chef/resource/reboot.rb +1 -3
- data/lib/chef/resource/registry_key.rb +3 -5
- data/lib/chef/resource/remote_directory.rb +3 -5
- data/lib/chef/resource/remote_file.rb +4 -5
- data/lib/chef/resource/route.rb +3 -5
- data/lib/chef/resource/rpm_package.rb +0 -2
- data/lib/chef/resource/ruby.rb +0 -4
- data/lib/chef/resource/ruby_block.rb +2 -4
- data/lib/chef/resource/scm.rb +3 -5
- data/lib/chef/resource/script.rb +0 -3
- data/lib/chef/resource/service.rb +3 -5
- data/lib/chef/resource/smartos_package.rb +0 -9
- data/lib/chef/resource/solaris_package.rb +0 -10
- data/lib/chef/resource/subversion.rb +1 -3
- data/lib/chef/resource/template.rb +0 -4
- data/lib/chef/resource/timestamped_deploy.rb +0 -4
- data/lib/chef/resource/user.rb +2 -5
- data/lib/chef/resource/whyrun_safe_ruby_block.rb +0 -7
- data/lib/chef/resource/windows_package.rb +3 -3
- data/lib/chef/resource/windows_script.rb +2 -2
- data/lib/chef/resource/windows_service.rb +3 -3
- data/lib/chef/resource/yum_package.rb +0 -3
- data/lib/chef/resource/zypper_package.rb +27 -0
- data/lib/chef/resource_builder.rb +7 -0
- data/lib/chef/resource_reporter.rb +1 -1
- data/lib/chef/resource_resolver.rb +108 -62
- data/lib/chef/resources.rb +1 -0
- data/lib/chef/rest.rb +1 -0
- data/lib/chef/server_api.rb +2 -0
- data/lib/chef/user.rb +193 -42
- data/lib/chef/util/backup.rb +9 -1
- data/lib/chef/util/path_helper.rb +0 -1
- data/lib/chef/version.rb +1 -1
- data/spec/functional/audit/runner_spec.rb +22 -42
- data/spec/functional/mixin/powershell_out_spec.rb +43 -0
- data/spec/functional/resource/execute_spec.rb +9 -2
- data/spec/functional/resource/file_spec.rb +25 -0
- data/spec/functional/resource/group_spec.rb +5 -0
- data/spec/functional/resource/link_spec.rb +5 -11
- data/spec/functional/resource/powershell_spec.rb +40 -5
- data/spec/functional/resource/user/useradd_spec.rb +10 -18
- data/spec/integration/recipes/lwrp_spec.rb +57 -0
- data/spec/integration/recipes/provider_choice.rb +2 -7
- data/spec/integration/recipes/recipe_dsl_spec.rb +517 -19
- data/spec/spec_helper.rb +1 -1
- data/spec/support/lib/chef/provider/openldap_includer.rb +29 -0
- data/spec/support/lib/chef/resource/cat.rb +0 -2
- data/spec/support/lib/chef/resource/one_two_three_four.rb +0 -6
- data/spec/support/lib/chef/resource/openldap_includer.rb +27 -0
- data/spec/support/lib/chef/resource/with_state.rb +0 -9
- data/spec/support/lib/chef/resource/zen_follower.rb +0 -6
- data/spec/support/lib/chef/resource/zen_master.rb +1 -6
- data/spec/support/shared/context/client.rb +277 -0
- data/spec/support/shared/examples/client.rb +53 -0
- data/spec/support/shared/functional/file_resource.rb +0 -4
- data/spec/support/shared/functional/securable_resource.rb +0 -24
- data/spec/support/shared/functional/securable_resource_with_reporting.rb +4 -4
- data/spec/support/shared/functional/windows_script.rb +1 -1
- data/spec/support/shared/unit/api_versioning.rb +77 -0
- data/spec/support/shared/unit/knife_shared.rb +40 -0
- data/spec/support/shared/unit/user_and_client_shared.rb +115 -0
- data/spec/unit/api_client_spec.rb +189 -14
- data/spec/unit/application/client_spec.rb +0 -5
- data/spec/unit/audit/audit_reporter_spec.rb +58 -14
- data/spec/unit/audit/logger_spec.rb +42 -0
- data/spec/unit/audit/runner_spec.rb +2 -2
- data/spec/unit/chef_fs/file_pattern_spec.rb +3 -15
- data/spec/unit/client_spec.rb +58 -374
- data/spec/unit/cookbook_spec.rb +0 -9
- data/spec/unit/cookbook_version_spec.rb +0 -20
- data/spec/unit/deprecation_spec.rb +55 -0
- data/spec/unit/dsl/resources_spec.rb +85 -0
- data/spec/unit/exceptions_spec.rb +2 -2
- data/spec/unit/file_content_management/deploy/mv_windows_spec.rb +60 -0
- data/spec/unit/formatters/doc_spec.rb +46 -0
- data/spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb +12 -10
- data/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb +8 -0
- data/spec/unit/http/authenticator_spec.rb +11 -2
- data/spec/unit/knife/client_create_spec.rb +122 -51
- data/spec/unit/knife/core/subcommand_loader_spec.rb +19 -3
- data/spec/unit/knife/core/ui_spec.rb +14 -0
- data/spec/unit/knife/osc_user_create_spec.rb +93 -0
- data/spec/unit/knife/osc_user_delete_spec.rb +44 -0
- data/spec/unit/knife/osc_user_edit_spec.rb +52 -0
- data/spec/unit/knife/osc_user_list_spec.rb +37 -0
- data/spec/unit/knife/osc_user_reregister_spec.rb +58 -0
- data/spec/unit/knife/osc_user_show_spec.rb +46 -0
- data/spec/unit/knife/user_create_spec.rb +177 -51
- data/spec/unit/knife/user_delete_spec.rb +34 -8
- data/spec/unit/knife/user_edit_spec.rb +31 -12
- data/spec/unit/knife/user_list_spec.rb +7 -3
- data/spec/unit/knife/user_reregister_spec.rb +38 -17
- data/spec/unit/knife/user_show_spec.rb +35 -11
- data/spec/unit/knife_spec.rb +10 -4
- data/spec/unit/lwrp_spec.rb +228 -54
- data/spec/unit/mixin/api_version_request_handling_spec.rb +127 -0
- data/spec/unit/mixin/command_spec.rb +1 -2
- data/spec/unit/mixin/powershell_out_spec.rb +70 -0
- data/spec/unit/mixin/uris_spec.rb +23 -11
- data/spec/unit/node_map_spec.rb +4 -1
- data/spec/unit/osc_user_spec.rb +276 -0
- data/spec/unit/platform_spec.rb +0 -60
- data/spec/unit/provider/deploy_spec.rb +1 -1
- data/spec/unit/provider/directory_spec.rb +199 -135
- data/spec/unit/provider/ifconfig/debian_spec.rb +0 -10
- data/spec/unit/provider/package/aix_spec.rb +16 -16
- data/spec/unit/provider/package/dpkg_spec.rb +2 -2
- data/spec/unit/provider/package/freebsd/pkg_spec.rb +13 -13
- data/spec/unit/provider/package/freebsd/pkgng_spec.rb +9 -9
- data/spec/unit/provider/package/freebsd/port_spec.rb +7 -7
- data/spec/unit/provider/package/ips_spec.rb +22 -22
- data/spec/unit/provider/package/macports_spec.rb +10 -10
- data/spec/unit/provider/package/openbsd_spec.rb +4 -26
- data/spec/unit/provider/package/pacman_spec.rb +5 -5
- data/spec/unit/provider/package/rpm_spec.rb +14 -14
- data/spec/unit/provider/package/rubygems_spec.rb +10 -44
- data/spec/unit/provider/package/smartos_spec.rb +4 -4
- data/spec/unit/provider/package/solaris_spec.rb +11 -11
- data/spec/unit/provider/package/zypper_spec.rb +125 -90
- data/spec/unit/provider/package_spec.rb +34 -0
- data/spec/unit/provider/powershell_spec.rb +53 -11
- data/spec/unit/provider/remote_directory_spec.rb +2 -2
- data/spec/unit/provider/remote_file/local_file_spec.rb +25 -6
- data/spec/unit/provider/service/freebsd_service_spec.rb +0 -12
- data/spec/unit/provider/user_spec.rb +3 -3
- data/spec/unit/provider_resolver_spec.rb +463 -327
- data/spec/unit/recipe_spec.rb +42 -15
- data/spec/unit/resource/breakpoint_spec.rb +1 -1
- data/spec/unit/resource/erl_call_spec.rb +1 -1
- data/spec/unit/resource/file_spec.rb +1 -1
- data/spec/unit/resource/ifconfig_spec.rb +10 -6
- data/spec/unit/resource/remote_file_spec.rb +5 -0
- data/spec/unit/resource/route_spec.rb +1 -1
- data/spec/unit/resource/ruby_block_spec.rb +2 -2
- data/spec/unit/resource/template_spec.rb +1 -1
- data/spec/unit/resource/timestamped_deploy_spec.rb +1 -2
- data/spec/unit/resource/windows_service_spec.rb +1 -1
- data/spec/unit/resource_spec.rb +99 -13
- data/spec/unit/rest_spec.rb +5 -5
- data/spec/unit/run_context_spec.rb +41 -0
- data/spec/unit/runner_spec.rb +2 -2
- data/spec/unit/user_spec.rb +406 -93
- data/tasks/maintainers.rb +69 -0
- metadata +37 -4
data/lib/chef/provider.rb
CHANGED
@@ -22,14 +22,19 @@ require 'chef/mixin/convert_to_class_name'
|
|
22
22
|
require 'chef/mixin/enforce_ownership_and_permissions'
|
23
23
|
require 'chef/mixin/why_run'
|
24
24
|
require 'chef/mixin/shell_out'
|
25
|
+
require 'chef/mixin/powershell_out'
|
25
26
|
require 'chef/mixin/provides'
|
26
27
|
require 'chef/platform/service_helpers'
|
27
28
|
require 'chef/node_map'
|
28
29
|
|
29
30
|
class Chef
|
30
31
|
class Provider
|
32
|
+
require 'chef/mixin/why_run'
|
33
|
+
require 'chef/mixin/shell_out'
|
34
|
+
require 'chef/mixin/provides'
|
31
35
|
include Chef::Mixin::WhyRun
|
32
36
|
include Chef::Mixin::ShellOut
|
37
|
+
include Chef::Mixin::PowershellOut
|
33
38
|
extend Chef::Mixin::Provides
|
34
39
|
|
35
40
|
# supports the given resource and action (late binding)
|
@@ -170,6 +175,14 @@ class Chef
|
|
170
175
|
converge_actions.add_action(descriptions, &block)
|
171
176
|
end
|
172
177
|
|
178
|
+
def self.provides(short_name, opts={}, &block)
|
179
|
+
Chef.set_provider_priority_array(short_name, self, opts, &block)
|
180
|
+
end
|
181
|
+
|
182
|
+
def self.provides?(node, resource)
|
183
|
+
Chef::ProviderResolver.new(node, resource, :nothing).provided_by?(self)
|
184
|
+
end
|
185
|
+
|
173
186
|
protected
|
174
187
|
|
175
188
|
def converge_actions
|
@@ -226,3 +239,9 @@ class Chef
|
|
226
239
|
extend DeprecatedLWRPClass
|
227
240
|
end
|
228
241
|
end
|
242
|
+
|
243
|
+
# Requiring things at the bottom breaks cycles
|
244
|
+
require 'chef/chef_class'
|
245
|
+
require 'chef/mixin/why_run'
|
246
|
+
require 'chef/resource_collection'
|
247
|
+
require 'chef/runner'
|
@@ -43,6 +43,9 @@ class Chef
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def define_resource_requirements
|
46
|
+
# deep inside FAC we have to assert requirements, so call FACs hook to set that up
|
47
|
+
access_controls.define_resource_requirements
|
48
|
+
|
46
49
|
requirements.assert(:create) do |a|
|
47
50
|
# Make sure the parent dir exists, or else fail.
|
48
51
|
# for why run, print a message explaining the potential error.
|
@@ -121,7 +121,14 @@ class Chef
|
|
121
121
|
# however Invoke-DscResource is not correctly writing to that
|
122
122
|
# stream and instead just dumping to stdout
|
123
123
|
@converge_description = result.stdout
|
124
|
-
|
124
|
+
|
125
|
+
if result.return_value.is_a?(Array)
|
126
|
+
# WMF Feb 2015 Preview
|
127
|
+
result.return_value[0]["InDesiredState"]
|
128
|
+
else
|
129
|
+
# WMF April 2015 Preview
|
130
|
+
result.return_value["InDesiredState"]
|
131
|
+
end
|
125
132
|
end
|
126
133
|
|
127
134
|
def set_resource
|
data/lib/chef/provider/file.rb
CHANGED
@@ -26,6 +26,7 @@ require 'fileutils'
|
|
26
26
|
require 'chef/scan_access_control'
|
27
27
|
require 'chef/mixin/checksum'
|
28
28
|
require 'chef/mixin/file_class'
|
29
|
+
require 'chef/mixin/enforce_ownership_and_permissions'
|
29
30
|
require 'chef/util/backup'
|
30
31
|
require 'chef/util/diff'
|
31
32
|
require 'chef/util/selinux'
|
@@ -22,6 +22,8 @@ class Chef
|
|
22
22
|
class Provider
|
23
23
|
class Group
|
24
24
|
class Suse < Chef::Provider::Group::Groupadd
|
25
|
+
provides :group, platform: 'opensuse', platform_version: '< 12.3'
|
26
|
+
provides :group, platform: 'suse', platform_version: '< 12.0'
|
25
27
|
|
26
28
|
def load_current_resource
|
27
29
|
super
|
@@ -23,6 +23,8 @@ class Chef
|
|
23
23
|
class Provider
|
24
24
|
class Ifconfig
|
25
25
|
class Debian < Chef::Provider::Ifconfig
|
26
|
+
provides :ifconfig, platform: %w(ubuntu), platform_version: '>= 11.10'
|
27
|
+
provides :ifconfig, platform: %w(debian), platform_version: '>= 7.0'
|
26
28
|
|
27
29
|
INTERFACES_FILE = "/etc/network/interfaces"
|
28
30
|
INTERFACES_DOT_D_DIR = "/etc/network/interfaces.d"
|
@@ -19,6 +19,7 @@
|
|
19
19
|
#
|
20
20
|
|
21
21
|
require 'chef/provider'
|
22
|
+
require 'chef/dsl/include_recipe'
|
22
23
|
|
23
24
|
class Chef
|
24
25
|
class Provider
|
@@ -77,6 +78,9 @@ class Chef
|
|
77
78
|
include Chef::DSL::PlatformIntrospection
|
78
79
|
include Chef::DSL::DataQuery
|
79
80
|
|
81
|
+
# Allow include_recipe from within LWRP provider code
|
82
|
+
include Chef::DSL::IncludeRecipe
|
83
|
+
|
80
84
|
# no-op `load_current_resource`. Allows simple LWRP providers to work
|
81
85
|
# without defining this method explicitly (silences
|
82
86
|
# Chef::Exceptions::Override exception)
|
data/lib/chef/provider/mount.rb
CHANGED
@@ -490,6 +490,61 @@ class Chef
|
|
490
490
|
false
|
491
491
|
end
|
492
492
|
end
|
493
|
+
|
494
|
+
# Set provider priority
|
495
|
+
require 'chef/chef_class'
|
496
|
+
require 'chef/provider/package/dpkg'
|
497
|
+
require 'chef/provider/package/homebrew'
|
498
|
+
require 'chef/provider/package/macports'
|
499
|
+
require 'chef/provider/package/apt'
|
500
|
+
require 'chef/provider/package/yum'
|
501
|
+
require 'chef/provider/package/zypper'
|
502
|
+
require 'chef/provider/package/portage'
|
503
|
+
require 'chef/provider/package/pacman'
|
504
|
+
require 'chef/provider/package/ips'
|
505
|
+
require 'chef/provider/package/solaris'
|
506
|
+
require 'chef/provider/package/smartos'
|
507
|
+
require 'chef/provider/package/aix'
|
508
|
+
require 'chef/provider/package/paludis'
|
509
|
+
|
510
|
+
Chef.set_provider_priority_array :package, [ Homebrew, Macports ], os: "darwin"
|
511
|
+
|
512
|
+
Chef.set_provider_priority_array :package, Apt, platform_family: "debian"
|
513
|
+
Chef.set_provider_priority_array :package, Yum, platform_family: %w(rhel fedora)
|
514
|
+
Chef.set_provider_priority_array :package, Zypper, platform_family: "suse"
|
515
|
+
Chef.set_provider_priority_array :package, Portage, platform: "gentoo"
|
516
|
+
Chef.set_provider_priority_array :package, Pacman, platform: "arch"
|
517
|
+
Chef.set_provider_priority_array :package, Ips, platform: %w(openindiana opensolaris omnios solaris2)
|
518
|
+
Chef.set_provider_priority_array :package, Solaris, platform: "nexentacore"
|
519
|
+
Chef.set_provider_priority_array :package, Solaris, platform: "solaris2", platform_version: '< 5.11'
|
520
|
+
|
521
|
+
Chef.set_provider_priority_array :package, SmartOS, platform: "smartos"
|
522
|
+
Chef.set_provider_priority_array :package, Aix, platform: "aix"
|
523
|
+
Chef.set_provider_priority_array :package, Paludis, platform: "exherbo"
|
524
|
+
|
525
|
+
private
|
526
|
+
|
527
|
+
def shell_out_with_timeout(*command_args)
|
528
|
+
shell_out(*add_timeout_option(command_args))
|
529
|
+
end
|
530
|
+
|
531
|
+
def shell_out_with_timeout!(*command_args)
|
532
|
+
shell_out!(*add_timeout_option(command_args))
|
533
|
+
end
|
534
|
+
|
535
|
+
def add_timeout_option(command_args)
|
536
|
+
args = command_args.dup
|
537
|
+
if args.last.is_a?(Hash)
|
538
|
+
options = args.pop.dup
|
539
|
+
options[:timeout] = new_resource.timeout if new_resource.timeout
|
540
|
+
options[:timeout] = 900 unless options.has_key?(:timeout)
|
541
|
+
args << options
|
542
|
+
else
|
543
|
+
args << { :timeout => new_resource.timeout ? new_resource.timeout : 900 }
|
544
|
+
end
|
545
|
+
args
|
546
|
+
end
|
547
|
+
|
493
548
|
end
|
494
549
|
end
|
495
550
|
end
|
@@ -52,7 +52,7 @@ class Chef
|
|
52
52
|
@package_source_found = ::File.exists?(@new_resource.source)
|
53
53
|
if @package_source_found
|
54
54
|
Chef::Log.debug("#{@new_resource} checking pkg status")
|
55
|
-
ret =
|
55
|
+
ret = shell_out_with_timeout("installp -L -d #{@new_resource.source}")
|
56
56
|
ret.stdout.each_line do | line |
|
57
57
|
case line
|
58
58
|
when /#{@new_resource.package_name}:/
|
@@ -65,7 +65,7 @@ class Chef
|
|
65
65
|
end
|
66
66
|
|
67
67
|
Chef::Log.debug("#{@new_resource} checking install state")
|
68
|
-
ret =
|
68
|
+
ret = shell_out_with_timeout("lslpp -lcq #{@current_resource.package_name}")
|
69
69
|
ret.stdout.each_line do | line |
|
70
70
|
case line
|
71
71
|
when /#{@current_resource.package_name}/
|
@@ -84,7 +84,7 @@ class Chef
|
|
84
84
|
|
85
85
|
def candidate_version
|
86
86
|
return @candidate_version if @candidate_version
|
87
|
-
ret =
|
87
|
+
ret = shell_out_with_timeout("installp -L -d #{@new_resource.source}")
|
88
88
|
ret.stdout.each_line do | line |
|
89
89
|
case line
|
90
90
|
when /\w:#{Regexp.escape(@new_resource.package_name)}:(.*)/
|
@@ -110,10 +110,10 @@ class Chef
|
|
110
110
|
def install_package(name, version)
|
111
111
|
Chef::Log.debug("#{@new_resource} package install options: #{@new_resource.options}")
|
112
112
|
if @new_resource.options.nil?
|
113
|
-
|
113
|
+
shell_out_with_timeout!( "installp -aYF -d #{@new_resource.source} #{@new_resource.package_name}" )
|
114
114
|
Chef::Log.debug("#{@new_resource} installed version #{@new_resource.version} from: #{@new_resource.source}")
|
115
115
|
else
|
116
|
-
|
116
|
+
shell_out_with_timeout!( "installp -aYF #{expand_options(@new_resource.options)} -d #{@new_resource.source} #{@new_resource.package_name}" )
|
117
117
|
Chef::Log.debug("#{@new_resource} installed version #{@new_resource.version} from: #{@new_resource.source}")
|
118
118
|
end
|
119
119
|
end
|
@@ -122,10 +122,10 @@ class Chef
|
|
122
122
|
|
123
123
|
def remove_package(name, version)
|
124
124
|
if @new_resource.options.nil?
|
125
|
-
|
125
|
+
shell_out_with_timeout!( "installp -u #{name}" )
|
126
126
|
Chef::Log.debug("#{@new_resource} removed version #{@new_resource.version}")
|
127
127
|
else
|
128
|
-
|
128
|
+
shell_out_with_timeout!( "installp -u #{expand_options(@new_resource.options)} #{name}" )
|
129
129
|
Chef::Log.debug("#{@new_resource} removed version #{@new_resource.version}")
|
130
130
|
end
|
131
131
|
end
|
@@ -62,7 +62,7 @@ class Chef
|
|
62
62
|
installed_version = nil
|
63
63
|
candidate_version = nil
|
64
64
|
|
65
|
-
|
65
|
+
shell_out_with_timeout!("apt-cache#{expand_options(default_release_options)} policy #{pkg}").stdout.each_line do |line|
|
66
66
|
case line
|
67
67
|
when /^\s{2}Installed: (.+)$/
|
68
68
|
installed_version = $1
|
@@ -78,7 +78,7 @@ class Chef
|
|
78
78
|
if candidate_version == '(none)'
|
79
79
|
# This may not be an appropriate assumption, but it shouldn't break anything that already worked -- btm
|
80
80
|
is_virtual_package = true
|
81
|
-
showpkg =
|
81
|
+
showpkg = shell_out_with_timeout!("apt-cache showpkg #{pkg}").stdout
|
82
82
|
providers = Hash.new
|
83
83
|
showpkg.rpartition(/Reverse Provides: ?#{$/}/)[2].each_line do |line|
|
84
84
|
provider, version = line.split
|
@@ -175,7 +175,7 @@ class Chef
|
|
175
175
|
# interactive prompts. Command is run with default localization rather
|
176
176
|
# than forcing locale to "C", so command output may not be stable.
|
177
177
|
def run_noninteractive(command)
|
178
|
-
|
178
|
+
shell_out_with_timeout!(command, :env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil })
|
179
179
|
end
|
180
180
|
|
181
181
|
end
|
@@ -62,7 +62,7 @@ class Chef
|
|
62
62
|
# Get information from the package if supplied
|
63
63
|
Chef::Log.debug("#{@new_resource} checking dpkg status")
|
64
64
|
|
65
|
-
|
65
|
+
shell_out_with_timeout("dpkg-deb -W #{@new_resource.source}").stdout.each_line do |line|
|
66
66
|
if pkginfo = DPKG_INFO.match(line)
|
67
67
|
@current_resource.package_name(pkginfo[1])
|
68
68
|
@new_resource.version(pkginfo[2])
|
@@ -79,7 +79,7 @@ class Chef
|
|
79
79
|
# Check to see if it is installed
|
80
80
|
package_installed = nil
|
81
81
|
Chef::Log.debug("#{@new_resource} checking install state")
|
82
|
-
status =
|
82
|
+
status = shell_out_with_timeout("dpkg -s #{@current_resource.package_name}")
|
83
83
|
status.stdout.each_line do |line|
|
84
84
|
case line
|
85
85
|
when DPKG_INSTALLED
|
@@ -134,13 +134,13 @@ class Chef
|
|
134
134
|
run_noninteractive("dpkg-reconfigure #{name}")
|
135
135
|
end
|
136
136
|
|
137
|
-
# Runs command via
|
137
|
+
# Runs command via shell_out_with_timeout with magic environment to disable
|
138
138
|
# interactive prompts. Command is run with default localization rather
|
139
139
|
# than forcing locale to "C", so command output may not be stable.
|
140
140
|
#
|
141
141
|
# FIXME: This should be "LC_ALL" => "en_US.UTF-8" in order to stabilize the output and get UTF-8
|
142
142
|
def run_noninteractive(command)
|
143
|
-
|
143
|
+
shell_out_with_timeout!(command, :env => { "DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil })
|
144
144
|
end
|
145
145
|
|
146
146
|
end
|
@@ -32,10 +32,10 @@ class Chef
|
|
32
32
|
|
33
33
|
begin
|
34
34
|
# first check to see if we can import it
|
35
|
-
output =
|
35
|
+
output = shell_out_with_timeout!("#{python_binary_path} -c \"import #{name}\"", :returns=>[0,1]).stderr
|
36
36
|
if output.include? "ImportError"
|
37
37
|
# then check to see if its on the path
|
38
|
-
output =
|
38
|
+
output = shell_out_with_timeout!("#{python_binary_path} -c \"import sys; print sys.path\"", :returns=>[0,1]).stdout
|
39
39
|
if output.downcase.include? "#{name.downcase}"
|
40
40
|
check = true
|
41
41
|
end
|
@@ -73,10 +73,10 @@ class Chef
|
|
73
73
|
package_version = nil
|
74
74
|
if install_check(module_name)
|
75
75
|
begin
|
76
|
-
output =
|
76
|
+
output = shell_out_with_timeout!("#{python_binary_path} -c \"import #{module_name}; print #{module_name}.__version__\"").stdout
|
77
77
|
package_version = output.strip
|
78
78
|
rescue
|
79
|
-
output =
|
79
|
+
output = shell_out_with_timeout!("#{python_binary_path} -c \"import sys; print sys.path\"", :returns=>[0,1]).stdout
|
80
80
|
|
81
81
|
output_array = output.gsub(/[\[\]]/,'').split(/\s*,\s*/)
|
82
82
|
package_path = ""
|
@@ -107,7 +107,7 @@ class Chef
|
|
107
107
|
return @candidate_version if @candidate_version
|
108
108
|
|
109
109
|
# do a dry run to get the latest version
|
110
|
-
result =
|
110
|
+
result = shell_out_with_timeout!("#{easy_install_binary_path} -n #{@new_resource.package_name}", :returns=>[0,1])
|
111
111
|
@candidate_version = result.stdout[/(.*)Best match: (.*) (.*)$/, 3]
|
112
112
|
@candidate_version
|
113
113
|
end
|