Skip to content

Commit 38a7aa0

Browse files
Jethro van GinkelJethro van Ginkel
Jethro van Ginkel
authored and
Jethro van Ginkel
committed
#puppethack allow undef value for bind-address
If set `bind-address` to `undef` the bind-address will not be set in the mysql-config file so MySQL is listening on all interfaces. ```puppet class { '::mysql::server': override_options => { mysqld => { bind-address => undef, }, } ```
1 parent 79682e7 commit 38a7aa0

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

spec/classes/mysql_server_spec.rb

+15
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,21 @@
9797

9898
it { is_expected.to contain_file('/tmp/error.log') }
9999
end
100+
context 'default bind-address' do
101+
let(:params) { }
102+
103+
it { is_expected.to contain_file('mysql-config-file').with_content(/^bind-address = 127.0.0.1/) }
104+
end
105+
context 'with defined bind-address' do
106+
let(:params) { { override_options: { 'mysqld' => { 'bind-address' => '1.1.1.1' } } } }
107+
108+
it { is_expected.to contain_file('mysql-config-file').with_content(/^bind-address = 1.1.1.1/) }
109+
end
110+
context 'without bind-address' do
111+
let(:params) { { override_options: { 'mysqld' => { 'bind-address' => :undef } } } }
112+
113+
it { is_expected.to contain_file('mysql-config-file').without_content(/^bind-address/) }
114+
end
100115
end
101116

102117
context 'mysql::server::root_password' do

templates/my.cnf.erb

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
<% v.sort.map do |ki, vi| -%>
77
<% if ki == 'ssl-disable' or (ki =~ /^ssl/ and v['ssl-disable'] == true) -%>
88
<% next %>
9+
<% elsif ki == 'bind-address' and vi == :undef -%>
10+
<% next %>
911
<% elsif vi == true or vi == '' -%>
1012
<%= ki %>
1113
<% elsif vi.is_a?(Array) -%>

0 commit comments

Comments
 (0)