chef 11.16.4 → 11.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +2 -2
- data/lib/chef/api_client.rb +1 -1
- data/lib/chef/chef_fs/chef_fs_data_store.rb +3 -2
- data/lib/chef/chef_fs/command_line.rb +3 -2
- data/lib/chef/chef_fs/data_handler/group_data_handler.rb +5 -1
- data/lib/chef/chef_fs/file_system/acl_entry.rb +2 -1
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +2 -1
- data/lib/chef/chef_fs/file_system/rest_list_dir.rb +3 -2
- data/lib/chef/chef_fs/file_system/rest_list_entry.rb +5 -4
- data/lib/chef/config_fetcher.rb +1 -1
- data/lib/chef/cookbook/cookbook_version_loader.rb +4 -4
- data/lib/chef/cookbook/metadata.rb +1 -1
- data/lib/chef/cookbook_version.rb +2 -2
- data/lib/chef/data_bag.rb +1 -1
- data/lib/chef/data_bag_item.rb +1 -1
- data/lib/chef/encrypted_data_bag_item/decryptor.rb +3 -3
- data/lib/chef/environment.rb +1 -1
- data/lib/chef/exceptions.rb +19 -2
- data/lib/chef/json_compat.rb +64 -45
- data/lib/chef/knife/bootstrap.rb +2 -2
- data/lib/chef/knife/bootstrap/archlinux-gems.erb +2 -2
- data/lib/chef/knife/bootstrap/centos5-gems.erb +2 -2
- data/lib/chef/knife/bootstrap/chef-aix.erb +2 -2
- data/lib/chef/knife/bootstrap/chef-full.erb +2 -2
- data/lib/chef/knife/bootstrap/fedora13-gems.erb +2 -2
- data/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb +2 -2
- data/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb +2 -2
- data/lib/chef/knife/bootstrap/ubuntu12.04-gems.erb +2 -2
- data/lib/chef/knife/cookbook_site_download.rb +1 -1
- data/lib/chef/knife/cookbook_site_install.rb +34 -10
- data/lib/chef/knife/cookbook_site_list.rb +1 -1
- data/lib/chef/knife/cookbook_site_search.rb +1 -1
- data/lib/chef/knife/cookbook_site_share.rb +2 -2
- data/lib/chef/knife/cookbook_site_show.rb +3 -3
- data/lib/chef/knife/cookbook_site_unshare.rb +1 -1
- data/lib/chef/knife/core/subcommand_loader.rb +24 -0
- data/lib/chef/knife/deps.rb +3 -2
- data/lib/chef/node.rb +1 -1
- data/lib/chef/provider/deploy/revision.rb +1 -1
- data/lib/chef/provider/dsc_script.rb +32 -5
- data/lib/chef/provider/env.rb +25 -10
- data/lib/chef/provider/remote_file/cache_control_data.rb +1 -1
- data/lib/chef/resource.rb +1 -1
- data/lib/chef/resource/dsc_script.rb +2 -16
- data/lib/chef/resource_collection.rb +1 -1
- data/lib/chef/resource_reporter.rb +3 -3
- data/lib/chef/role.rb +1 -1
- data/lib/chef/run_list.rb +1 -1
- data/lib/chef/user.rb +1 -1
- data/lib/chef/util/dsc/local_configuration_manager.rb +15 -11
- data/lib/chef/util/powershell/cmdlet_result.rb +2 -2
- data/lib/chef/version.rb +1 -2
- data/spec/data/bootstrap/test-hints.erb +1 -1
- data/spec/data/bootstrap/test.erb +1 -1
- data/spec/functional/knife/cookbook_delete_spec.rb +3 -3
- data/spec/functional/knife/exec_spec.rb +1 -1
- data/spec/functional/resource/dsc_script_spec.rb +92 -47
- data/spec/functional/resource/env_spec.rb +3 -4
- data/spec/functional/util/powershell/cmdlet_spec.rb +1 -2
- data/spec/integration/knife/chef_fs_data_store_spec.rb +1 -1
- data/spec/integration/knife/chef_repo_path_spec.rb +6 -1
- data/spec/integration/knife/chef_repository_file_system_spec.rb +1 -1
- data/spec/integration/knife/chefignore_spec.rb +1 -1
- data/spec/integration/knife/common_options_spec.rb +1 -1
- data/spec/integration/knife/cookbook_api_ipv6_spec.rb +1 -1
- data/spec/integration/knife/delete_spec.rb +1 -1
- data/spec/integration/knife/deps_spec.rb +1 -1
- data/spec/integration/knife/diff_spec.rb +3 -3
- data/spec/integration/knife/download_spec.rb +3 -3
- data/spec/integration/knife/list_spec.rb +1 -1
- data/spec/integration/knife/raw_spec.rb +11 -1
- data/spec/integration/knife/redirection_spec.rb +1 -1
- data/spec/integration/knife/serve_spec.rb +1 -1
- data/spec/integration/knife/show_spec.rb +1 -1
- data/spec/integration/knife/upload_spec.rb +9 -9
- data/spec/spec_helper.rb +6 -0
- data/spec/support/shared/integration/integration_helper.rb +1 -2
- data/spec/support/shared/shared_examples.rb +10 -0
- data/spec/tiny_server.rb +2 -1
- data/spec/unit/api_client_spec.rb +3 -3
- data/spec/unit/chef_fs/data_handler/group_handler_spec.rb +63 -0
- data/spec/unit/config_fetcher_spec.rb +1 -1
- data/spec/unit/cookbook/metadata_spec.rb +7 -3
- data/spec/unit/cookbook_loader_spec.rb +1 -1
- data/spec/unit/cookbook_version_spec.rb +4 -0
- data/spec/unit/data_bag_item_spec.rb +5 -1
- data/spec/unit/data_bag_spec.rb +5 -1
- data/spec/unit/deprecation_spec.rb +1 -1
- data/spec/unit/encrypted_data_bag_item_spec.rb +14 -7
- data/spec/unit/environment_spec.rb +7 -3
- data/spec/unit/exceptions_spec.rb +6 -0
- data/spec/unit/json_compat_spec.rb +58 -17
- data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +0 -1
- data/spec/unit/knife/cookbook_site_download_spec.rb +2 -1
- data/spec/unit/knife/cookbook_site_install_spec.rb +161 -116
- data/spec/unit/knife/cookbook_site_share_spec.rb +6 -6
- data/spec/unit/knife/core/bootstrap_context_spec.rb +2 -2
- data/spec/unit/knife/core/subcommand_loader_spec.rb +66 -1
- data/spec/unit/knife/data_bag_from_file_spec.rb +1 -2
- data/spec/unit/node_spec.rb +4 -0
- data/spec/unit/provider/dsc_script_spec.rb +134 -105
- data/spec/unit/provider/env/windows_spec.rb +2 -2
- data/spec/unit/provider/env_spec.rb +76 -11
- data/spec/unit/provider/remote_file/cache_control_data_spec.rb +1 -1
- data/spec/unit/resource/dsc_script_spec.rb +0 -29
- data/spec/unit/resource_collection_spec.rb +5 -1
- data/spec/unit/resource_reporter_spec.rb +3 -3
- data/spec/unit/resource_spec.rb +5 -1
- data/spec/unit/role_spec.rb +4 -0
- data/spec/unit/run_list_spec.rb +5 -1
- data/spec/unit/user_spec.rb +5 -1
- data/spec/unit/util/dsc/local_configuration_manager_spec.rb +15 -10
- metadata +11 -9
data/lib/chef/knife/bootstrap.rb
CHANGED
@@ -126,7 +126,7 @@ class Chef
|
|
126
126
|
:short => "-j JSON_ATTRIBS",
|
127
127
|
:long => "--json-attributes",
|
128
128
|
:description => "A JSON string to be added to the first run of chef-client",
|
129
|
-
:proc => lambda { |o|
|
129
|
+
:proc => lambda { |o| Chef::JSONCompat.parse(o) },
|
130
130
|
:default => {}
|
131
131
|
|
132
132
|
option :host_key_verify,
|
@@ -141,7 +141,7 @@ class Chef
|
|
141
141
|
:proc => Proc.new { |h|
|
142
142
|
Chef::Config[:knife][:hints] ||= Hash.new
|
143
143
|
name, path = h.split("=")
|
144
|
-
Chef::Config[:knife][:hints][name] = path ?
|
144
|
+
Chef::Config[:knife][:hints][name] = path ? Chef::JSONCompat.parse(::File.read(path)) : Hash.new }
|
145
145
|
|
146
146
|
option :secret,
|
147
147
|
:short => "-s SECRET",
|
@@ -29,7 +29,7 @@ mkdir -p /etc/chef/ohai/hints
|
|
29
29
|
|
30
30
|
<% @chef_config[:knife][:hints].each do |name, hash| -%>
|
31
31
|
cat > /etc/chef/ohai/hints/<%= name %>.json <<'EOP'
|
32
|
-
<%=
|
32
|
+
<%= Chef::JSONCompat.to_json(hash) %>
|
33
33
|
EOP
|
34
34
|
<% end -%>
|
35
35
|
<% end -%>
|
@@ -56,7 +56,7 @@ https_proxy "<%= knife_config[:bootstrap_proxy] %>"
|
|
56
56
|
EOP
|
57
57
|
|
58
58
|
cat > /etc/chef/first-boot.json <<'EOP'
|
59
|
-
<%=
|
59
|
+
<%= Chef::JSONCompat.to_json(first_boot) %>
|
60
60
|
EOP
|
61
61
|
|
62
62
|
<%= start_chef %>'
|
@@ -46,7 +46,7 @@ mkdir -p /etc/chef/ohai/hints
|
|
46
46
|
|
47
47
|
<% @chef_config[:knife][:hints].each do |name, hash| -%>
|
48
48
|
cat > /etc/chef/ohai/hints/<%= name %>.json <<'EOP'
|
49
|
-
<%=
|
49
|
+
<%= Chef::JSONCompat.to_json(hash) %>
|
50
50
|
EOP
|
51
51
|
<% end -%>
|
52
52
|
<% end -%>
|
@@ -56,7 +56,7 @@ cat > /etc/chef/client.rb <<'EOP'
|
|
56
56
|
EOP
|
57
57
|
|
58
58
|
cat > /etc/chef/first-boot.json <<'EOP'
|
59
|
-
<%=
|
59
|
+
<%= Chef::JSONCompat.to_json(first_boot) %>
|
60
60
|
EOP
|
61
61
|
|
62
62
|
<%= start_chef %>'
|
@@ -42,7 +42,7 @@ mkdir -p /etc/chef/ohai/hints
|
|
42
42
|
|
43
43
|
<% @chef_config[:knife][:hints].each do |name, hash| -%>
|
44
44
|
cat > /etc/chef/ohai/hints/<%= name %>.json <<'EOP'
|
45
|
-
<%=
|
45
|
+
<%= Chef::JSONCompat.to_json(hash) %>
|
46
46
|
EOP
|
47
47
|
<% end -%>
|
48
48
|
<% end -%>
|
@@ -52,7 +52,7 @@ cat > /etc/chef/client.rb <<'EOP'
|
|
52
52
|
EOP
|
53
53
|
|
54
54
|
cat > /etc/chef/first-boot.json <<'EOP'
|
55
|
-
<%=
|
55
|
+
<%= Chef::JSONCompat.to_json(first_boot) %>
|
56
56
|
EOP
|
57
57
|
|
58
58
|
<%= start_chef %>'
|
@@ -57,7 +57,7 @@ mkdir -p /etc/chef/ohai/hints
|
|
57
57
|
|
58
58
|
<% @chef_config[:knife][:hints].each do |name, hash| -%>
|
59
59
|
cat > /etc/chef/ohai/hints/<%= name %>.json <<'EOP'
|
60
|
-
<%=
|
60
|
+
<%= Chef::JSONCompat.to_json(hash) %>
|
61
61
|
EOP
|
62
62
|
<% end -%>
|
63
63
|
<% end -%>
|
@@ -67,7 +67,7 @@ cat > /etc/chef/client.rb <<'EOP'
|
|
67
67
|
EOP
|
68
68
|
|
69
69
|
cat > /etc/chef/first-boot.json <<'EOP'
|
70
|
-
<%=
|
70
|
+
<%= Chef::JSONCompat.to_json(first_boot) %>
|
71
71
|
EOP
|
72
72
|
|
73
73
|
echo "Starting first Chef Client run..."
|
@@ -28,7 +28,7 @@ mkdir -p /etc/chef/ohai/hints
|
|
28
28
|
|
29
29
|
<% @chef_config[:knife][:hints].each do |name, hash| -%>
|
30
30
|
cat > /etc/chef/ohai/hints/<%= name %>.json <<'EOP'
|
31
|
-
<%=
|
31
|
+
<%= Chef::JSONCompat.to_json(hash) %>
|
32
32
|
EOP
|
33
33
|
<% end -%>
|
34
34
|
<% end -%>
|
@@ -38,7 +38,7 @@ cat > /etc/chef/client.rb <<'EOP'
|
|
38
38
|
EOP
|
39
39
|
|
40
40
|
cat > /etc/chef/first-boot.json <<'EOP'
|
41
|
-
<%=
|
41
|
+
<%= Chef::JSONCompat.to_json(first_boot) %>
|
42
42
|
EOP
|
43
43
|
|
44
44
|
<%= start_chef %>'
|
@@ -28,7 +28,7 @@ mkdir -p /etc/chef/ohai/hints
|
|
28
28
|
|
29
29
|
<% @chef_config[:knife][:hints].each do |name, hash| -%>
|
30
30
|
cat > /etc/chef/ohai/hints/<%= name %>.json <<'EOP'
|
31
|
-
<%=
|
31
|
+
<%= Chef::JSONCompat.to_json(hash) %>
|
32
32
|
EOP
|
33
33
|
<% end -%>
|
34
34
|
<% end -%>
|
@@ -47,7 +47,7 @@ echo 'https_proxy "knife_config[:bootstrap_proxy]"' >> /etc/chef/client.rb
|
|
47
47
|
<% end -%>
|
48
48
|
|
49
49
|
cat > /etc/chef/first-boot.json <<'EOP'
|
50
|
-
<%=
|
50
|
+
<%= Chef::JSONCompat.to_json(first_boot) %>
|
51
51
|
EOP
|
52
52
|
|
53
53
|
<%= start_chef %>'
|
@@ -32,7 +32,7 @@ mkdir -p /etc/chef/ohai/hints
|
|
32
32
|
|
33
33
|
<% @chef_config[:knife][:hints].each do |name, hash| -%>
|
34
34
|
cat > /etc/chef/ohai/hints/<%= name %>.json <<'EOP'
|
35
|
-
<%=
|
35
|
+
<%= Chef::JSONCompat.to_json(hash) %>
|
36
36
|
EOP
|
37
37
|
<% end -%>
|
38
38
|
<% end -%>
|
@@ -42,7 +42,7 @@ cat > /etc/chef/client.rb <<'EOP'
|
|
42
42
|
EOP
|
43
43
|
|
44
44
|
cat > /etc/chef/first-boot.json <<'EOP'
|
45
|
-
<%=
|
45
|
+
<%= Chef::JSONCompat.to_json(first_boot) %>
|
46
46
|
EOP
|
47
47
|
|
48
48
|
<%= start_chef %>'
|
@@ -30,7 +30,7 @@ mkdir -p /etc/chef/ohai/hints
|
|
30
30
|
|
31
31
|
<% @chef_config[:knife][:hints].each do |name, hash| -%>
|
32
32
|
cat > /etc/chef/ohai/hints/<%= name %>.json <<'EOP'
|
33
|
-
<%=
|
33
|
+
<%= Chef::JSONCompat.to_json(hash) %>
|
34
34
|
EOP
|
35
35
|
<% end -%>
|
36
36
|
<% end -%>
|
@@ -40,7 +40,7 @@ cat > /etc/chef/client.rb <<'EOP'
|
|
40
40
|
EOP
|
41
41
|
|
42
42
|
cat > /etc/chef/first-boot.json <<'EOP'
|
43
|
-
<%=
|
43
|
+
<%= Chef::JSONCompat.to_json(first_boot) %>
|
44
44
|
EOP
|
45
45
|
|
46
46
|
<%= start_chef %>'
|
@@ -17,11 +17,11 @@
|
|
17
17
|
#
|
18
18
|
|
19
19
|
require 'chef/knife'
|
20
|
+
require 'chef/exceptions'
|
20
21
|
require 'shellwords'
|
21
22
|
|
22
23
|
class Chef
|
23
24
|
class Knife
|
24
|
-
|
25
25
|
class CookbookSiteInstall < Knife
|
26
26
|
|
27
27
|
deps do
|
@@ -107,11 +107,8 @@ class Chef
|
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
110
|
-
|
111
110
|
unless config[:no_deps]
|
112
|
-
|
113
|
-
md.from_file(File.join(@install_path, @cookbook_name, "metadata.rb"))
|
114
|
-
md.dependencies.each do |cookbook, version_list|
|
111
|
+
preferred_metadata.dependencies.each do |cookbook, version_list|
|
115
112
|
# Doesn't do versions.. yet
|
116
113
|
nv = self.class.new
|
117
114
|
nv.config = config
|
@@ -144,6 +141,7 @@ class Chef
|
|
144
141
|
|
145
142
|
def extract_cookbook(upstream_file, version)
|
146
143
|
ui.info("Uncompressing #{@cookbook_name} version #{version}.")
|
144
|
+
# FIXME: Detect if we have the bad tar from git on Windows: https://github.com/opscode/chef/issues/1753
|
147
145
|
shell_out!("tar zxvf #{convert_path upstream_file}", :cwd => @install_path)
|
148
146
|
end
|
149
147
|
|
@@ -153,11 +151,37 @@ class Chef
|
|
153
151
|
end
|
154
152
|
|
155
153
|
def convert_path(upstream_file)
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
154
|
+
# converts a Windows path (C:\foo) to a mingw path (/c/foo)
|
155
|
+
if ENV['MSYSTEM'] == 'MINGW32'
|
156
|
+
return upstream_file.sub(/^([[:alpha:]]):/, '/\1')
|
157
|
+
else
|
158
|
+
return Shellwords.escape upstream_file
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
# Get the preferred metadata path on disk. Chef prefers the metadata.rb
|
163
|
+
# over the metadata.json.
|
164
|
+
#
|
165
|
+
# @raise if there is no metadata in the cookbook
|
166
|
+
#
|
167
|
+
# @return [Chef::Cookbook::Metadata]
|
168
|
+
def preferred_metadata
|
169
|
+
md = Chef::Cookbook::Metadata.new
|
170
|
+
|
171
|
+
rb = File.join(@install_path, @cookbook_name, "metadata.rb")
|
172
|
+
if File.exist?(rb)
|
173
|
+
md.from_file(rb)
|
174
|
+
return md
|
175
|
+
end
|
176
|
+
|
177
|
+
json = File.join(@install_path, @cookbook_name, "metadata.json")
|
178
|
+
if File.exist?(json)
|
179
|
+
json = IO.read(json)
|
180
|
+
md.from_json(json)
|
181
|
+
return md
|
182
|
+
end
|
183
|
+
|
184
|
+
raise Chef::Exceptions::MetadataNotFound.new(@install_path, @cookbook_name)
|
161
185
|
end
|
162
186
|
end
|
163
187
|
end
|
@@ -41,7 +41,7 @@ class Chef
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def get_cookbook_list(items=10, start=0, cookbook_collection={})
|
44
|
-
cookbooks_url = "
|
44
|
+
cookbooks_url = "https://supermarket.getchef.com/api/v1/cookbooks?items=#{items}&start=#{start}"
|
45
45
|
cr = noauth_rest.get_rest(cookbooks_url)
|
46
46
|
cr["items"].each do |cookbook|
|
47
47
|
cookbook_collection[cookbook["cookbook_name"]] = cookbook
|
@@ -29,7 +29,7 @@ class Chef
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def search_cookbook(query, items=10, start=0, cookbook_collection={})
|
32
|
-
cookbooks_url = "
|
32
|
+
cookbooks_url = "https://supermarket.getchef.com/api/v1/search?q=#{query}&items=#{items}&start=#{start}"
|
33
33
|
cr = noauth_rest.get_rest(cookbooks_url)
|
34
34
|
cr["items"].each do |cookbook|
|
35
35
|
cookbook_collection[cookbook["cookbook_name"]] = cookbook
|
@@ -85,9 +85,9 @@ class Chef
|
|
85
85
|
end
|
86
86
|
|
87
87
|
def do_upload(cookbook_filename, cookbook_category, user_id, user_secret_filename)
|
88
|
-
uri = "
|
88
|
+
uri = "https://supermarket.getchef.com/api/v1/cookbooks"
|
89
89
|
|
90
|
-
category_string = { 'category'=>cookbook_category }
|
90
|
+
category_string = Chef::JSONCompat.to_json({ 'category'=>cookbook_category })
|
91
91
|
|
92
92
|
http_resp = Chef::CookbookSiteStreamingUploader.post(uri, user_id, user_secret_filename, {
|
93
93
|
:tarball => File.open(cookbook_filename),
|
@@ -31,14 +31,14 @@ class Chef
|
|
31
31
|
def get_cookbook_data
|
32
32
|
case @name_args.length
|
33
33
|
when 1
|
34
|
-
noauth_rest.get_rest("
|
34
|
+
noauth_rest.get_rest("https://supermarket.getchef.com/api/v1/cookbooks/#{@name_args[0]}")
|
35
35
|
when 2
|
36
|
-
noauth_rest.get_rest("
|
36
|
+
noauth_rest.get_rest("https://supermarket.getchef.com/api/v1/cookbooks/#{@name_args[0]}/versions/#{name_args[1].gsub('.', '_')}")
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
def get_cookbook_list(items=10, start=0, cookbook_collection={})
|
41
|
-
cookbooks_url = "
|
41
|
+
cookbooks_url = "https://supermarket.getchef.com/api/v1/cookbooks?items=#{items}&start=#{start}"
|
42
42
|
cr = noauth_rest.get_rest(cookbooks_url)
|
43
43
|
cr["items"].each do |cookbook|
|
44
44
|
cookbook_collection[cookbook["cookbook_name"]] = cookbook
|
@@ -41,7 +41,7 @@ class Chef
|
|
41
41
|
confirm "Do you really want to unshare the cookbook #{@cookbook_name}"
|
42
42
|
|
43
43
|
begin
|
44
|
-
rest.delete_rest "
|
44
|
+
rest.delete_rest "https://supermarket.getchef.com/api/v1/cookbooks/#{@name_args[0]}"
|
45
45
|
rescue Net::HTTPServerException => e
|
46
46
|
raise e unless e.message =~ /Forbidden/
|
47
47
|
ui.error "Forbidden: You must be the maintainer of #{@cookbook_name} to unshare it."
|
@@ -21,6 +21,9 @@ class Chef
|
|
21
21
|
class Knife
|
22
22
|
class SubcommandLoader
|
23
23
|
|
24
|
+
MATCHES_CHEF_GEM = %r{/chef-[\d]+\.[\d]+\.[\d]+}.freeze
|
25
|
+
MATCHES_THIS_CHEF_GEM = %r{/chef-#{Chef::VERSION}/}.freeze
|
26
|
+
|
24
27
|
attr_reader :chef_config_dir
|
25
28
|
attr_reader :env
|
26
29
|
|
@@ -121,6 +124,14 @@ class Chef
|
|
121
124
|
subcommand_files = {}
|
122
125
|
files.each do |file|
|
123
126
|
rel_path = file[/(#{Regexp.escape File.join('chef', 'knife', '')}.*)\.rb/, 1]
|
127
|
+
|
128
|
+
# When not installed as a gem (ChefDK/appbundler in particular), AND
|
129
|
+
# a different version of Chef is installed via gems, `files` will
|
130
|
+
# include some files from the 'other' Chef install. If this contains
|
131
|
+
# a knife command that doesn't exist in this version of Chef, we will
|
132
|
+
# get a LoadError later when we try to require it.
|
133
|
+
next if from_different_chef_version?(file)
|
134
|
+
|
124
135
|
subcommand_files[rel_path] = file
|
125
136
|
end
|
126
137
|
|
@@ -184,6 +195,19 @@ class Chef
|
|
184
195
|
|
185
196
|
Dir[glob].map { |f| f.untaint }
|
186
197
|
end
|
198
|
+
|
199
|
+
def from_different_chef_version?(path)
|
200
|
+
matches_any_chef_gem?(path) && !matches_this_chef_gem?(path)
|
201
|
+
end
|
202
|
+
|
203
|
+
def matches_any_chef_gem?(path)
|
204
|
+
path =~ MATCHES_CHEF_GEM
|
205
|
+
end
|
206
|
+
|
207
|
+
def matches_this_chef_gem?(path)
|
208
|
+
path =~ MATCHES_THIS_CHEF_GEM
|
209
|
+
end
|
210
|
+
|
187
211
|
end
|
188
212
|
end
|
189
213
|
end
|
data/lib/chef/knife/deps.rb
CHANGED
@@ -9,6 +9,7 @@ class Chef
|
|
9
9
|
|
10
10
|
deps do
|
11
11
|
require 'chef/chef_fs/file_system'
|
12
|
+
require 'chef/json_compat'
|
12
13
|
require 'chef/run_list'
|
13
14
|
end
|
14
15
|
|
@@ -77,7 +78,7 @@ class Chef
|
|
77
78
|
return entry.chef_object.metadata.dependencies.keys.map { |cookbook| "/cookbooks/#{cookbook}" }
|
78
79
|
|
79
80
|
elsif entry.parent && entry.parent.path == '/nodes'
|
80
|
-
node =
|
81
|
+
node = Chef::JSONCompat.parse(entry.read, :create_additions => false)
|
81
82
|
result = []
|
82
83
|
if node['chef_environment'] && node['chef_environment'] != '_default'
|
83
84
|
result << "/environments/#{node['chef_environment']}.json"
|
@@ -88,7 +89,7 @@ class Chef
|
|
88
89
|
result
|
89
90
|
|
90
91
|
elsif entry.parent && entry.parent.path == '/roles'
|
91
|
-
role =
|
92
|
+
role = Chef::JSONCompat.parse(entry.read, :create_additions => false)
|
92
93
|
result = []
|
93
94
|
if role['run_list']
|
94
95
|
dependencies_from_runlist(role['run_list']).each do |dependency|
|
data/lib/chef/node.rb
CHANGED
@@ -46,9 +46,11 @@ class Chef
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def load_current_resource
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
if supports_dsc?
|
50
|
+
@dsc_resources_info = run_configuration(:test)
|
51
|
+
@resource_converged = @dsc_resources_info.all? do |resource|
|
52
|
+
!resource.changes_state?
|
53
|
+
end
|
52
54
|
end
|
53
55
|
end
|
54
56
|
|
@@ -56,8 +58,26 @@ class Chef
|
|
56
58
|
true
|
57
59
|
end
|
58
60
|
|
61
|
+
def define_resource_requirements
|
62
|
+
requirements.assert(:run) do |a|
|
63
|
+
err = [
|
64
|
+
'Could not find PowerShell DSC support on the system',
|
65
|
+
powershell_info_str,
|
66
|
+
"Powershell 4.0 or higher was not detected on your system and is required to use the dsc_script resource.",
|
67
|
+
]
|
68
|
+
a.assertion { supports_dsc? }
|
69
|
+
a.failure_message Chef::Exceptions::NoProviderAvailable, err.join(' ')
|
70
|
+
a.whyrun err + ["Assuming a previous resource installs Powershell 4.0 or higher."]
|
71
|
+
a.block_action!
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
59
75
|
protected
|
60
76
|
|
77
|
+
def supports_dsc?
|
78
|
+
run_context && Chef::Platform.supports_dsc?(node)
|
79
|
+
end
|
80
|
+
|
61
81
|
def run_configuration(operation)
|
62
82
|
config_directory = ::Dir.mktmpdir("chef-dsc-script")
|
63
83
|
configuration_data_path = get_configuration_data_path(config_directory)
|
@@ -77,9 +97,8 @@ class Chef
|
|
77
97
|
end
|
78
98
|
|
79
99
|
def get_augmented_configuration_flags(configuration_data_path)
|
80
|
-
updated_flags = nil
|
100
|
+
updated_flags = @dsc_resource.flags.nil? ? {} : @dsc_resource.flags.dup
|
81
101
|
if configuration_data_path
|
82
|
-
updated_flags = @dsc_resource.flags.nil? ? {} : @dsc_resource.flags.dup
|
83
102
|
Chef::Util::PathHelper.validate_path(configuration_data_path)
|
84
103
|
updated_flags[:configurationdata] = configuration_data_path
|
85
104
|
end
|
@@ -143,6 +162,14 @@ class Chef
|
|
143
162
|
end
|
144
163
|
end
|
145
164
|
end
|
165
|
+
|
166
|
+
def powershell_info_str
|
167
|
+
if run_context && run_context.node[:languages] && run_context.node[:languages][:powershell]
|
168
|
+
install_info = "Powershell #{run_context.node[:languages][:powershell][:version]} was found on the system."
|
169
|
+
else
|
170
|
+
install_info = 'Powershell was not found.'
|
171
|
+
end
|
172
|
+
end
|
146
173
|
end
|
147
174
|
end
|
148
175
|
end
|