chef 15.3.14 → 15.4.45
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/chef.gemspec +2 -2
- data/lib/chef/application/solo.rb +1 -1
- data/lib/chef/event_dispatch/dispatcher.rb +9 -2
- data/lib/chef/formatters/doc.rb +3 -3
- data/lib/chef/knife.rb +13 -3
- data/lib/chef/knife/bootstrap.rb +28 -4
- data/lib/chef/knife/bootstrap/templates/chef-full.erb +7 -8
- data/lib/chef/knife/data_bag_secret_options.rb +11 -4
- data/lib/chef/knife/download.rb +2 -2
- data/lib/chef/knife/exec.rb +9 -1
- data/lib/chef/knife/ssh.rb +1 -1
- data/lib/chef/knife/ssl_check.rb +1 -1
- data/lib/chef/knife/supermarket_list.rb +19 -7
- data/lib/chef/knife/supermarket_search.rb +3 -2
- data/lib/chef/node/attribute.rb +2 -0
- data/lib/chef/node/attribute_collections.rb +8 -0
- data/lib/chef/node/immutable_collections.rb +12 -0
- data/lib/chef/node/mixin/immutablize_array.rb +1 -0
- data/lib/chef/node/mixin/immutablize_hash.rb +1 -0
- data/lib/chef/provider.rb +14 -8
- data/lib/chef/provider/package/chocolatey.rb +11 -3
- data/lib/chef/provider/package/dnf/python_helper.rb +8 -3
- data/lib/chef/provider/package/windows/exe.rb +2 -2
- data/lib/chef/provider/package/windows/msi.rb +3 -3
- data/lib/chef/provider/package/yum/python_helper.rb +8 -3
- data/lib/chef/provider/service/windows.rb +1 -1
- data/lib/chef/resource/apt_repository.rb +19 -13
- data/lib/chef/resource/apt_update.rb +15 -1
- data/lib/chef/resource/archive_file.rb +10 -1
- data/lib/chef/resource/build_essential.rb +14 -1
- data/lib/chef/resource/chocolatey_config.rb +17 -1
- data/lib/chef/resource/chocolatey_feature.rb +15 -0
- data/lib/chef/resource/chocolatey_package.rb +31 -1
- data/lib/chef/resource/chocolatey_source.rb +17 -1
- data/lib/chef/resource/cookbook_file.rb +1 -1
- data/lib/chef/resource/cron_access.rb +22 -1
- data/lib/chef/resource/cron_d.rb +46 -1
- data/lib/chef/resource/dmg_package.rb +28 -0
- data/lib/chef/resource/kernel_module.rb +61 -0
- data/lib/chef/resource/sudo.rb +2 -2
- data/lib/chef/resource/windows_ad_join.rb +72 -3
- data/lib/chef/resource/windows_service.rb +1 -1
- data/lib/chef/resource/windows_share.rb +2 -1
- data/lib/chef/shell.rb +4 -4
- data/lib/chef/shell/ext.rb +2 -2
- data/lib/chef/train_transport.rb +1 -1
- data/lib/chef/version.rb +1 -1
- data/spec/functional/resource/ifconfig_spec.rb +0 -2
- data/spec/functional/resource/mount_spec.rb +0 -4
- data/spec/functional/util/powershell/cmdlet_spec.rb +2 -2
- data/spec/integration/knife/chef_repo_path_spec.rb +4 -2
- data/spec/integration/recipes/resource_converge_if_changed_spec.rb +19 -19
- data/spec/spec_helper.rb +2 -0
- data/spec/unit/formatters/doc_spec.rb +18 -0
- data/spec/unit/knife/bootstrap_spec.rb +46 -10
- data/spec/unit/knife/supermarket_list_spec.rb +70 -0
- data/spec/unit/knife/supermarket_search_spec.rb +85 -0
- data/spec/unit/node/attribute_spec.rb +22 -0
- data/spec/unit/node/immutable_collections_spec.rb +72 -144
- data/spec/unit/provider/package/chocolatey_spec.rb +50 -35
- data/spec/unit/provider/package/windows/exe_spec.rb +1 -1
- data/spec/unit/provider/service/windows_spec.rb +23 -3
- data/spec/unit/resource/chocolatey_package_spec.rb +17 -2
- data/spec/unit/resource/windows_ad_join_spec.rb +4 -0
- data/spec/unit/resource/windows_service_spec.rb +5 -0
- data/spec/unit/resource/windows_share_spec.rb +7 -0
- data/tasks/docs.rb +4 -1
- metadata +10 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '09023fe03c2a36ec34f9b087b7671cd38d066cde37ad6027051f333046950701'
|
4
|
+
data.tar.gz: cdd9bd027741716d597f2cc5c9faa1bfaac2f14f7c28b98995b0f71bc8afb295
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52c05b3792352bf46d3124412c92bb1e4a2d2b693de090bb7e793a923547a68955ab1f1faf3bd2c122d1850dd8f9b2c12e0f4ac639a60bdb9ad6cb1b2e607f52
|
7
|
+
data.tar.gz: b9fb6e927fb5d5277979db1e798526b5294e55326a7c0fbc5527d0b736134fc78cec96f9e6584c3bab768a91f2328b66218ed7814735c610a5102af635a28422
|
data/chef.gemspec
CHANGED
@@ -16,8 +16,8 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.required_ruby_version = ">= 2.5.0"
|
17
17
|
|
18
18
|
s.add_dependency "chef-config", "= #{Chef::VERSION}"
|
19
|
-
s.add_dependency "train-core", "~> 3.
|
20
|
-
s.add_dependency "train-winrm"
|
19
|
+
s.add_dependency "train-core", "~> 3.1"
|
20
|
+
s.add_dependency "train-winrm", ">= 0.2.5"
|
21
21
|
|
22
22
|
s.add_dependency "license-acceptance", "~> 1.0", ">= 1.0.5"
|
23
23
|
s.add_dependency "mixlib-cli", ">= 2.1.1", "< 3.0"
|
@@ -52,13 +52,13 @@ class Chef::Application::Solo < Chef::Application::Base
|
|
52
52
|
# Get this party started
|
53
53
|
def run(enforce_license: false)
|
54
54
|
setup_signal_handlers
|
55
|
-
setup_application
|
56
55
|
reconfigure
|
57
56
|
check_license_acceptance if enforce_license
|
58
57
|
for_ezra if Chef::Config[:ez]
|
59
58
|
if !Chef::Config[:solo_legacy_mode]
|
60
59
|
Chef::Application::Client.new.run
|
61
60
|
else
|
61
|
+
setup_application
|
62
62
|
run_application
|
63
63
|
end
|
64
64
|
end
|
@@ -10,11 +10,18 @@ class Chef
|
|
10
10
|
class Dispatcher < Base
|
11
11
|
|
12
12
|
attr_reader :subscribers
|
13
|
-
attr_reader :event_list
|
14
13
|
|
15
14
|
def initialize(*subscribers)
|
16
15
|
@subscribers = subscribers
|
17
|
-
|
16
|
+
end
|
17
|
+
|
18
|
+
# Since the cookbook synchronizer will call this object from threads, we
|
19
|
+
# have to deal with concurrent access to this object. Since we don't want
|
20
|
+
# threads to handle events from other threads, we just use thread local
|
21
|
+
# storage.
|
22
|
+
#
|
23
|
+
def event_list
|
24
|
+
Thread.current[:chef_client_event_list] ||= []
|
18
25
|
end
|
19
26
|
|
20
27
|
# Add a new subscriber to the list of registered subscribers
|
data/lib/chef/formatters/doc.rb
CHANGED
@@ -236,11 +236,11 @@ class Chef
|
|
236
236
|
end
|
237
237
|
|
238
238
|
def resource_update_progress(resource, current, total, interval)
|
239
|
-
@progress[resource] ||=
|
239
|
+
@progress[resource] ||= -1
|
240
240
|
|
241
|
-
percent_complete = (current.to_f / total.to_f * 100).to_i
|
241
|
+
percent_complete = (current.to_f / total.to_f * 100).to_i unless total.to_f == 0.0
|
242
242
|
|
243
|
-
if percent_complete > @progress[resource]
|
243
|
+
if percent_complete && percent_complete > @progress[resource]
|
244
244
|
|
245
245
|
@progress[resource] = percent_complete
|
246
246
|
|
data/lib/chef/knife.rb
CHANGED
@@ -64,6 +64,12 @@ class Chef
|
|
64
64
|
attr_accessor :name_args
|
65
65
|
attr_accessor :ui
|
66
66
|
|
67
|
+
# knife acl subcommands are grouped in this category using this constant to verify.
|
68
|
+
OPSCODE_HOSTED_CHEF_ACCESS_CONTROL = %w{acl group user}.freeze
|
69
|
+
|
70
|
+
# knife opc subcommands are grouped in this category using this constant to verify.
|
71
|
+
CHEF_ORGANIZATION_MANAGEMENT = %w{opc}.freeze
|
72
|
+
|
67
73
|
# Configure mixlib-cli to always separate defaults from user-supplied CLI options
|
68
74
|
def self.use_separate_defaults?
|
69
75
|
true
|
@@ -234,7 +240,7 @@ class Chef
|
|
234
240
|
dependency_loaders.each(&:call)
|
235
241
|
end
|
236
242
|
|
237
|
-
OFFICIAL_PLUGINS = %w{
|
243
|
+
OFFICIAL_PLUGINS = %w{lpar openstack push rackspace vcenter}.freeze
|
238
244
|
|
239
245
|
class << self
|
240
246
|
def list_commands(preferred_category = nil)
|
@@ -270,10 +276,14 @@ class Chef
|
|
270
276
|
ui.info("If this is a recently installed plugin, please run 'knife rehash' to update the subcommands cache.")
|
271
277
|
end
|
272
278
|
|
273
|
-
if
|
279
|
+
if CHEF_ORGANIZATION_MANAGEMENT.include?(args[0])
|
280
|
+
list_commands("CHEF ORGANIZATION MANAGEMENT")
|
281
|
+
elsif OPSCODE_HOSTED_CHEF_ACCESS_CONTROL.include?(args[0])
|
282
|
+
list_commands("OPSCODE HOSTED CHEF ACCESS CONTROL")
|
283
|
+
elsif category_commands = guess_category(args)
|
274
284
|
list_commands(category_commands)
|
275
285
|
elsif OFFICIAL_PLUGINS.include?(args[0]) # command was an uninstalled official chef knife plugin
|
276
|
-
ui.info("Use `#{Chef::Dist::EXEC} gem install knife-#{args[0]}` to install the plugin into ChefDK")
|
286
|
+
ui.info("Use `#{Chef::Dist::EXEC} gem install knife-#{args[0]}` to install the plugin into ChefDK / Chef Workstation")
|
277
287
|
else
|
278
288
|
list_commands
|
279
289
|
end
|
data/lib/chef/knife/bootstrap.rb
CHANGED
@@ -616,7 +616,7 @@ class Chef
|
|
616
616
|
|
617
617
|
def connect!
|
618
618
|
ui.info("Connecting to #{ui.color(server_name, :bold)}")
|
619
|
-
opts
|
619
|
+
opts ||= connection_opts.dup
|
620
620
|
do_connect(opts)
|
621
621
|
rescue Train::Error => e
|
622
622
|
# We handle these by message text only because train only loads the
|
@@ -638,8 +638,10 @@ class Chef
|
|
638
638
|
EOM
|
639
639
|
# FIXME: this should save the key to known_hosts but doesn't appear to be
|
640
640
|
config[:ssh_verify_host_key] = :accept_new
|
641
|
-
|
642
|
-
|
641
|
+
conn_opts = connection_opts(reset: true)
|
642
|
+
opts.merge! conn_opts
|
643
|
+
retry
|
644
|
+
elsif (ssh? && e.cause && e.cause.class == Net::SSH::AuthenticationFailed) || (ssh? && e.class == Train::ClientError && e.reason == :no_ssh_password_or_key_available)
|
643
645
|
if connection.password_auth?
|
644
646
|
raise
|
645
647
|
else
|
@@ -650,7 +652,23 @@ class Chef
|
|
650
652
|
end
|
651
653
|
|
652
654
|
opts.merge! force_ssh_password_opts(password)
|
653
|
-
|
655
|
+
retry
|
656
|
+
else
|
657
|
+
raise
|
658
|
+
end
|
659
|
+
rescue RuntimeError => e
|
660
|
+
if winrm? && e.message == "password is a required option"
|
661
|
+
if connection.password_auth?
|
662
|
+
raise
|
663
|
+
else
|
664
|
+
ui.warn("Failed to authenticate #{opts[:user]} to #{server_name} - trying password auth")
|
665
|
+
password = ui.ask("Enter password for #{opts[:user]}@#{server_name}.") do |q|
|
666
|
+
q.echo = false
|
667
|
+
end
|
668
|
+
end
|
669
|
+
|
670
|
+
opts.merge! force_winrm_password_opts(password)
|
671
|
+
retry
|
654
672
|
else
|
655
673
|
raise
|
656
674
|
end
|
@@ -1023,6 +1041,12 @@ class Chef
|
|
1023
1041
|
}
|
1024
1042
|
end
|
1025
1043
|
|
1044
|
+
def force_winrm_password_opts(password)
|
1045
|
+
{
|
1046
|
+
password: password,
|
1047
|
+
}
|
1048
|
+
end
|
1049
|
+
|
1026
1050
|
# Looks up configuration entries, first in the class member
|
1027
1051
|
# `config` which contains options populated from CLI flags.
|
1028
1052
|
# If the entry is not found there, Chef::Config[:knife][KEY]
|
@@ -1,4 +1,3 @@
|
|
1
|
-
sh -c '
|
2
1
|
<%= "https_proxy=\"#{knife_config[:bootstrap_proxy]}\" export https_proxy" if knife_config[:bootstrap_proxy] %>
|
3
2
|
<%= "no_proxy=\"#{knife_config[:bootstrap_no_proxy]}\" export no_proxy" if knife_config[:bootstrap_no_proxy] %>
|
4
3
|
|
@@ -189,24 +188,24 @@ fi
|
|
189
188
|
mkdir -p <%= Chef::Dist::CONF_DIR %>
|
190
189
|
|
191
190
|
<% if client_pem -%>
|
192
|
-
cat > <%= Chef::Dist::CONF_DIR %>/client.pem <<'EOP'
|
191
|
+
(umask 077 && (cat > <%= Chef::Dist::CONF_DIR %>/client.pem <<'EOP'
|
193
192
|
<%= ::File.read(::File.expand_path(client_pem)) %>
|
194
193
|
EOP
|
195
|
-
|
194
|
+
)) || exit 1
|
196
195
|
<% end -%>
|
197
196
|
|
198
197
|
<% if validation_key -%>
|
199
|
-
cat > <%= Chef::Dist::CONF_DIR %>/validation.pem <<'EOP'
|
198
|
+
(umask 077 && (cat > <%= Chef::Dist::CONF_DIR %>/validation.pem <<'EOP'
|
200
199
|
<%= validation_key %>
|
201
200
|
EOP
|
202
|
-
|
201
|
+
)) || exit 1
|
203
202
|
<% end -%>
|
204
203
|
|
205
204
|
<% if encrypted_data_bag_secret -%>
|
206
|
-
cat > <%= Chef::Dist::CONF_DIR %>/encrypted_data_bag_secret <<'EOP'
|
205
|
+
(umask 077 && (cat > <%= Chef::Dist::CONF_DIR %>/encrypted_data_bag_secret <<'EOP'
|
207
206
|
<%= encrypted_data_bag_secret %>
|
208
207
|
EOP
|
209
|
-
|
208
|
+
)) || exit 1
|
210
209
|
<% end -%>
|
211
210
|
|
212
211
|
<% unless trusted_certs.empty? -%>
|
@@ -240,4 +239,4 @@ mkdir -p <%= Chef::Dist::CONF_DIR %>/client.d
|
|
240
239
|
|
241
240
|
echo "Starting the first <%= Chef::Dist::PRODUCT %> Client run..."
|
242
241
|
|
243
|
-
<%= start_chef %>
|
242
|
+
<%= start_chef %>
|
@@ -36,7 +36,7 @@ class Chef
|
|
36
36
|
def self.included(base)
|
37
37
|
base.option :secret,
|
38
38
|
short: "-s SECRET",
|
39
|
-
long: "--secret ",
|
39
|
+
long: "--secret SECRET",
|
40
40
|
description: "The secret key to use to encrypt data bag item values. Can also be defaulted in your config with the key 'secret'.",
|
41
41
|
# Need to store value from command line in separate variable - knife#merge_configs populates same keys
|
42
42
|
# on config object from
|
@@ -80,9 +80,16 @@ class Chef
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def validate_secrets
|
83
|
-
if has_cl_secret?
|
84
|
-
|
85
|
-
|
83
|
+
if has_cl_secret?
|
84
|
+
if opt_parser.default_argv.include?("-s")
|
85
|
+
ui.warn("Secret short option -s is deprecated and will remove in the future. Please use --secret instead.
|
86
|
+
")
|
87
|
+
end
|
88
|
+
|
89
|
+
if has_cl_secret_file?
|
90
|
+
ui.fatal("Please specify only one of --secret, --secret-file")
|
91
|
+
exit(1)
|
92
|
+
end
|
86
93
|
end
|
87
94
|
|
88
95
|
if knife_config[:secret] && knife_config[:secret_file]
|
data/lib/chef/knife/download.rb
CHANGED
@@ -43,7 +43,7 @@ class Chef
|
|
43
43
|
long: "--[no-]force",
|
44
44
|
boolean: true,
|
45
45
|
default: false,
|
46
|
-
description: "Force
|
46
|
+
description: "Force download of files even if they match (quicker and harmless, but doesn't print out what it changed)."
|
47
47
|
|
48
48
|
option :dry_run,
|
49
49
|
long: "--dry-run",
|
@@ -56,7 +56,7 @@ class Chef
|
|
56
56
|
long: "--[no-]diff",
|
57
57
|
boolean: true,
|
58
58
|
default: true,
|
59
|
-
description: "Turn off to avoid
|
59
|
+
description: "Turn off to avoid downloading existing files; only new (and possibly deleted) files with --no-diff."
|
60
60
|
|
61
61
|
option :cookbook_version,
|
62
62
|
long: "--cookbook-version VERSION",
|
data/lib/chef/knife/exec.rb
CHANGED
@@ -40,7 +40,7 @@ class Chef::Knife::Exec < Chef::Knife
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def run
|
43
|
-
config[:script_path]
|
43
|
+
config[:script_path] = Array(config[:script_path] || Chef::Config[:script_path])
|
44
44
|
|
45
45
|
# Default script paths are chef-repo/.chef/scripts and ~/.chef/scripts
|
46
46
|
config[:script_path] << File.join(Chef::Knife.chef_config_dir, "scripts") if Chef::Knife.chef_config_dir
|
@@ -57,6 +57,14 @@ class Chef::Knife::Exec < Chef::Knife
|
|
57
57
|
context.instance_eval(IO.read(file), file, 0)
|
58
58
|
end
|
59
59
|
else
|
60
|
+
puts "An interactive shell is opened"
|
61
|
+
puts
|
62
|
+
puts "Type your script and do:"
|
63
|
+
puts
|
64
|
+
puts "1. To run the script, use 'Ctrl D'"
|
65
|
+
puts "2. To exit, use 'Ctrl/Shift C'"
|
66
|
+
puts
|
67
|
+
puts "Type here a script..."
|
60
68
|
script = STDIN.read
|
61
69
|
context.instance_eval(script, "STDIN", 0)
|
62
70
|
end
|
data/lib/chef/knife/ssh.rb
CHANGED
data/lib/chef/knife/ssl_check.rb
CHANGED
@@ -190,7 +190,7 @@ class Chef
|
|
190
190
|
#{ui.color("TO FIX THIS ERROR:", :bold)}
|
191
191
|
|
192
192
|
If the server you are connecting to uses a self-signed certificate, you must
|
193
|
-
configure
|
193
|
+
configure #{Chef::Dist::PRODUCT} to trust that server's certificate.
|
194
194
|
|
195
195
|
By default, the certificate is stored in the following location on the host
|
196
196
|
where your chef-server runs:
|
@@ -37,23 +37,35 @@ class Chef
|
|
37
37
|
default: "https://supermarket.chef.io",
|
38
38
|
proc: Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket }
|
39
39
|
|
40
|
+
option :sort_by,
|
41
|
+
long: "--sort-by SORT",
|
42
|
+
description: "Use to sort the records",
|
43
|
+
in: %w{recently_updated recently_added most_downloaded most_followed}
|
44
|
+
|
45
|
+
option :owned_by,
|
46
|
+
short: "-o USER",
|
47
|
+
long: "--owned-by USER",
|
48
|
+
description: "Show cookbooks that are owned by the USER"
|
49
|
+
|
40
50
|
def run
|
41
51
|
if config[:with_uri]
|
42
|
-
|
43
|
-
get_cookbook_list.each { |k, v| cookbooks[k] = v["cookbook"] }
|
44
|
-
ui.output(format_for_display(cookbooks))
|
52
|
+
ui.output(format_for_display(get_cookbook_list))
|
45
53
|
else
|
46
|
-
ui.msg(ui.list(get_cookbook_list.keys
|
54
|
+
ui.msg(ui.list(get_cookbook_list.keys, :columns_down))
|
47
55
|
end
|
48
56
|
end
|
49
57
|
|
50
|
-
|
58
|
+
# In order to avoid pagination items limit set to 9999999
|
59
|
+
def get_cookbook_list(items = 9999999, start = 0, cookbook_collection = {})
|
51
60
|
cookbooks_url = "#{config[:supermarket_site]}/api/v1/cookbooks?items=#{items}&start=#{start}"
|
61
|
+
cookbooks_url << "&order=#{config[:sort_by]}" if config[:sort_by]
|
62
|
+
cookbooks_url << "&user=#{config[:owned_by]}" if config[:owned_by]
|
52
63
|
cr = noauth_rest.get(cookbooks_url)
|
64
|
+
|
53
65
|
cr["items"].each do |cookbook|
|
54
|
-
cookbook_collection[cookbook["cookbook_name"]] = cookbook
|
66
|
+
cookbook_collection[cookbook["cookbook_name"]] = cookbook["cookbook"]
|
55
67
|
end
|
56
|
-
new_start = start +
|
68
|
+
new_start = start + items
|
57
69
|
if new_start < cr["total"]
|
58
70
|
get_cookbook_list(items, new_start, cookbook_collection)
|
59
71
|
else
|
@@ -35,13 +35,14 @@ class Chef
|
|
35
35
|
output(search_cookbook(name_args[0]))
|
36
36
|
end
|
37
37
|
|
38
|
-
|
38
|
+
# In order to avoid pagination items limit set to 9999999
|
39
|
+
def search_cookbook(query, items = 9999999, start = 0, cookbook_collection = {})
|
39
40
|
cookbooks_url = "#{config[:supermarket_site]}/api/v1/search?q=#{query}&items=#{items}&start=#{start}"
|
40
41
|
cr = noauth_rest.get(cookbooks_url)
|
41
42
|
cr["items"].each do |cookbook|
|
42
43
|
cookbook_collection[cookbook["cookbook_name"]] = cookbook
|
43
44
|
end
|
44
|
-
new_start = start +
|
45
|
+
new_start = start + items
|
45
46
|
if new_start < cr["total"]
|
46
47
|
search_cookbook(query, items, new_start, cookbook_collection)
|
47
48
|
else
|
data/lib/chef/node/attribute.rb
CHANGED
@@ -65,6 +65,10 @@ class Chef
|
|
65
65
|
Array.new(map { |e| safe_dup(e) })
|
66
66
|
end
|
67
67
|
|
68
|
+
def to_yaml(*opts)
|
69
|
+
to_a.to_yaml(*opts)
|
70
|
+
end
|
71
|
+
|
68
72
|
private
|
69
73
|
|
70
74
|
def convert_value(value)
|
@@ -172,6 +176,10 @@ class Chef
|
|
172
176
|
Mash.new(self)
|
173
177
|
end
|
174
178
|
|
179
|
+
def to_yaml(*opts)
|
180
|
+
to_h.to_yaml(*opts)
|
181
|
+
end
|
182
|
+
|
175
183
|
prepend Chef::Node::Mixin::StateTracking
|
176
184
|
end
|
177
185
|
end
|
@@ -96,6 +96,12 @@ class Chef
|
|
96
96
|
|
97
97
|
alias_method :to_array, :to_a
|
98
98
|
|
99
|
+
# As Psych module, not respecting ImmutableArray object
|
100
|
+
# So first convert it to Hash/Array then parse it to `.to_yaml`
|
101
|
+
def to_yaml(*opts)
|
102
|
+
to_a.to_yaml(*opts)
|
103
|
+
end
|
104
|
+
|
99
105
|
private
|
100
106
|
|
101
107
|
# needed for __path__
|
@@ -168,6 +174,12 @@ class Chef
|
|
168
174
|
|
169
175
|
alias_method :to_hash, :to_h
|
170
176
|
|
177
|
+
# As Psych module, not respecting ImmutableMash object
|
178
|
+
# So first convert it to Hash/Array then parse it to `.to_yaml`
|
179
|
+
def to_yaml(*opts)
|
180
|
+
to_h.to_yaml(*opts)
|
181
|
+
end
|
182
|
+
|
171
183
|
# For elements like Fixnums, true, nil...
|
172
184
|
def safe_dup(e)
|
173
185
|
e.dup
|
data/lib/chef/provider.rb
CHANGED
@@ -272,11 +272,17 @@ class Chef
|
|
272
272
|
raise ArgumentError, "converge_if_changed must be passed a block!"
|
273
273
|
end
|
274
274
|
|
275
|
-
properties =
|
276
|
-
|
275
|
+
properties =
|
276
|
+
if properties.empty?
|
277
|
+
new_resource.class.state_properties
|
278
|
+
else
|
279
|
+
properties.map { |property| new_resource.class.properties[property] }
|
280
|
+
end
|
281
|
+
|
277
282
|
if current_resource
|
278
283
|
# Collect the list of modified properties
|
279
|
-
specified_properties = properties.select { |property|
|
284
|
+
specified_properties = properties.select { |property| property.is_set?(new_resource) || property.has_default? }
|
285
|
+
specified_properties = specified_properties.map(&:name).map(&:to_sym)
|
280
286
|
modified = specified_properties.select { |p| new_resource.send(p) != current_resource.send(p) }
|
281
287
|
if modified.empty?
|
282
288
|
properties_str = if new_resource.sensitive
|
@@ -309,15 +315,15 @@ class Chef
|
|
309
315
|
else
|
310
316
|
# The resource doesn't exist. Mark that we are *creating* this, and
|
311
317
|
# write down any properties we are setting.
|
312
|
-
property_size = properties.map(&:size).max
|
318
|
+
property_size = properties.map(&:name).map(&:to_sym).map(&:size).max
|
313
319
|
created = properties.map do |property|
|
314
|
-
default = " (default value)" unless
|
315
|
-
properties_str = if new_resource.sensitive ||
|
320
|
+
default = " (default value)" unless property.is_set?(new_resource)
|
321
|
+
properties_str = if new_resource.sensitive || property.sensitive?
|
316
322
|
"(suppressed sensitive property)"
|
317
323
|
else
|
318
|
-
new_resource.send(property).inspect
|
324
|
+
new_resource.send(property.name.to_sym).inspect
|
319
325
|
end
|
320
|
-
" set #{property.to_s.ljust(property_size)} to #{properties_str}#{default}"
|
326
|
+
" set #{property.name.to_sym.to_s.ljust(property_size)} to #{properties_str}#{default}"
|
321
327
|
end
|
322
328
|
|
323
329
|
converge_by([ "create #{new_resource.identity}" ] + created, &converge_block)
|