Skip to content

Commit a6101dc

Browse files
author
Ashley Penney
committed
Merge pull request #303 from treydock/fix_monitor_privileges
Fix mysql::server::monitor mysql_grant privileges
2 parents 4e6b792 + 2132dd3 commit a6101dc

File tree

3 files changed

+51
-9
lines changed

3 files changed

+51
-9
lines changed

manifests/server/monitor.pp

+4-5
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,17 @@
66
$mysql_monitor_hostname
77
) {
88

9-
Class['mysql::server'] -> Class['mysql::server::monitor']
10-
11-
mysql_user{ "${mysql_monitor_username}@${mysql_monitor_hostname}":
9+
mysql_user { "${mysql_monitor_username}@${mysql_monitor_hostname}":
1210
ensure => present,
1311
password_hash => mysql_password($mysql_monitor_password),
12+
require => Class['mysql::config'],
1413
}
1514

16-
mysql_grant { "${mysql_monitor_username}@${mysql_monitor_hostname}":
15+
mysql_grant { "${mysql_monitor_username}@${mysql_monitor_hostname}/*.*":
1716
ensure => present,
1817
user => "${mysql_monitor_username}@${mysql_monitor_hostname}",
1918
table => '*.*',
20-
privileges => [ 'PROCESS_PRIV', 'SUPER_PRIV' ],
19+
privileges => [ 'PROCESS', 'SUPER' ],
2120
require => Mysql_user["${mysql_monitor_username}@${mysql_monitor_hostname}"],
2221
}
2322

spec/classes/mysql_server_monitor_spec.rb

+17-4
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,26 @@
66
let :pre_condition do
77
"include 'mysql::server'"
88
end
9-
let :params do
9+
10+
let :default_params do
1011
{
11-
:mysql_monitor_username => 'monitoruser',
12-
:mysql_monitor_password => 'monitorpass',
13-
:mysql_monitor_hostname => 'monitorhost'
12+
:mysql_monitor_username => 'monitoruser',
13+
:mysql_monitor_password => 'monitorpass',
14+
:mysql_monitor_hostname => 'monitorhost',
1415
}
1516
end
1617

18+
let :params do
19+
default_params
20+
end
21+
1722
it { should contain_mysql_user('monitoruser@monitorhost')}
23+
24+
it { should contain_mysql_grant('monitoruser@monitorhost/*.*').with(
25+
:ensure => 'present',
26+
:user => 'monitoruser@monitorhost',
27+
:table => '*.*',
28+
:privileges => ["PROCESS", "SUPER"],
29+
:require => 'Mysql_user[monitoruser@monitorhost]'
30+
)}
1831
end
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
require 'spec_helper_system'
2+
3+
describe 'mysql::server::monitor class' do
4+
context 'should work with no errors' do
5+
pp = <<-EOS
6+
class { 'mysql::server': config_hash => { 'root_password' => 'foo' } }
7+
8+
class { 'mysql::server::monitor':
9+
mysql_monitor_username => 'monitoruser',
10+
mysql_monitor_password => 'monitorpass',
11+
mysql_monitor_hostname => 'localhost',
12+
}
13+
EOS
14+
15+
context puppet_apply(pp) do
16+
its(:stderr) { should be_empty }
17+
its(:exit_code) { should_not == 1 }
18+
its(:refresh) { should be_nil }
19+
its(:stderr) { should be_empty }
20+
its(:exit_code) { should be_zero }
21+
end
22+
23+
context 'should run mysqladmin ping with no errors' do
24+
describe command("mysqladmin -u monitoruser -pmonitorpass -h localhost ping") do
25+
it { should return_stdout /mysqld is alive/ }
26+
it { should return_exit_status 0 }
27+
end
28+
end
29+
end
30+
end

0 commit comments

Comments
 (0)