chef 16.6.14 → 16.7.61
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -11
- data/Rakefile +21 -14
- data/chef-universal-mingw32.gemspec +1 -1
- data/lib/chef/application/knife.rb +1 -1
- data/lib/chef/chef_fs/data_handler/cookbook_data_handler.rb +1 -1
- data/lib/chef/chef_fs/file_pattern.rb +1 -1
- data/lib/chef/client.rb +1 -1
- data/lib/chef/cookbook_manifest.rb +1 -1
- data/lib/chef/cookbook_site_streaming_uploader.rb +1 -1
- data/lib/chef/cookbook_version.rb +2 -5
- data/lib/chef/environment.rb +1 -1
- data/lib/chef/exceptions.rb +1 -1
- data/lib/chef/file_access_control/windows.rb +1 -4
- data/lib/chef/formatters/error_inspectors/compile_error_inspector.rb +2 -2
- data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +4 -4
- data/lib/chef/guard_interpreter/resource_guard_interpreter.rb +28 -39
- data/lib/chef/http.rb +2 -12
- data/lib/chef/http/basic_client.rb +1 -1
- data/lib/chef/http/http_request.rb +1 -1
- data/lib/chef/http/socketless_chef_zero_client.rb +1 -1
- data/lib/chef/json_compat.rb +2 -7
- data/lib/chef/key.rb +1 -1
- data/lib/chef/knife/bootstrap.rb +2 -1
- data/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb +2 -2
- data/lib/chef/knife/config_show.rb +1 -1
- data/lib/chef/knife/core/cookbook_scm_repo.rb +1 -1
- data/lib/chef/knife/core/gem_glob_loader.rb +1 -1
- data/lib/chef/knife/core/windows_bootstrap_context.rb +7 -4
- data/lib/chef/mixin/convert_to_class_name.rb +0 -56
- data/lib/chef/mixin/openssl_helper.rb +1 -1
- data/lib/chef/mixin/properties.rb +2 -0
- data/lib/chef/mixin/unformatter.rb +1 -1
- data/lib/chef/node/attribute_collections.rb +2 -6
- data/lib/chef/powershell.rb +5 -2
- data/lib/chef/property.rb +1 -1
- data/lib/chef/provider/cron.rb +2 -13
- data/lib/chef/provider/group.rb +14 -6
- data/lib/chef/provider/group/windows.rb +12 -1
- data/lib/chef/provider/ifconfig.rb +7 -7
- data/lib/chef/provider/ifconfig/debian.rb +5 -7
- data/lib/chef/provider/ifconfig/redhat.rb +3 -1
- data/lib/chef/provider/launchd.rb +1 -11
- data/lib/chef/provider/mount.rb +18 -1
- data/lib/chef/provider/mount/linux.rb +4 -0
- data/lib/chef/provider/mount/mount.rb +41 -43
- data/lib/chef/provider/package.rb +3 -0
- data/lib/chef/provider/package/apt.rb +1 -1
- data/lib/chef/provider/package/chocolatey.rb +6 -6
- data/lib/chef/provider/package/freebsd/base.rb +3 -2
- data/lib/chef/provider/package/freebsd/pkgng.rb +1 -1
- data/lib/chef/provider/package/ips.rb +1 -1
- data/lib/chef/provider/package/powershell.rb +2 -3
- data/lib/chef/provider/package/rubygems.rb +1 -1
- data/lib/chef/provider/package/snap.rb +1 -3
- data/lib/chef/provider/package/solaris.rb +0 -2
- data/lib/chef/provider/package/yum/rpm_utils.rb +1 -1
- data/lib/chef/provider/package/zypper.rb +98 -71
- data/lib/chef/provider/registry_key.rb +4 -3
- data/lib/chef/provider/route.rb +2 -2
- data/lib/chef/provider/service/debian.rb +2 -1
- data/lib/chef/provider/user.rb +17 -9
- data/lib/chef/provider/user/aix.rb +1 -1
- data/lib/chef/provider/user/mac.rb +12 -4
- data/lib/chef/provider/user/solaris.rb +1 -1
- data/lib/chef/provider/user/windows.rb +10 -3
- data/lib/chef/providers.rb +0 -3
- data/lib/chef/pwsh.rb +7 -0
- data/lib/chef/resource/bash.rb +119 -1
- data/lib/chef/resource/batch.rb +1 -1
- data/lib/chef/resource/breakpoint.rb +3 -1
- data/lib/chef/resource/build_essential.rb +5 -8
- data/lib/chef/resource/csh.rb +2 -2
- data/lib/chef/resource/execute.rb +6 -4
- data/lib/chef/resource/file.rb +1 -1
- data/lib/chef/resource/homebrew_update.rb +4 -1
- data/lib/chef/resource/hostname.rb +2 -2
- data/lib/chef/resource/ifconfig.rb +52 -5
- data/lib/chef/resource/ksh.rb +3 -3
- data/lib/chef/resource/lwrp_base.rb +3 -5
- data/lib/chef/resource/mount.rb +7 -1
- data/lib/chef/resource/perl.rb +2 -2
- data/lib/chef/resource/plist.rb +2 -6
- data/lib/chef/resource/powershell_package_source.rb +19 -18
- data/lib/chef/resource/powershell_script.rb +7 -10
- data/lib/chef/resource/python.rb +2 -2
- data/lib/chef/resource/registry_key.rb +93 -2
- data/lib/chef/resource/route.rb +1 -1
- data/lib/chef/resource/ruby.rb +2 -2
- data/lib/chef/resource/scm/_scm.rb +2 -1
- data/lib/chef/resource/scm/git.rb +82 -1
- data/lib/chef/resource/scm/subversion.rb +12 -0
- data/lib/chef/resource/script.rb +2 -2
- data/lib/chef/resource/solaris_package.rb +0 -2
- data/lib/chef/resource/sudo.rb +1 -1
- data/lib/chef/resource/support/client.erb +4 -5
- data/lib/chef/resource/systemd_unit.rb +42 -1
- data/lib/chef/resource/windows_ad_join.rb +9 -9
- data/lib/chef/resource/windows_certificate.rb +6 -6
- data/lib/chef/resource/windows_dfs_server.rb +7 -4
- data/lib/chef/resource/windows_env.rb +173 -0
- data/lib/chef/resource/windows_feature.rb +2 -0
- data/lib/chef/resource/windows_firewall_profile.rb +7 -12
- data/lib/chef/resource/windows_firewall_rule.rb +9 -11
- data/lib/chef/resource/windows_font.rb +1 -1
- data/lib/chef/resource/windows_package.rb +1 -0
- data/lib/chef/resource/windows_path.rb +38 -0
- data/lib/chef/resource/windows_security_policy.rb +5 -5
- data/lib/chef/resource/windows_service.rb +108 -0
- data/lib/chef/resource/windows_share.rb +18 -18
- data/lib/chef/resource/windows_task.rb +629 -28
- data/lib/chef/resource/windows_workgroup.rb +6 -4
- data/lib/chef/resource/yum_repository.rb +1 -1
- data/lib/chef/resource_collection/resource_set.rb +1 -5
- data/lib/chef/resource_inspector.rb +77 -75
- data/lib/chef/run_lock.rb +1 -1
- data/lib/chef/server_api.rb +0 -4
- data/lib/chef/shell/ext.rb +1 -1
- data/lib/chef/util/dsc/lcm_output_parser.rb +1 -3
- data/lib/chef/util/dsc/local_configuration_manager.rb +1 -1
- data/lib/chef/util/powershell/cmdlet.rb +3 -9
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/security/sid.rb +1 -1
- data/spec/functional/mixin/powershell_out_spec.rb +4 -4
- data/spec/functional/resource/apt_package_spec.rb +4 -6
- data/spec/functional/resource/chocolatey_package_spec.rb +3 -3
- data/spec/functional/resource/cron_spec.rb +3 -3
- data/spec/functional/resource/dsc_script_spec.rb +3 -3
- data/spec/functional/resource/mount_spec.rb +10 -2
- data/spec/functional/resource/powershell_package_source_spec.rb +107 -0
- data/spec/functional/resource/windows_certificate_spec.rb +10 -6
- data/spec/functional/resource/windows_firewall_rule_spec.rb +93 -0
- data/spec/functional/resource/windows_package_spec.rb +36 -10
- data/spec/functional/resource/windows_share_spec.rb +103 -0
- data/spec/functional/resource/windows_task_spec.rb +2 -3
- data/spec/functional/resource/zypper_package_spec.rb +11 -0
- data/spec/integration/knife/client_key_create_spec.rb +1 -1
- data/spec/integration/knife/node_create_spec.rb +1 -1
- data/spec/integration/knife/node_environment_set_spec.rb +1 -1
- data/spec/integration/knife/node_run_list_add_spec.rb +4 -4
- data/spec/integration/knife/node_run_list_remove_spec.rb +1 -1
- data/spec/integration/knife/node_run_list_set_spec.rb +1 -1
- data/spec/integration/knife/node_show_spec.rb +1 -1
- data/spec/integration/recipes/notifies_spec.rb +1 -1
- data/spec/integration/recipes/provider_choice.rb +2 -2
- data/spec/support/lib/chef/resource/cat.rb +1 -1
- data/spec/support/lib/chef/resource/one_two_three_four.rb +1 -1
- data/spec/support/mock/platform.rb +24 -16
- data/spec/support/platform_helpers.rb +6 -4
- data/spec/support/shared/unit/knife_shared.rb +1 -1
- data/spec/support/shared/unit/script_resource.rb +4 -4
- data/spec/support/shared/unit/windows_script_resource.rb +1 -1
- data/spec/unit/client_spec.rb +16 -0
- data/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb +11 -11
- data/spec/unit/knife/client_create_spec.rb +2 -2
- data/spec/unit/knife/configure_client_spec.rb +5 -5
- data/spec/unit/knife/configure_spec.rb +3 -3
- data/spec/unit/knife/cookbook_delete_spec.rb +2 -2
- data/spec/unit/knife/cookbook_download_spec.rb +2 -2
- data/spec/unit/knife/cookbook_list_spec.rb +2 -2
- data/spec/unit/knife/cookbook_metadata_spec.rb +3 -3
- data/spec/unit/knife/environment_compare_spec.rb +3 -3
- data/spec/unit/knife/supermarket_download_spec.rb +8 -8
- data/spec/unit/knife/supermarket_list_spec.rb +3 -3
- data/spec/unit/knife/supermarket_search_spec.rb +1 -1
- data/spec/unit/knife/tag_create_spec.rb +1 -1
- data/spec/unit/knife/tag_delete_spec.rb +1 -1
- data/spec/unit/knife/user_create_spec.rb +1 -1
- data/spec/unit/mixin/which.rb +1 -1
- data/spec/unit/provider/group/windows_spec.rb +6 -0
- data/spec/unit/provider/group_spec.rb +1 -1
- data/spec/unit/provider/mount/linux_spec.rb +10 -0
- data/spec/unit/provider/mount/mount_spec.rb +21 -10
- data/spec/unit/provider/mount/solaris_spec.rb +1 -1
- data/spec/unit/provider/mount_spec.rb +31 -0
- data/spec/unit/provider/package/chocolatey_spec.rb +1 -2
- data/spec/unit/provider/package/powershell_spec.rb +87 -95
- data/spec/unit/provider/package/zypper_spec.rb +0 -25
- data/spec/unit/provider/package_spec.rb +2 -2
- data/spec/unit/provider/subversion_spec.rb +0 -3
- data/spec/unit/provider/user_spec.rb +7 -1
- data/spec/unit/provider/windows_env_spec.rb +18 -34
- data/spec/unit/provider/windows_path_spec.rb +6 -11
- data/spec/unit/provider/windows_task_spec.rb +7 -6
- data/spec/unit/resource/breakpoint_spec.rb +1 -1
- data/spec/unit/resource/build_essential_spec.rb +0 -12
- data/spec/unit/resource/ifconfig_spec.rb +2 -10
- data/spec/unit/resource/mount_spec.rb +18 -5
- data/spec/unit/resource/powershell_package_source_spec.rb +20 -20
- data/spec/unit/resource/powershell_script_spec.rb +4 -74
- data/spec/unit/resource/service_spec.rb +2 -2
- data/spec/unit/resource/solaris_package_spec.rb +8 -10
- data/spec/unit/resource_inspector_spec.rb +3 -3
- data/spec/unit/shell_spec.rb +2 -2
- data/tasks/rspec.rb +1 -1
- metadata +9 -15
- data/lib/chef/monkey_patches/net_http.rb +0 -22
- data/lib/chef/provider/windows_env.rb +0 -210
- data/lib/chef/provider/windows_path.rb +0 -61
- data/lib/chef/provider/windows_task.rb +0 -631
- data/spec/support/mock/constant.rb +0 -52
- data/spec/unit/monkey_patches/uri_spec.rb +0 -34
- data/spec/unit/provider_resolver_spec.rb +0 -885
- data/spec/unit/resource/data/InstallHistory_with_CLT.plist +0 -92
- data/spec/unit/resource/data/InstallHistory_without_CLT.plist +0 -38
@@ -21,6 +21,8 @@ require "chef-utils/dist" unless defined?(ChefUtils::Dist)
|
|
21
21
|
class Chef
|
22
22
|
class Resource
|
23
23
|
class WindowsWorkgroup < Chef::Resource
|
24
|
+
unified_mode true
|
25
|
+
|
24
26
|
provides :windows_workgroup
|
25
27
|
|
26
28
|
description "Use the **windows_workgroup** resource to join or change the workgroup of a Windows host."
|
@@ -90,8 +92,8 @@ class Chef
|
|
90
92
|
|
91
93
|
unless workgroup_member?
|
92
94
|
converge_by("join workstation workgroup #{new_resource.workgroup_name}") do
|
93
|
-
ps_run =
|
94
|
-
raise "Failed to join the workgroup #{new_resource.workgroup_name}: #{ps_run.
|
95
|
+
ps_run = powershell_exec(join_command)
|
96
|
+
raise "Failed to join the workgroup #{new_resource.workgroup_name}: #{ps_run.errors}}" if ps_run.error?
|
95
97
|
|
96
98
|
unless new_resource.reboot == :never
|
97
99
|
reboot "Reboot to join workgroup #{new_resource.workgroup_name}" do
|
@@ -117,10 +119,10 @@ class Chef
|
|
117
119
|
|
118
120
|
# @return [Boolean] is the node a member of the workgroup specified in the resource
|
119
121
|
def workgroup_member?
|
120
|
-
node_workgroup =
|
122
|
+
node_workgroup = powershell_exec!("(Get-WmiObject -Class Win32_ComputerSystem).Workgroup")
|
121
123
|
raise "Failed to determine if system already a member of workgroup #{new_resource.workgroup_name}" if node_workgroup.error?
|
122
124
|
|
123
|
-
node_workgroup.
|
125
|
+
String(node_workgroup.result).downcase.strip == new_resource.workgroup_name.downcase
|
124
126
|
end
|
125
127
|
end
|
126
128
|
end
|
@@ -123,11 +123,7 @@ class Chef
|
|
123
123
|
# * Chef::Exceptions::InvalidResourceSpecification for all invalid input.
|
124
124
|
def validate_lookup_spec!(query_object)
|
125
125
|
case query_object
|
126
|
-
when Chef::Resource
|
127
|
-
true
|
128
|
-
when SINGLE_RESOURCE_MATCH, MULTIPLE_RESOURCE_MATCH, NAMELESS_RESOURCE_MATCH
|
129
|
-
true
|
130
|
-
when Hash
|
126
|
+
when Chef::Resource, SINGLE_RESOURCE_MATCH, MULTIPLE_RESOURCE_MATCH, NAMELESS_RESOURCE_MATCH, Hash
|
131
127
|
true
|
132
128
|
when String
|
133
129
|
raise Chef::Exceptions::InvalidResourceSpecification,
|
@@ -23,94 +23,96 @@ require_relative "node"
|
|
23
23
|
require_relative "resources"
|
24
24
|
require_relative "json_compat"
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
26
|
+
class Chef
|
27
|
+
module ResourceInspector
|
28
|
+
def self.get_default(default)
|
29
|
+
if default.is_a?(Chef::DelayedEvaluator)
|
30
|
+
# ideally we'd get the block we pass to `lazy`, but the best we can do
|
31
|
+
# is to get the source location, which then results in reparsing the source
|
32
|
+
# code for the resource ourselves and just no
|
33
|
+
"lazy default"
|
34
|
+
else
|
35
|
+
default.is_a?(Symbol) ? default.inspect : default # inspect properly returns symbols
|
36
|
+
end
|
35
37
|
end
|
36
|
-
end
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
39
|
+
def self.extract_resource(resource, complete = false)
|
40
|
+
data = {}
|
41
|
+
data[:description] = resource.description
|
42
|
+
# data[:deprecated] = resource.deprecated || false
|
43
|
+
data[:default_action] = resource.default_action
|
44
|
+
data[:actions] = resource.allowed_actions
|
45
|
+
data[:examples] = resource.examples
|
46
|
+
data[:introduced] = resource.introduced
|
47
|
+
data[:preview] = resource.preview_resource
|
47
48
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
49
|
+
properties = unless complete
|
50
|
+
resource.properties.reject { |_, k| k.options[:declared_in] == Chef::Resource || k.options[:skip_docs] }
|
51
|
+
else
|
52
|
+
resource.properties.reject { |_, k| k.options[:skip_docs] }
|
53
|
+
end
|
53
54
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
55
|
+
data[:properties] = properties.each_with_object([]) do |(n, k), acc|
|
56
|
+
opts = k.options
|
57
|
+
acc << { name: n, description: opts[:description],
|
58
|
+
introduced: opts[:introduced], is: opts[:is],
|
59
|
+
deprecated: opts[:deprecated] || false,
|
60
|
+
required: opts[:required] || false,
|
61
|
+
default: opts[:default_description] || get_default(opts[:default]),
|
62
|
+
name_property: opts[:name_property] || false,
|
63
|
+
equal_to: sort_equal_to(opts[:equal_to]) }
|
64
|
+
end
|
65
|
+
data
|
63
66
|
end
|
64
|
-
data
|
65
|
-
end
|
66
67
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
68
|
+
def self.sort_equal_to(equal_to)
|
69
|
+
Array(equal_to).sort.map(&:inspect)
|
70
|
+
rescue ArgumentError
|
71
|
+
Array(equal_to).map(&:inspect)
|
72
|
+
end
|
72
73
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
74
|
+
def self.extract_cookbook(path, complete)
|
75
|
+
path = File.expand_path(path)
|
76
|
+
dir, name = File.split(path)
|
77
|
+
Chef::Cookbook::FileVendor.fetch_from_disk(path)
|
78
|
+
loader = Chef::CookbookLoader.new(dir)
|
79
|
+
cookbook = loader.load_cookbook(name)
|
80
|
+
resources = cookbook.files_for(:resources)
|
80
81
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
82
|
+
resources.each_with_object({}) do |r, res|
|
83
|
+
pth = r["full_path"]
|
84
|
+
cur = Chef::Resource::LWRPBase.build_from_file(name, pth, Chef::RunContext.new(Chef::Node.new, nil, nil))
|
85
|
+
res[cur.resource_name] = extract_resource(cur, complete)
|
86
|
+
end
|
85
87
|
end
|
86
|
-
end
|
87
88
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
89
|
+
# If we're given no resources, dump all of Chef's built ins
|
90
|
+
# otherwise, if we have a path then extract all the resources from the cookbook
|
91
|
+
# or else do a list of built in resources
|
92
|
+
#
|
93
|
+
# @param arguments [Array, String] One of more paths to a cookbook or a resource file to inspect
|
94
|
+
# @param complete [TrueClass, FalseClass] Whether to show properties defined in the base Resource class
|
95
|
+
# @return [String] JSON formatting of all resources
|
96
|
+
def self.inspect(arguments = [], complete: false)
|
97
|
+
output = if arguments.empty?
|
98
|
+
ObjectSpace.each_object(Class).select { |k| k < Chef::Resource }.each_with_object({}) { |klass, acc| acc[klass.resource_name] = extract_resource(klass) }
|
99
|
+
else
|
100
|
+
Array(arguments).each_with_object({}) do |arg, acc|
|
101
|
+
if File.directory?(arg)
|
102
|
+
extract_cookbook(arg, complete).each { |k, v| acc[k] = v }
|
103
|
+
else
|
104
|
+
r = Chef::ResourceResolver.resolve(arg.to_sym)
|
105
|
+
acc[r.resource_name] = extract_resource(r, complete)
|
106
|
+
end
|
105
107
|
end
|
106
108
|
end
|
107
|
-
end
|
108
109
|
|
109
|
-
|
110
|
-
|
110
|
+
Chef::JSONCompat.to_json_pretty(output)
|
111
|
+
end
|
111
112
|
|
112
|
-
|
113
|
-
|
114
|
-
|
113
|
+
def self.start
|
114
|
+
puts inspect(ARGV, complete: true)
|
115
|
+
end
|
115
116
|
|
117
|
+
end
|
116
118
|
end
|
data/lib/chef/run_lock.rb
CHANGED
@@ -173,7 +173,7 @@ class Chef
|
|
173
173
|
# Mutex name is case-sensitive contrary to other things in
|
174
174
|
# windows. "\" is the only invalid character.
|
175
175
|
def acquire_win32_mutex
|
176
|
-
@mutex = Chef::ReservedNames::Win32::Mutex.new("Global\\#{runlock_file.
|
176
|
+
@mutex = Chef::ReservedNames::Win32::Mutex.new("Global\\#{runlock_file.tr('\\', "/").downcase}")
|
177
177
|
mutex.test
|
178
178
|
end
|
179
179
|
|
data/lib/chef/server_api.rb
CHANGED
data/lib/chef/shell/ext.rb
CHANGED
@@ -89,9 +89,7 @@ class Chef
|
|
89
89
|
case op_action
|
90
90
|
when "InDesiredState"
|
91
91
|
current_resource[:skipped] = op_value.strip == "True" ? true : false
|
92
|
-
when "ResourcesInDesiredState"
|
93
|
-
current_resource[:name] = op_value.strip if op_value
|
94
|
-
when "ResourcesNotInDesiredState"
|
92
|
+
when "ResourcesInDesiredState", "ResourcesNotInDesiredState"
|
95
93
|
current_resource[:name] = op_value.strip if op_value
|
96
94
|
when "ReturnValue"
|
97
95
|
current_resource[:context] = nil
|
@@ -105,7 +105,7 @@ class Chef::Util::DSC
|
|
105
105
|
|
106
106
|
def dsc_module_import_failure?(command_output)
|
107
107
|
!! (command_output =~ /\sCimException/ &&
|
108
|
-
command_output
|
108
|
+
command_output.include?("ProviderOperationExecutionFailure") &&
|
109
109
|
command_output =~ /\smodule\s+is\s+installed/)
|
110
110
|
end
|
111
111
|
|
@@ -31,13 +31,9 @@ class Chef
|
|
31
31
|
@node = node
|
32
32
|
|
33
33
|
case output_format
|
34
|
-
when nil
|
34
|
+
when nil, :text
|
35
35
|
@json_format = false
|
36
|
-
when :json
|
37
|
-
@json_format = true
|
38
|
-
when :text
|
39
|
-
@json_format = false
|
40
|
-
when :object
|
36
|
+
when :json, :object
|
41
37
|
@json_format = true
|
42
38
|
else
|
43
39
|
raise ArgumentError, "Invalid output format #{output_format} specified"
|
@@ -128,9 +124,7 @@ class Chef
|
|
128
124
|
switch_present = true
|
129
125
|
|
130
126
|
case switch_value
|
131
|
-
when Numeric
|
132
|
-
switch_argument = switch_value.to_s
|
133
|
-
when Float
|
127
|
+
when Numeric, Float
|
134
128
|
switch_argument = switch_value.to_s
|
135
129
|
when FalseClass
|
136
130
|
switch_present = false
|
data/lib/chef/version.rb
CHANGED
@@ -321,7 +321,7 @@ class Chef
|
|
321
321
|
while status == ERROR_MORE_DATA
|
322
322
|
status = NetUserEnum(servername, level, filter, bufptr, prefmaxlen, entriesread, totalentries, resume_handle)
|
323
323
|
|
324
|
-
if
|
324
|
+
if [NERR_Success, ERROR_MORE_DATA].include?(status)
|
325
325
|
Array.new(entriesread.read_long) do |i|
|
326
326
|
user_info = USER_INFO_3.new(bufptr.read_pointer + i * USER_INFO_3.size)
|
327
327
|
# Check if the account is the Administrator account
|
@@ -23,15 +23,15 @@ describe Chef::Mixin::PowershellOut, :windows_only do
|
|
23
23
|
|
24
24
|
describe "#powershell_out" do
|
25
25
|
it "runs a powershell command and collects stdout" do
|
26
|
-
expect(powershell_out("get-process").run_command.stdout).to match
|
26
|
+
expect(powershell_out("get-process").run_command.stdout).to match(/Handles/)
|
27
27
|
end
|
28
28
|
|
29
29
|
it "uses :powershell by default" do
|
30
|
-
expect(powershell_out("$PSVersionTable").run_command.stdout).to match
|
30
|
+
expect(powershell_out("$PSVersionTable").run_command.stdout).to match(/CLRVersion/)
|
31
31
|
end
|
32
32
|
|
33
33
|
it ":pwsh interpreter uses core edition", :pwsh_installed do
|
34
|
-
expect(powershell_out("$PSVersionTable", :pwsh).run_command.stdout).to match
|
34
|
+
expect(powershell_out("$PSVersionTable", :pwsh).run_command.stdout).to match(/Core/)
|
35
35
|
end
|
36
36
|
|
37
37
|
it "does not raise exceptions when the command is invalid" do
|
@@ -41,7 +41,7 @@ describe Chef::Mixin::PowershellOut, :windows_only do
|
|
41
41
|
|
42
42
|
describe "#powershell_out!" do
|
43
43
|
it "runs a powershell command and collects stdout" do
|
44
|
-
expect(powershell_out!("get-process").run_command.stdout).to match
|
44
|
+
expect(powershell_out!("get-process").run_command.stdout).to match(/Handles/)
|
45
45
|
end
|
46
46
|
|
47
47
|
it "raises exceptions when the command is invalid" do
|
@@ -39,9 +39,7 @@ module AptServer
|
|
39
39
|
def tcp_test_port(hostname, port)
|
40
40
|
tcp_socket = TCPSocket.new(hostname, port)
|
41
41
|
true
|
42
|
-
rescue Errno::ETIMEDOUT
|
43
|
-
false
|
44
|
-
rescue Errno::ECONNREFUSED
|
42
|
+
rescue Errno::ETIMEDOUT, Errno::ECONNREFUSED
|
45
43
|
false
|
46
44
|
ensure
|
47
45
|
tcp_socket && tcp_socket.close
|
@@ -326,7 +324,7 @@ describe Chef::Resource::AptPackage, metadata do
|
|
326
324
|
pkg_check = shell_out!("dpkg -l chef-integration-test", returns: [0, 1])
|
327
325
|
|
328
326
|
if pkg_check.exitstatus == 0
|
329
|
-
expect(pkg_check.stdout).to match(/un
|
327
|
+
expect(pkg_check.stdout).to match(/un\s+chef-integration-test/)
|
330
328
|
end
|
331
329
|
end
|
332
330
|
|
@@ -359,7 +357,7 @@ describe Chef::Resource::AptPackage, metadata do
|
|
359
357
|
it "upgrades the package for action :upgrade" do
|
360
358
|
package_resource.run_action(:upgrade)
|
361
359
|
dpkg_l = shell_out!("dpkg -l chef-integration-test", returns: [0])
|
362
|
-
expect(dpkg_l.stdout).to match(/chef\-integration\-test
|
360
|
+
expect(dpkg_l.stdout).to match(/chef\-integration\-test\s+1\.1\-1/)
|
363
361
|
expect(package_resource).to be_updated_by_last_action
|
364
362
|
end
|
365
363
|
|
@@ -373,7 +371,7 @@ describe Chef::Resource::AptPackage, metadata do
|
|
373
371
|
it "upgrades the package for action :install" do
|
374
372
|
package_resource.run_action(:install)
|
375
373
|
dpkg_l = shell_out!("dpkg -l chef-integration-test", returns: [0])
|
376
|
-
expect(dpkg_l.stdout).to match(/chef\-integration\-test
|
374
|
+
expect(dpkg_l.stdout).to match(/chef\-integration\-test\s+1\.1\-1/)
|
377
375
|
expect(package_resource).to be_updated_by_last_action
|
378
376
|
end
|
379
377
|
end
|
@@ -16,13 +16,13 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
require "spec_helper"
|
19
|
-
require "chef/mixin/
|
19
|
+
require "chef/mixin/shell_out"
|
20
20
|
|
21
21
|
describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
|
22
|
-
include Chef::Mixin::
|
22
|
+
include Chef::Mixin::ShellOut
|
23
23
|
|
24
24
|
let(:package_name) { "test-A" }
|
25
|
-
let(:package_list) { proc {
|
25
|
+
let(:package_list) { proc { shell_out!("choco list -lo -r #{Array(package_name).join(" ")}").stdout.chomp } }
|
26
26
|
let(:package_source) { File.join(CHEF_SPEC_ASSETS, "chocolatey_feed") }
|
27
27
|
|
28
28
|
let(:run_context) do
|
@@ -26,7 +26,7 @@ describe Chef::Resource::Cron, :requires_root, :unix_only do
|
|
26
26
|
# Platform specific validation routines.
|
27
27
|
def cron_should_exists(cron_name, command)
|
28
28
|
case ohai[:platform]
|
29
|
-
when "aix", "
|
29
|
+
when "aix", "solaris2", "omnios"
|
30
30
|
expect(shell_out("crontab -l #{new_resource.user} | grep \"#{cron_name}\"").exitstatus).to eq(0)
|
31
31
|
expect(shell_out("crontab -l #{new_resource.user} | grep \"#{cron_name}\"").stdout.lines.to_a.size).to eq(1)
|
32
32
|
expect(shell_out("crontab -l #{new_resource.user} | grep \"#{command}\"").exitstatus).to eq(0)
|
@@ -41,7 +41,7 @@ describe Chef::Resource::Cron, :requires_root, :unix_only do
|
|
41
41
|
|
42
42
|
def cron_should_not_exists(cron_name)
|
43
43
|
case ohai[:platform]
|
44
|
-
when "aix", "
|
44
|
+
when "aix", "solaris2", "omnios"
|
45
45
|
expect(shell_out("crontab -l #{new_resource.user} | grep \"#{cron_name}\"").exitstatus).to eq(1)
|
46
46
|
expect(shell_out("crontab -l #{new_resource.user} | grep \"#{new_resource.command}\"").stdout.lines.to_a.size).to eq(0)
|
47
47
|
else
|
@@ -113,7 +113,7 @@ describe Chef::Resource::Cron, :requires_root, :unix_only do
|
|
113
113
|
end
|
114
114
|
end
|
115
115
|
|
116
|
-
exclude_solaris = %w{solaris
|
116
|
+
exclude_solaris = %w{solaris solaris2 omnios}.include?(ohai[:platform])
|
117
117
|
describe "create action with various attributes", external: exclude_solaris do
|
118
118
|
def create_and_validate_with_property(resource, attribute, value)
|
119
119
|
if ohai[:platform] == "aix"
|
@@ -17,13 +17,13 @@
|
|
17
17
|
#
|
18
18
|
|
19
19
|
require "spec_helper"
|
20
|
-
require "chef/mixin/
|
20
|
+
require "chef/mixin/powershell_exec"
|
21
21
|
require "chef/mixin/windows_architecture_helper"
|
22
22
|
require "support/shared/integration/integration_helper"
|
23
23
|
|
24
24
|
describe Chef::Resource::DscScript, :windows_powershell_dsc_only do
|
25
25
|
include Chef::Mixin::WindowsArchitectureHelper
|
26
|
-
include Chef::Mixin::
|
26
|
+
include Chef::Mixin::PowershellExec
|
27
27
|
before(:all) do
|
28
28
|
@temp_dir = ::Dir.mktmpdir("dsc-functional-test")
|
29
29
|
# enable the HTTP listener if it is not already enabled needed by underlying DSC engine
|
@@ -33,7 +33,7 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only do
|
|
33
33
|
winrm create winrm/config/Listener?Address=*+Transport=HTTP
|
34
34
|
}
|
35
35
|
CODE
|
36
|
-
|
36
|
+
powershell_exec!(winrm_code)
|
37
37
|
end
|
38
38
|
|
39
39
|
after(:all) do
|