Using node.default_unless instead of node.default in _attributes
* Wrapper cookbook usually uses default level to override attributes of the wrapped cookbook. Here, we had a problem because if the wrapper cookbook was enabling sasl and was setting a relayhost and a user/password combination using the default level, this was not working because _attributes resets those attributes. To fix this, we now use node.default_unless which will set the attribute only if it's not already set ensuring that wrapper cookbook overriden attributes using default level are correctly kept when computing derived attributes.
This commit is contained in:
20
spec/wrapper_spec.rb
Normal file
20
spec/wrapper_spec.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
require 'spec_helper'
|
||||
|
||||
##
|
||||
# Spec to ensure wrapper cookbook can correctly override
|
||||
# attributes using default level without _attributes
|
||||
# recipe clearing them.
|
||||
|
||||
describe 'wrapper::default' do
|
||||
cached(:chef_run) do
|
||||
ChefSpec::SoloRunner.new.converge(described_recipe)
|
||||
end
|
||||
|
||||
describe '_attributes recipes' do
|
||||
it 'keeps wrapper cookbook default set attributes' do
|
||||
expect(chef_run.node['postfix']['main']['relayhost']).to eq('please')
|
||||
expect(chef_run.node['postfix']['main']['smtp_sasl_security_options']).to eq('keep')
|
||||
expect(chef_run.node['postfix']['sasl']['smtp_sasl_user_name']).to eq('us')
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user