summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2021-07-06 10:20:43 -0700
committerGitHub <noreply@github.com>2021-07-06 10:20:43 -0700
commit20ca8dd141e2fabff24746f2dd2886a23cafdd1d (patch)
tree4162b8067259810dbb7401a1775f4c94be11d465
parent3431d0251816edbe8bbef23f27a1d18ca0376565 (diff)
parent0181c597552b6e5855224c37a3583a2c0ec1aa59 (diff)
downloadchef-20ca8dd141e2fabff24746f2dd2886a23cafdd1d.tar.gz
Merge pull request #11766 from chef/config
Fix handling of ohai properties in chef_client_config
-rw-r--r--kitchen-tests/cookbooks/end_to_end/recipes/_chef_client_config.rb2
-rw-r--r--lib/chef/resource/support/client.erb6
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) -%>