diff options
author | Tim Smith <tsmith@chef.io> | 2021-07-01 13:02:51 -0700 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2021-07-01 13:02:51 -0700 |
commit | 0181c597552b6e5855224c37a3583a2c0ec1aa59 (patch) | |
tree | 6757cc8e4cae95d6125c0392815f9b108e66cfaa | |
parent | ec33c4b9b46f6905e14aef7deda2cd9637af5078 (diff) | |
download | chef-0181c597552b6e5855224c37a3583a2c0ec1aa59.tar.gz |
Fix handling of ohai properties in chef_client_config
These 2 properties don't match the config format so the existing logic
didn't work.
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | kitchen-tests/cookbooks/end_to_end/recipes/_chef_client_config.rb | 2 | ||||
-rw-r--r-- | lib/chef/resource/support/client.erb | 6 |
2 files changed, 8 insertions, 0 deletions
diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/_chef_client_config.rb b/kitchen-tests/cookbooks/end_to_end/recipes/_chef_client_config.rb index 0e68582af0..c2a6e4254b 100644 --- a/kitchen-tests/cookbooks/end_to_end/recipes/_chef_client_config.rb +++ b/kitchen-tests/cookbooks/end_to_end/recipes/_chef_client_config.rb @@ -1,6 +1,8 @@ chef_client_config "Create chef-client's client.rb" do chef_server_url "https://localhost" chef_license "accept" + ohai_optional_plugins %i{Passwd Lspci Sysctl} + ohai_disabled_plugins %i{Sessions Interrupts} additional_config <<~CONFIG begin require 'aws-sdk' diff --git a/lib/chef/resource/support/client.erb b/lib/chef/resource/support/client.erb index 6507c74440..69faf0fcf6 100644 --- a/lib/chef/resource/support/client.erb +++ b/lib/chef/resource/support/client.erb @@ -22,6 +22,12 @@ <% next if instance_variable_get(prop).nil? || instance_variable_get(prop).empty? -%> <%=prop.delete_prefix("@") %> <%= instance_variable_get(prop).inspect %> <% end -%> +<%# ohai_disabled_plugins and ohai_optional_plugins properties don't match the config value perfectly-%> +<% %w(@ohai_disabled_plugins + @ohai_optional_plugins).each do |prop| -%> +<% next if instance_variable_get(prop).nil? || instance_variable_get(prop).empty? -%> +<%=prop.gsub("@ohai_", "ohai.") %> <%= instance_variable_get(prop).inspect %> +<% end -%> <%# log_location is special due to STDOUT/STDERR from String -> IO Object -%> <% unless @log_location.nil? %> <% if @log_location.is_a?(String) && %w(STDOUT STDERR).include?(@log_location) -%> |