chef 12.17.44-universal-mingw32 → 12.18.31-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/README.md +3 -2
- data/Rakefile +9 -0
- data/VERSION +1 -1
- data/acceptance/Gemfile.lock +17 -17
- data/distro/common/html/knife_environment.html +4 -8
- data/distro/common/man/man1/knife-environment.1 +4 -16
- data/distro/powershell/chef/chef.psm1 +139 -24
- data/lib/chef/application.rb +5 -4
- data/lib/chef/application/windows_service_manager.rb +6 -4
- data/lib/chef/chef_fs/chef_fs_data_store.rb +1 -1
- data/lib/chef/chef_fs/command_line.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb +8 -1
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +1 -1
- data/lib/chef/cookbook/chefignore.rb +1 -1
- data/lib/chef/cookbook/cookbook_version_loader.rb +4 -4
- data/lib/chef/cookbook/metadata.rb +2 -2
- data/lib/chef/cookbook_loader.rb +1 -1
- data/lib/chef/data_collector.rb +24 -13
- data/lib/chef/data_collector/messages.rb +8 -6
- data/lib/chef/data_collector/messages/helpers.rb +1 -1
- data/lib/chef/deprecated.rb +30 -0
- data/lib/chef/dsl/platform_introspection.rb +2 -2
- data/lib/chef/encrypted_data_bag_item.rb +1 -1
- data/lib/chef/encrypted_data_bag_item/decryptor.rb +2 -2
- data/lib/chef/environment.rb +1 -1
- data/lib/chef/exceptions.rb +5 -5
- data/lib/chef/file_access_control/unix.rb +5 -5
- data/lib/chef/formatters/error_description.rb +1 -1
- data/lib/chef/http/basic_client.rb +1 -1
- data/lib/chef/http/json_input.rb +2 -2
- data/lib/chef/knife.rb +1 -1
- data/lib/chef/knife/cookbook_site_install.rb +1 -1
- data/lib/chef/knife/core/cookbook_scm_repo.rb +1 -1
- data/lib/chef/knife/core/ui.rb +1 -1
- data/lib/chef/mixin/command.rb +1 -0
- data/lib/chef/mixin/deep_merge.rb +1 -1
- data/lib/chef/mixin/shell_out.rb +58 -3
- data/lib/chef/mixin/which.rb +5 -9
- data/lib/chef/mixin/wide_string.rb +1 -1
- data/lib/chef/node.rb +1 -1
- data/lib/chef/node/attribute.rb +4 -5
- data/lib/chef/node_map.rb +18 -2
- data/lib/chef/platform/provider_handler_map.rb +2 -2
- data/lib/chef/platform/provider_mapping.rb +5 -0
- data/lib/chef/platform/resource_handler_map.rb +2 -2
- data/lib/chef/provider/env/windows.rb +1 -1
- data/lib/chef/provider/git.rb +1 -1
- data/lib/chef/provider/group.rb +41 -46
- data/lib/chef/provider/group/aix.rb +12 -19
- data/lib/chef/provider/group/dscl.rb +46 -43
- data/lib/chef/provider/group/gpasswd.rb +7 -7
- data/lib/chef/provider/group/groupadd.rb +29 -34
- data/lib/chef/provider/group/groupmod.rb +26 -31
- data/lib/chef/provider/group/pw.rb +28 -31
- data/lib/chef/provider/group/suse.rb +9 -9
- data/lib/chef/provider/group/usermod.rb +10 -11
- data/lib/chef/provider/group/windows.rb +18 -20
- data/lib/chef/provider/ifconfig.rb +52 -63
- data/lib/chef/provider/ifconfig/aix.rb +23 -28
- data/lib/chef/provider/ifconfig/debian.rb +23 -22
- data/lib/chef/provider/ifconfig/redhat.rb +12 -12
- data/lib/chef/provider/mount/mount.rb +1 -1
- data/lib/chef/provider/osx_profile.rb +4 -2
- data/lib/chef/provider/package.rb +16 -7
- data/lib/chef/provider/package/chocolatey.rb +3 -1
- data/lib/chef/provider/package/dnf.rb +183 -0
- data/lib/chef/provider/package/dnf/dnf_helper.py +91 -0
- data/lib/chef/provider/package/dnf/python_helper.rb +120 -0
- data/lib/chef/provider/package/dnf/version.rb +56 -0
- data/lib/chef/provider/package/easy_install.rb +1 -1
- data/lib/chef/provider/package/freebsd/base.rb +1 -1
- data/lib/chef/provider/package/freebsd/pkgng.rb +1 -1
- data/lib/chef/provider/package/powershell.rb +3 -3
- data/lib/chef/provider/package/windows.rb +1 -1
- data/lib/chef/provider/package/zypper.rb +1 -1
- data/lib/chef/provider/route.rb +186 -184
- data/lib/chef/provider/service/arch.rb +2 -2
- data/lib/chef/provider/service/freebsd.rb +1 -1
- data/lib/chef/provider/service/gentoo.rb +2 -2
- data/lib/chef/provider/service/insserv.rb +2 -2
- data/lib/chef/provider/service/macosx.rb +2 -2
- data/lib/chef/provider/service/openbsd.rb +1 -1
- data/lib/chef/provider/service/redhat.rb +2 -2
- data/lib/chef/provider/support/yum_repo.erb +10 -3
- data/lib/chef/provider/user.rb +17 -20
- data/lib/chef/provider/user/aix.rb +23 -24
- data/lib/chef/provider/user/dscl.rb +56 -53
- data/lib/chef/provider/user/linux.rb +13 -16
- data/lib/chef/provider/user/pw.rb +26 -30
- data/lib/chef/provider/user/solaris.rb +11 -12
- data/lib/chef/provider/user/useradd.rb +20 -22
- data/lib/chef/provider/user/windows.rb +19 -22
- data/lib/chef/provider_resolver.rb +4 -2
- data/lib/chef/providers.rb +1 -0
- data/lib/chef/resource.rb +7 -0
- data/lib/chef/resource/chocolatey_package.rb +1 -0
- data/lib/chef/resource/dnf_package.rb +64 -0
- data/lib/chef/resource/file/verification.rb +6 -4
- data/lib/chef/resource/yum_package.rb +18 -14
- data/lib/chef/resource/yum_repository.rb +1 -1
- data/lib/chef/resource_reporter.rb +11 -0
- data/lib/chef/resources.rb +1 -0
- data/lib/chef/scan_access_control.rb +4 -4
- data/lib/chef/util/dsc/resource_store.rb +1 -1
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/memory.rb +1 -1
- data/lib/chef/win32/security.rb +2 -2
- data/lib/chef/win32/security/sid.rb +2 -2
- data/spec/functional/assets/yumrepo/chef_rpm-1.10-1.fc24.i686.rpm +0 -0
- data/spec/functional/assets/yumrepo/chef_rpm-1.10-1.fc24.src.rpm +0 -0
- data/spec/functional/assets/yumrepo/chef_rpm-1.10-1.fc24.x86_64.rpm +0 -0
- data/spec/functional/assets/yumrepo/chef_rpm-1.2-1.fc24.i686.rpm +0 -0
- data/spec/functional/assets/yumrepo/chef_rpm-1.2-1.fc24.src.rpm +0 -0
- data/spec/functional/assets/yumrepo/chef_rpm-1.2-1.fc24.x86_64.rpm +0 -0
- data/spec/functional/assets/yumrepo/repodata/313329137b55fd333b2dc66394a6661a2befa6cc535d8460d92a4a78a9c581f0-primary.sqlite.bz2 +0 -0
- data/spec/functional/assets/yumrepo/repodata/31ac4db5d5ac593728fcc26aef82b7b93c4cc4dbec843786b1845b939b658553-other.xml.gz +0 -0
- data/spec/functional/assets/yumrepo/repodata/4ac40fa3c6728c1401318e2e20a997436624e83dcf7a5f952b851ef422637773-filelists.sqlite.bz2 +0 -0
- data/spec/functional/assets/yumrepo/repodata/66391e53f0510b98b3f0b79f40ba1048026d9a1ef20905d9c40ba6f5411f3243-primary.xml.gz +0 -0
- data/spec/functional/assets/yumrepo/repodata/8b34697595fcc87928e12d24644dda9462c3857bd932861e28bc77ae1f31be16-filelists.xml.gz +0 -0
- data/spec/functional/assets/yumrepo/repodata/b97cca3fe14bcf06c52be4449b6108f7731239ff221111dcce8aada5467f60dc-other.sqlite.bz2 +0 -0
- data/spec/functional/assets/yumrepo/repodata/repomd.xml +55 -0
- data/spec/functional/resource/dnf_package_spec.rb +686 -0
- data/spec/functional/resource/dsc_script_spec.rb +1 -0
- data/spec/functional/resource/user/useradd_spec.rb +10 -1
- data/spec/integration/knife/chef_repo_path_spec.rb +2 -2
- data/spec/integration/recipes/recipe_dsl_spec.rb +3 -0
- data/spec/integration/recipes/resource_load_spec.rb +3 -3
- data/spec/spec_helper.rb +5 -3
- data/spec/support/lib/chef/provider/snakeoil.rb +1 -0
- data/spec/support/lib/chef/resource/cat.rb +1 -0
- data/spec/support/lib/chef/resource/one_two_three_four.rb +1 -0
- data/spec/support/lib/chef/resource/openldap_includer.rb +2 -0
- data/spec/support/lib/chef/resource/with_state.rb +2 -0
- data/spec/support/lib/chef/resource/zen_master.rb +1 -0
- data/spec/unit/cookbook/metadata_spec.rb +3 -3
- data/spec/unit/data_collector/messages/helpers_spec.rb +7 -0
- data/spec/unit/data_collector_spec.rb +56 -0
- data/spec/unit/decorator/lazy_spec.rb +1 -1
- data/spec/unit/environment_spec.rb +1 -1
- data/spec/unit/lwrp_spec.rb +3 -4
- data/spec/unit/node_spec.rb +23 -2
- data/spec/unit/platform_spec.rb +1 -0
- data/spec/unit/provider/group/dscl_spec.rb +29 -29
- data/spec/unit/provider/group/gpasswd_spec.rb +10 -10
- data/spec/unit/provider/group/groupadd_spec.rb +31 -30
- data/spec/unit/provider/group/groupmod_spec.rb +16 -16
- data/spec/unit/provider/group/pw_spec.rb +11 -11
- data/spec/unit/provider/group/suse_spec.rb +5 -5
- data/spec/unit/provider/group/usermod_spec.rb +15 -15
- data/spec/unit/provider/ifconfig/aix_spec.rb +14 -14
- data/spec/unit/provider/ifconfig/debian_spec.rb +10 -22
- data/spec/unit/provider/ifconfig/redhat_spec.rb +4 -4
- data/spec/unit/provider/ifconfig_spec.rb +18 -19
- data/spec/unit/provider/package/chocolatey_spec.rb +21 -21
- data/spec/unit/provider/package/msu_spec.rb +1 -1
- data/spec/unit/provider/route_spec.rb +21 -21
- data/spec/unit/provider/user/dscl_spec.rb +54 -57
- data/spec/unit/provider/user/linux_spec.rb +5 -5
- data/spec/unit/provider/user/pw_spec.rb +26 -22
- data/spec/unit/provider/user/windows_spec.rb +4 -4
- data/spec/unit/provider/user_spec.rb +19 -21
- data/spec/unit/provider_resolver_spec.rb +1 -0
- data/spec/unit/resource/chocolatey_package_spec.rb +12 -0
- data/spec/unit/resource/dnf_package_spec.rb +99 -0
- data/spec/unit/resource/remote_file_spec.rb +2 -2
- data/spec/unit/resource/yum_package_spec.rb +20 -0
- data/spec/unit/resource_reporter_spec.rb +24 -0
- data/spec/unit/resource_spec.rb +2 -0
- data/spec/unit/runner_spec.rb +1 -0
- data/tasks/bin/bundle-platform +1 -1
- data/tasks/gemfile_util.rb +2 -2
- data/tasks/templates/prerelease.md.erb +1 -10
- data/tasks/templates/release.md.erb +1 -9
- metadata +24 -5
- data/lib/chef/platform/handler_map.rb +0 -40
data/lib/chef/http/json_input.rb
CHANGED
@@ -33,7 +33,7 @@ class Chef
|
|
33
33
|
|
34
34
|
def handle_request(method, url, headers = {}, data = false)
|
35
35
|
if data && should_encode_as_json?(headers)
|
36
|
-
headers.delete_if { |key, _value| key.casecmp("content-type")
|
36
|
+
headers.delete_if { |key, _value| key.casecmp("content-type") == 0 }
|
37
37
|
headers["Content-Type"] = "application/json"
|
38
38
|
json_opts = {}
|
39
39
|
json_opts[:validate_utf8] = opts[:validate_utf8] if opts.has_key?(:validate_utf8)
|
@@ -64,7 +64,7 @@ class Chef
|
|
64
64
|
# ruby/Net::HTTP don't enforce capitalized headers (it normalizes them
|
65
65
|
# for you before sending the request), so we have to account for all
|
66
66
|
# the variations we might find
|
67
|
-
requested_content_type = headers.find { |k, v| k.casecmp("content-type")
|
67
|
+
requested_content_type = headers.find { |k, v| k.casecmp("content-type") == 0 }
|
68
68
|
requested_content_type.nil? || requested_content_type.last.include?("json")
|
69
69
|
end
|
70
70
|
|
data/lib/chef/knife.rb
CHANGED
@@ -145,7 +145,7 @@ class Chef
|
|
145
145
|
end
|
146
146
|
|
147
147
|
def self.subcommand_class_from(args)
|
148
|
-
if args.size == 1 && args[0].strip.casecmp("rehash")
|
148
|
+
if args.size == 1 && args[0].strip.casecmp("rehash") == 0
|
149
149
|
# To prevent issues with the rehash file not pointing to the correct plugins,
|
150
150
|
# we always use the glob loader when regenerating the rehash file
|
151
151
|
@subcommand_loader = Chef::Knife::SubcommandLoader.gem_glob_loader(chef_config_dir)
|
@@ -83,7 +83,7 @@ class Chef
|
|
83
83
|
# Check to ensure we have a valid source of cookbooks before continuing
|
84
84
|
#
|
85
85
|
@install_path = File.expand_path(Array(config[:cookbook_path]).first)
|
86
|
-
ui.info "Installing
|
86
|
+
ui.info "Installing #{@cookbook_name} to #{@install_path}"
|
87
87
|
|
88
88
|
@repo = CookbookSCMRepo.new(@install_path, ui, config)
|
89
89
|
#cookbook_path = File.join(vendor_path, name_args[0])
|
@@ -122,7 +122,7 @@ class Chef
|
|
122
122
|
git("branch --no-color").stdout.lines.any? { |l| l =~ /\s#{Regexp.escape(branch_name)}(?:\s|$)/ }
|
123
123
|
end
|
124
124
|
|
125
|
-
def get_current_branch
|
125
|
+
def get_current_branch
|
126
126
|
ref = git("symbolic-ref HEAD").stdout
|
127
127
|
ref.chomp.split("/")[2]
|
128
128
|
end
|
data/lib/chef/knife/core/ui.rb
CHANGED
@@ -138,7 +138,7 @@ class Chef
|
|
138
138
|
end
|
139
139
|
|
140
140
|
def ask_question(question, opts = {})
|
141
|
-
question
|
141
|
+
question += "[#{opts[:default]}] " if opts[:default]
|
142
142
|
|
143
143
|
if opts[:default] && config[:defaults]
|
144
144
|
opts[:default]
|
data/lib/chef/mixin/command.rb
CHANGED
@@ -107,6 +107,7 @@ class Chef
|
|
107
107
|
end
|
108
108
|
|
109
109
|
def output_of_command(command, args)
|
110
|
+
Chef.deprecated(:run_command, "Chef::Mixin::Command.run_command is deprecated, please use shell_out")
|
110
111
|
Chef::Log.debug("Executing #{command}")
|
111
112
|
stderr_string, stdout_string, status = "", "", nil
|
112
113
|
|
data/lib/chef/mixin/shell_out.rb
CHANGED
@@ -21,6 +21,60 @@ class Chef
|
|
21
21
|
module Mixin
|
22
22
|
module ShellOut
|
23
23
|
|
24
|
+
# PREFERRED APIS:
|
25
|
+
#
|
26
|
+
# shell_out_compact and shell_out_compact! flatten their array arguments and remove nils and pass
|
27
|
+
# the resultant array to shell_out. this actually eliminates spaces-in-args bugs because this:
|
28
|
+
#
|
29
|
+
# shell_out!("command #{arg}")
|
30
|
+
#
|
31
|
+
# becomes two arguments if arg has spaces and requires quotations:
|
32
|
+
#
|
33
|
+
# shell_out!("command '#{arg}'")
|
34
|
+
#
|
35
|
+
# using shell_out_compact! this becomes:
|
36
|
+
#
|
37
|
+
# shell_out_compact!("command", arg)
|
38
|
+
#
|
39
|
+
# and spaces in the arg just works and it does not become two arguments (and the shell quoting around
|
40
|
+
# the argument must actually be removed).
|
41
|
+
#
|
42
|
+
# there's also an implicit join between all the array elements, and nested arrays are flattened which
|
43
|
+
# means that odd where-do-i-put-the-spaces options handling just works, and instead of this:
|
44
|
+
#
|
45
|
+
# opts = "" # needs to be empty string for when foo and bar are both missing
|
46
|
+
# opts << " -foo" if needs_foo? # needs the leading space on both of these
|
47
|
+
# opts << " -bar" if needs_bar?
|
48
|
+
# shell_out!("cmd#{opts}") # have to think way too hard about why there's no space here
|
49
|
+
#
|
50
|
+
# becomes:
|
51
|
+
#
|
52
|
+
# opts = []
|
53
|
+
# opts << "-foo" if needs_foo?
|
54
|
+
# opts << "-bar" if needs_bar?
|
55
|
+
# shell_out_compact!("cmd", opts)
|
56
|
+
#
|
57
|
+
# and opts can be an empty array or nil and it'll work out fine.
|
58
|
+
#
|
59
|
+
# generally its best to use shell_out_compact! in code and setup expectations on shell_out! in tests
|
60
|
+
#
|
61
|
+
|
62
|
+
def shell_out_compact(*args, **options)
|
63
|
+
if options.empty?
|
64
|
+
shell_out(*clean_array(*args))
|
65
|
+
else
|
66
|
+
shell_out(*clean_array(*args), **options)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def shell_out_compact!(*args, **options)
|
71
|
+
if options.empty?
|
72
|
+
shell_out!(*clean_array(*args))
|
73
|
+
else
|
74
|
+
shell_out!(*clean_array(*args), **options)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
24
78
|
# shell_out! runs a command on the system and will raise an error if the command fails, which is what you want
|
25
79
|
# for debugging, shell_out and shell_out! both will display command output to the tty when the log level is debug
|
26
80
|
# Generally speaking, 'extend Chef::Mixin::ShellOut' in your recipes and include 'Chef::Mixin::ShellOut' in your LWRPs
|
@@ -85,10 +139,11 @@ class Chef
|
|
85
139
|
# @param args [String] variable number of string arguments
|
86
140
|
# @return [String] nicely concatenated string or empty string
|
87
141
|
def a_to_s(*args)
|
88
|
-
|
142
|
+
# FIXME: this should be deprecated in favor of shell_out_compact/shell_out_compact!
|
143
|
+
args.flatten.reject { |i| i.nil? || i == "" }.map(&:to_s).join(" ")
|
89
144
|
end
|
90
145
|
|
91
|
-
# Helper for sublcasses to reject nil
|
146
|
+
# Helper for sublcasses to reject nil out of an array. It allows
|
92
147
|
# using the array form of shell_out (which avoids the need to surround arguments with
|
93
148
|
# quote marks to deal with shells).
|
94
149
|
#
|
@@ -105,7 +160,7 @@ class Chef
|
|
105
160
|
# @param args [String] variable number of string arguments
|
106
161
|
# @return [Array] array of strings with nil and null string rejection
|
107
162
|
def clean_array(*args)
|
108
|
-
args.flatten.
|
163
|
+
args.flatten.compact.map(&:to_s)
|
109
164
|
end
|
110
165
|
|
111
166
|
private
|
data/lib/chef/mixin/which.rb
CHANGED
@@ -18,17 +18,13 @@
|
|
18
18
|
class Chef
|
19
19
|
module Mixin
|
20
20
|
module Which
|
21
|
-
def which(cmd,
|
22
|
-
|
23
|
-
|
24
|
-
[ "/bin", "/usr/bin", "/sbin", "/usr/sbin" ]
|
25
|
-
else
|
26
|
-
[ opts[:extra_path] ].flatten
|
27
|
-
end
|
21
|
+
def which(cmd, extra_path: nil)
|
22
|
+
# NOTE: unnecessarily duplicates function of path_sanity
|
23
|
+
extra_path ||= [ "/bin", "/usr/bin", "/sbin", "/usr/sbin" ]
|
28
24
|
paths = ENV["PATH"].split(File::PATH_SEPARATOR) + extra_path
|
29
25
|
paths.each do |path|
|
30
|
-
filename = File.join(path, cmd)
|
31
|
-
return filename if File.executable?(
|
26
|
+
filename = Chef.path_to(File.join(path, cmd))
|
27
|
+
return filename if File.executable?(filename)
|
32
28
|
end
|
33
29
|
false
|
34
30
|
end
|
@@ -34,7 +34,7 @@ class Chef
|
|
34
34
|
ustring = (ustring + "").force_encoding("UTF-8") if ustring.respond_to?(:force_encoding) && ustring.encoding.name != "UTF-8"
|
35
35
|
|
36
36
|
# ensure we have the double-null termination Windows Wide likes
|
37
|
-
ustring
|
37
|
+
ustring += "\000\000" if ustring.length == 0 || ustring[-1].chr != "\000"
|
38
38
|
|
39
39
|
# encode it all as UTF-16LE AKA Windows Wide Character AKA Windows Unicode
|
40
40
|
ustring = begin
|
data/lib/chef/node.rb
CHANGED
data/lib/chef/node/attribute.rb
CHANGED
@@ -416,23 +416,22 @@ class Chef
|
|
416
416
|
|
417
417
|
def normal_unless(*args)
|
418
418
|
return Decorator::Unchain.new(self, :normal_unless) unless args.length > 0
|
419
|
-
write(:normal, *args) if read(*args[0...-1]).nil?
|
419
|
+
write(:normal, *args) if normal.read(*args[0...-1]).nil?
|
420
420
|
end
|
421
421
|
|
422
422
|
def default_unless(*args)
|
423
423
|
return Decorator::Unchain.new(self, :default_unless) unless args.length > 0
|
424
|
-
write(:default, *args) if read(*args[0...-1]).nil?
|
424
|
+
write(:default, *args) if default.read(*args[0...-1]).nil?
|
425
425
|
end
|
426
426
|
|
427
427
|
def override_unless(*args)
|
428
428
|
return Decorator::Unchain.new(self, :override_unless) unless args.length > 0
|
429
|
-
write(:override, *args) if read(*args[0...-1]).nil?
|
429
|
+
write(:override, *args) if override.read(*args[0...-1]).nil?
|
430
430
|
end
|
431
431
|
|
432
432
|
def set_unless(*args)
|
433
433
|
Chef.deprecated(:attributes, "node.set_unless is deprecated and will be removed in Chef 14, please use node.default_unless/node.override_unless (or node.normal_unless if you really need persistence)")
|
434
|
-
|
435
|
-
write(:normal, *args) if read(*args[0...-1]).nil?
|
434
|
+
normal_unless(*args)
|
436
435
|
end
|
437
436
|
|
438
437
|
def has_key?(key)
|
data/lib/chef/node_map.rb
CHANGED
@@ -113,7 +113,7 @@ class Chef
|
|
113
113
|
remaining
|
114
114
|
end
|
115
115
|
|
116
|
-
|
116
|
+
private
|
117
117
|
|
118
118
|
#
|
119
119
|
# Succeeds if:
|
@@ -172,7 +172,8 @@ class Chef
|
|
172
172
|
!!canonical == !!matcher[:canonical]
|
173
173
|
end
|
174
174
|
|
175
|
-
|
175
|
+
# @api private
|
176
|
+
def dispatch_compare_matchers(key, new_matcher, matcher)
|
176
177
|
cmp = compare_matcher_properties(new_matcher, matcher) { |m| m[:block] }
|
177
178
|
return cmp if cmp != 0
|
178
179
|
cmp = compare_matcher_properties(new_matcher, matcher) { |m| m[:filters][:platform_version] }
|
@@ -189,6 +190,21 @@ class Chef
|
|
189
190
|
0
|
190
191
|
end
|
191
192
|
|
193
|
+
#
|
194
|
+
# "provides" lines with identical filters sort by class name (ascending).
|
195
|
+
#
|
196
|
+
def compare_matchers(key, new_matcher, matcher)
|
197
|
+
cmp = dispatch_compare_matchers(key, new_matcher, matcher)
|
198
|
+
if cmp == 0
|
199
|
+
# Sort by class name (ascending) as well, if all other properties
|
200
|
+
# are exactly equal
|
201
|
+
if new_matcher[:value].is_a?(Class) && !new_matcher[:override]
|
202
|
+
cmp = compare_matcher_properties(new_matcher, matcher) { |m| m[:value].name }
|
203
|
+
end
|
204
|
+
end
|
205
|
+
cmp
|
206
|
+
end
|
207
|
+
|
192
208
|
def compare_matcher_properties(new_matcher, matcher)
|
193
209
|
a = yield(new_matcher)
|
194
210
|
b = yield(matcher)
|
@@ -17,12 +17,12 @@
|
|
17
17
|
#
|
18
18
|
|
19
19
|
require "singleton"
|
20
|
-
require "chef/
|
20
|
+
require "chef/node_map"
|
21
21
|
|
22
22
|
class Chef
|
23
23
|
class Platform
|
24
24
|
# @api private
|
25
|
-
class ProviderHandlerMap < Chef::
|
25
|
+
class ProviderHandlerMap < Chef::NodeMap
|
26
26
|
include Singleton
|
27
27
|
end
|
28
28
|
end
|
@@ -35,6 +35,7 @@ class Chef
|
|
35
35
|
include Chef::Mixin::ParamsValidate
|
36
36
|
|
37
37
|
def find(name, version)
|
38
|
+
Chef.deprecated(:chef_platform_methods, "#{self.class.name}.find is deprecated")
|
38
39
|
provider_map = platforms[:default].clone
|
39
40
|
|
40
41
|
name_sym = name
|
@@ -90,6 +91,7 @@ class Chef
|
|
90
91
|
end
|
91
92
|
|
92
93
|
def provider_for_resource(resource, action = :nothing)
|
94
|
+
Chef.deprecated(:chef_platform_methods, "#{self.class.name}.provider_for_resource is deprecated")
|
93
95
|
node = resource.run_context && resource.run_context.node
|
94
96
|
raise ArgumentError, "Cannot find the provider for a resource with no run context set" unless node
|
95
97
|
provider = find_provider_for_node(node, resource).new(resource, resource.run_context)
|
@@ -102,11 +104,13 @@ class Chef
|
|
102
104
|
end
|
103
105
|
|
104
106
|
def find_provider_for_node(node, resource_type)
|
107
|
+
Chef.deprecated(:chef_platform_methods, "#{self.class.name}.find_provider_for_node is deprecated")
|
105
108
|
platform, version = find_platform_and_version(node)
|
106
109
|
find_provider(platform, version, resource_type)
|
107
110
|
end
|
108
111
|
|
109
112
|
def set(args)
|
113
|
+
Chef.deprecated(:chef_platform_methods, "#{self.class.name}.set is deprecated")
|
110
114
|
validate(
|
111
115
|
args,
|
112
116
|
{
|
@@ -172,6 +176,7 @@ class Chef
|
|
172
176
|
end
|
173
177
|
|
174
178
|
def find_provider(platform, version, resource_type)
|
179
|
+
Chef.deprecated(:chef_platform_methods, "#{self.class.name}.find_provider is deprecated")
|
175
180
|
provider_klass = explicit_provider(platform, version, resource_type) ||
|
176
181
|
platform_provider(platform, version, resource_type) ||
|
177
182
|
resource_matching_provider(platform, version, resource_type)
|
@@ -17,12 +17,12 @@
|
|
17
17
|
#
|
18
18
|
|
19
19
|
require "singleton"
|
20
|
-
require "chef/
|
20
|
+
require "chef/node_map"
|
21
21
|
|
22
22
|
class Chef
|
23
23
|
class Platform
|
24
24
|
# @api private
|
25
|
-
class ResourceHandlerMap < Chef::
|
25
|
+
class ResourceHandlerMap < Chef::NodeMap
|
26
26
|
include Singleton
|
27
27
|
end
|
28
28
|
end
|
@@ -36,7 +36,7 @@ class Chef
|
|
36
36
|
obj.variablevalue = @new_resource.value
|
37
37
|
obj.put_
|
38
38
|
value = @new_resource.value
|
39
|
-
value = expand_path(value) if @new_resource.key_name.casecmp("PATH")
|
39
|
+
value = expand_path(value) if @new_resource.key_name.casecmp("PATH") == 0
|
40
40
|
ENV[@new_resource.key_name] = value
|
41
41
|
broadcast_env_change
|
42
42
|
end
|
data/lib/chef/provider/git.rb
CHANGED
@@ -65,7 +65,7 @@ class Chef
|
|
65
65
|
# this can't be recovered from in why-run mode, because nothing that
|
66
66
|
# we do in the course of a run is likely to create a valid target_revision
|
67
67
|
# if we can't resolve it up front.
|
68
|
-
a.assertion { target_revision
|
68
|
+
a.assertion { !target_revision.nil? }
|
69
69
|
a.failure_message Chef::Exceptions::UnresolvableGitReference,
|
70
70
|
"Unable to parse SHA reference for '#{@new_resource.revision}' in repository '#{@new_resource.repository}'. " +
|
71
71
|
"Verify your (case-sensitive) repository URL and revision.\n" +
|
data/lib/chef/provider/group.rb
CHANGED
@@ -39,38 +39,38 @@ class Chef
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def load_current_resource
|
42
|
-
@current_resource = Chef::Resource::Group.new(
|
43
|
-
|
42
|
+
@current_resource = Chef::Resource::Group.new(new_resource.name)
|
43
|
+
current_resource.group_name(new_resource.group_name)
|
44
44
|
|
45
45
|
group_info = nil
|
46
46
|
begin
|
47
|
-
group_info = Etc.getgrnam(
|
48
|
-
rescue ArgumentError
|
47
|
+
group_info = Etc.getgrnam(new_resource.group_name)
|
48
|
+
rescue ArgumentError
|
49
49
|
@group_exists = false
|
50
|
-
Chef::Log.debug("#{
|
50
|
+
Chef::Log.debug("#{new_resource} group does not exist")
|
51
51
|
end
|
52
52
|
|
53
53
|
if group_info
|
54
|
-
|
55
|
-
|
56
|
-
|
54
|
+
new_resource.gid(group_info.gid) unless new_resource.gid
|
55
|
+
current_resource.gid(group_info.gid)
|
56
|
+
current_resource.members(group_info.mem)
|
57
57
|
end
|
58
58
|
|
59
|
-
|
59
|
+
current_resource
|
60
60
|
end
|
61
61
|
|
62
62
|
def define_resource_requirements
|
63
63
|
requirements.assert(:modify) do |a|
|
64
64
|
a.assertion { @group_exists }
|
65
|
-
a.failure_message(Chef::Exceptions::Group, "Cannot modify #{
|
66
|
-
a.whyrun("Group #{
|
65
|
+
a.failure_message(Chef::Exceptions::Group, "Cannot modify #{new_resource} - group does not exist!")
|
66
|
+
a.whyrun("Group #{new_resource} does not exist. Unless it would have been created earlier in this run, this attempt to modify it would fail.")
|
67
67
|
end
|
68
68
|
|
69
69
|
requirements.assert(:all_actions) do |a|
|
70
70
|
# Make sure that the resource doesn't contain any common
|
71
71
|
# user names in the members and exclude_members properties.
|
72
|
-
if
|
73
|
-
common_members =
|
72
|
+
if !new_resource.members.nil? && !new_resource.excluded_members.nil?
|
73
|
+
common_members = new_resource.members & new_resource.excluded_members
|
74
74
|
a.assertion { common_members.empty? }
|
75
75
|
a.failure_message(Chef::Exceptions::ConflictingMembersInGroup, "Attempting to both add and remove users from a group: '#{common_members.join(', ')}'")
|
76
76
|
# No why-run alternative
|
@@ -86,41 +86,39 @@ class Chef
|
|
86
86
|
# <false>:: If a change is not required
|
87
87
|
def compare_group
|
88
88
|
@change_desc = [ ]
|
89
|
-
if
|
90
|
-
@change_desc << "change gid #{
|
89
|
+
if new_resource.gid.to_s != current_resource.gid.to_s
|
90
|
+
@change_desc << "change gid #{current_resource.gid} to #{new_resource.gid}"
|
91
91
|
end
|
92
92
|
|
93
|
-
if
|
93
|
+
if new_resource.append
|
94
94
|
missing_members = []
|
95
|
-
|
95
|
+
new_resource.members.each do |member|
|
96
96
|
next if has_current_group_member?(member)
|
97
97
|
validate_member!(member)
|
98
98
|
missing_members << member
|
99
99
|
end
|
100
|
-
|
101
|
-
@change_desc << "add missing member(s): #{missing_members.join(
|
100
|
+
unless missing_members.empty?
|
101
|
+
@change_desc << "add missing member(s): #{missing_members.join(', ')}"
|
102
102
|
end
|
103
103
|
|
104
104
|
members_to_be_removed = []
|
105
|
-
|
105
|
+
new_resource.excluded_members.each do |member|
|
106
106
|
if has_current_group_member?(member)
|
107
107
|
members_to_be_removed << member
|
108
108
|
end
|
109
109
|
end
|
110
|
-
|
111
|
-
@change_desc << "remove existing member(s): #{members_to_be_removed.join(
|
112
|
-
end
|
113
|
-
else
|
114
|
-
if @new_resource.members != @current_resource.members
|
115
|
-
@change_desc << "replace group members with new list of members"
|
110
|
+
unless members_to_be_removed.empty?
|
111
|
+
@change_desc << "remove existing member(s): #{members_to_be_removed.join(', ')}"
|
116
112
|
end
|
113
|
+
elsif new_resource.members != current_resource.members
|
114
|
+
@change_desc << "replace group members with new list of members"
|
117
115
|
end
|
118
116
|
|
119
117
|
!@change_desc.empty?
|
120
118
|
end
|
121
119
|
|
122
120
|
def has_current_group_member?(member)
|
123
|
-
|
121
|
+
current_resource.members.include?(member)
|
124
122
|
end
|
125
123
|
|
126
124
|
def validate_member!(member)
|
@@ -132,44 +130,41 @@ class Chef
|
|
132
130
|
def action_create
|
133
131
|
case @group_exists
|
134
132
|
when false
|
135
|
-
converge_by("create group #{
|
133
|
+
converge_by("create group #{new_resource.group_name}") do
|
136
134
|
create_group
|
137
|
-
Chef::Log.info("#{
|
135
|
+
Chef::Log.info("#{new_resource} created")
|
138
136
|
end
|
139
137
|
else
|
140
138
|
if compare_group
|
141
|
-
converge_by(["alter group #{
|
139
|
+
converge_by(["alter group #{new_resource.group_name}"] + change_desc) do
|
142
140
|
manage_group
|
143
|
-
Chef::Log.info("#{
|
141
|
+
Chef::Log.info("#{new_resource} altered")
|
144
142
|
end
|
145
143
|
end
|
146
144
|
end
|
147
145
|
end
|
148
146
|
|
149
147
|
def action_remove
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
end
|
148
|
+
return unless @group_exists
|
149
|
+
converge_by("remove group #{new_resource.group_name}") do
|
150
|
+
remove_group
|
151
|
+
Chef::Log.info("#{new_resource} removed")
|
155
152
|
end
|
156
153
|
end
|
157
154
|
|
158
155
|
def action_manage
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
end
|
156
|
+
return unless @group_exists && compare_group
|
157
|
+
converge_by(["manage group #{new_resource.group_name}"] + change_desc) do
|
158
|
+
manage_group
|
159
|
+
Chef::Log.info("#{new_resource} managed")
|
164
160
|
end
|
165
161
|
end
|
166
162
|
|
167
163
|
def action_modify
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
end
|
164
|
+
return unless compare_group
|
165
|
+
converge_by(["modify group #{new_resource.group_name}"] + change_desc) do
|
166
|
+
manage_group
|
167
|
+
Chef::Log.info("#{new_resource} modified")
|
173
168
|
end
|
174
169
|
end
|
175
170
|
|