Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chef_client_config errors out for bool property #14254

Open
gaoweisgp opened this issue Feb 23, 2024 · 0 comments
Open

chef_client_config errors out for bool property #14254

gaoweisgp opened this issue Feb 23, 2024 · 0 comments
Labels
Chef 18.5 Status: Waiting on Release Ready to merge, but waiting on cutting a release

Comments

@gaoweisgp
Copy link

Description

When I tried to set a bool property inside chef_client_config resource, like

  • policy_persist_run_list
  • minimal_ohai

the chef compilation fails with the following error:

        template("/etc/cinc/client.rb") do
        action [:create]
        default_guard_interpreter :default
        source "/opt/cinc/embedded/lib/ruby/gems/2.7.0/gems/chef-16.16.13/lib/chef/resource/support/client.erb"
        declared_type :template
        cookbook_name "system-base"
        owner "root"
        group "root"
        local true
        variables {:chef_license=>"accept", :chef_server_url=>"chefzero://localhost:1", :event_loggers=>[], :exception_handlers=>[], :file_backup_path=>"/var/lib/chef", :file_cache_path=>"/var/chef/cache", :file_staging_uses_destdir=>nil, :formatters=>[], :http_proxy=>nil, :https_proxy=>nil, :ftp_proxy=>nil, :log_level=>:info, :log_location=>"/var/log/chef/client.log", :minimal_ohai=>false, :named_run_list=>nil, :no_proxy=>"", :node_name=>"wgao-redhat-79", :ohai_disabled_plugins=>[], :ohai_optional_plugins=>[], :pid_file=>"var/run/chef/client.pid", :policy_group=>nil, :policy_name=>nil, :report_handlers=>[], :ssl_verify_mode=>:verify_none, :start_handlers=>[], :additional_config=>nil}
        mode "0640"
        path "/etc/cinc/client.rb"
        verifications []
             end
             
             Template Context:
             -----------------
             on line #22
       20:       @policy_name
       21:       @ssl_verify_mode).each do |prop| -%>
       22: <% next if instance_variable_get(prop).nil? || instance_variable_get(prop).empty? -%>
       23: <%=prop.delete_prefix("@") %> <%= instance_variable_get(prop).inspect %>
       24: <% end -%>
             
             System Info:
             ------------
             chef_version=16.16.13
             platform=redhat
             platform_version=7.9
             ruby=ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x86_64-linux]
             program_name=/opt/cinc/bin/cinc-client
             executable=/opt/cinc/bin/cinc-client
             
           
           ================================================================================
           Error executing action `create` on resource 'chef_client_config[Create client.rb]'
           ================================================================================
           
           Chef::Mixin::Template::TemplateError
           ------------------------------------
           undefined method `empty?' for false:FalseClass

This code looks like is from
https://github.com/chef/chef/blob/main/lib/chef/resource/support/client.erb#L22

<% next if instance_variable_get(prop).nil? || instance_variable_get(prop).empty? -%>

Quick Ruby testing

irb(main):001:0> false.nil?
=> false
irb(main):002:0> false.empty?
NoMethodError: undefined method `empty?' for false:FalseClass
	from (irb):2
	from /bin/irb:12:in `<main>'
irb(main):003:0> 

Chef Version

16.16.13

Platform Version

RHEL 7.9

Replication Case

See above Ruby test

Client Output

See above inside issue description

Stacktrace

See above inside issue description

@gaoweisgp gaoweisgp added the Status: Untriaged An issue that has yet to be triaged. label Feb 23, 2024
@tpowell-progress tpowell-progress added Status: Waiting on Release Ready to merge, but waiting on cutting a release Chef 18.5 and removed Status: Untriaged An issue that has yet to be triaged. labels Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Chef 18.5 Status: Waiting on Release Ready to merge, but waiting on cutting a release
Projects
None yet
Development

No branches or pull requests

2 participants