Skip to content

Commit 136b1aa

Browse files
committed
Allow options with values of false to override things that mysql default to true
instead of being elided, leaving the default.
1 parent 08e8477 commit 136b1aa

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

spec/classes/mysql_server_spec.rb

+18
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,24 @@
3333
end
3434
end
3535

36+
describe 'an option set to true' do
37+
let(:params) {
38+
{ :override_options => { 'mysqld' => { 'ssl' => true } }}
39+
}
40+
it do
41+
should contain_file('/etc/my.cnf').with_content(/^\s*ssl\s*(?:$|= true)/m)
42+
end
43+
end
44+
45+
describe 'an option set to false' do
46+
let(:params) {
47+
{ :override_options => { 'mysqld' => { 'ssl' => false } }}
48+
}
49+
it do
50+
should contain_file('/etc/my.cnf').with_content(/^\s*ssl = false/m)
51+
end
52+
end
53+
3654
context 'with remove_default_accounts set' do
3755
let (:params) {{ :remove_default_accounts => true }}
3856
it { should contain_class('mysql::server::account_security') }

templates/my.cnf.erb

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22
<% if v.is_a?(Hash) -%>
33
[<%= k %>]
44
<% v.sort.map do |ki, vi| -%>
5-
<% if vi == true -%>
5+
<% if vi == true or v == '' -%>
66
<%= ki %>
77
<% elsif vi.is_a?(Array) -%>
88
<% vi.each do |vii| -%>
99
<%= ki %> = <%= vii %>
1010
<% end -%>
11-
<% elsif vi and vi != '' -%>
11+
<% else -%>
1212
<%= ki %> = <%= vi %>
13-
<% elsif vi -%>
14-
<%= ki %>
1513
<% end -%>
1614
<% end -%>
1715
<% end %>

0 commit comments

Comments
 (0)