Skip to content

Fix mysql::server::monitor mysql_grant privileges #303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 7, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions manifests/server/monitor.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@
$mysql_monitor_hostname
) {

Class['mysql::server'] -> Class['mysql::server::monitor']

mysql_user{ "${mysql_monitor_username}@${mysql_monitor_hostname}":
mysql_user { "${mysql_monitor_username}@${mysql_monitor_hostname}":
ensure => present,
password_hash => mysql_password($mysql_monitor_password),
require => Class['mysql::config'],
}

mysql_grant { "${mysql_monitor_username}@${mysql_monitor_hostname}":
mysql_grant { "${mysql_monitor_username}@${mysql_monitor_hostname}/*.*":
ensure => present,
user => "${mysql_monitor_username}@${mysql_monitor_hostname}",
table => '*.*',
privileges => [ 'PROCESS_PRIV', 'SUPER_PRIV' ],
privileges => [ 'PROCESS', 'SUPER' ],
require => Mysql_user["${mysql_monitor_username}@${mysql_monitor_hostname}"],
}

Expand Down
21 changes: 17 additions & 4 deletions spec/classes/mysql_server_monitor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,26 @@
let :pre_condition do
"include 'mysql::server'"
end
let :params do

let :default_params do
{
:mysql_monitor_username => 'monitoruser',
:mysql_monitor_password => 'monitorpass',
:mysql_monitor_hostname => 'monitorhost'
:mysql_monitor_username => 'monitoruser',
:mysql_monitor_password => 'monitorpass',
:mysql_monitor_hostname => 'monitorhost',
}
end

let :params do
default_params
end

it { should contain_mysql_user('monitoruser@monitorhost')}

it { should contain_mysql_grant('monitoruser@monitorhost/*.*').with(
:ensure => 'present',
:user => 'monitoruser@monitorhost',
:table => '*.*',
:privileges => ["PROCESS", "SUPER"],
:require => 'Mysql_user[monitoruser@monitorhost]'
)}
end
30 changes: 30 additions & 0 deletions spec/system/mysql_server_monitor_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require 'spec_helper_system'

describe 'mysql::server::monitor class' do
context 'should work with no errors' do
pp = <<-EOS
class { 'mysql::server': config_hash => { 'root_password' => 'foo' } }

class { 'mysql::server::monitor':
mysql_monitor_username => 'monitoruser',
mysql_monitor_password => 'monitorpass',
mysql_monitor_hostname => 'localhost',
}
EOS

context puppet_apply(pp) do
its(:stderr) { should be_empty }
its(:exit_code) { should_not == 1 }
its(:refresh) { should be_nil }
its(:stderr) { should be_empty }
its(:exit_code) { should be_zero }
end

context 'should run mysqladmin ping with no errors' do
describe command("mysqladmin -u monitoruser -pmonitorpass -h localhost ping") do
it { should return_stdout /mysqld is alive/ }
it { should return_exit_status 0 }
end
end
end
end