I've dumped the entire node into the logs to prove that my attribute booleans are getting set.
Here's my modified version of your code. I never see the "GOT HERE 2" message. It's as though the next unless value.nil? command always skips to the next iteration of the loop, no matter what. If I remove that line, things work fine.
log "============= GOT HERE =================="
node['selinux']['booleans'].each do |boolean, value|
value = SELinuxServiceHelpers.selinux_bool(value)
log "Is value of #{boolean} nil?: #{value.nil?}"
next unless value.nil?
log '================== GOT HERE 2 ================='
log "Processing #{boolean} #{value}"
script "boolean_#{boolean}" do
interpreter 'bash'
code "setsebool -P #{boolean} #{value}"
not_if "getsebool #{boolean} |egrep -q \" #{value}\"$"
end
end
Expected Result:
Expecting the setsebool script to run.
Actual Result:
* log[============= GOT HERE ==================] action write
* log[Is value of httpd_can_sendmail nil?: false] action write
* log[Is value of httpd_can_connect_ldap nil?: false] action write
* log[Is value of httpd_can_network_memcache nil?: false] action write
Cookbook version
2.0.2
Chef-client version
13.1.31
Platform Details
CentOS 7.3
Scenario:
Trying to do setsebool commands using
default['selinux']['booleans']
hash in my cookbook'sattributes\default.rb
file.Steps to Reproduce:
I extracted your code and added logging to figure out which line was failing.
Here's what's in my attributes\default.rb file:
I've dumped the entire node into the logs to prove that my attribute booleans are getting set.
Here's my modified version of your code. I never see the "GOT HERE 2" message. It's as though the
next unless value.nil?
command always skips to the next iteration of the loop, no matter what. If I remove that line, things work fine.Expected Result:
Expecting the setsebool script to run.
Actual Result: