Skip to content
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

Fix rights (always present) #28

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ For debian users, the config_include_dir has been defaulted to /etc/mysql/conf.d
percona::rights {'userbar on dbfoo':
priv => 'select_priv',
host => 'localhost',
database => '*'
database => '*',
password => 'default',
}

Expand Down
2 changes: 1 addition & 1 deletion manifests/adminpass.pp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
exec {"percona-adminpass-${name}":
onlyif => [
'test -f /usr/bin/mysqladmin',
"mysqladmin -u${user} -h${host} --no-defaults status",
"mysqladmin --no-defaults -u${user} -h${host} status",
],
path => ['/usr/bin','/bin',],
command => "mysqladmin -h ${host} -u${user} password ${password}",
Expand Down
34 changes: 31 additions & 3 deletions manifests/config/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
$config_skip = $::percona::config_skip

$logdir = $::percona::logdir
$logdir_link = $::percona::logdir_link
$server = $::percona::server
$service_name = $::percona::service_name
$service_restart = $::percona::service_restart
Expand All @@ -27,6 +28,9 @@
$configuration = $::percona::configuration
$default_configuration = $::percona::params::default_configuration

$daemon_group = $::percona::daemon_group
$daemon_user = $::percona::daemon_user

File {
owner => $config_user,
group => $config_group,
Expand Down Expand Up @@ -131,11 +135,35 @@
}
}

file { $logdir :
ensure => 'directory',
mode => $config_dir_mode,


if $logdir_link {
file { $logdir_link :
ensure => 'directory',
mode => $config_dir_mode,
group => $daemon_group,
owner => $daemon_user,
}

file { $logdir :
ensure => 'link',
target => $logdir_link,
mode => $config_dir_mode,
group => $daemon_group,
owner => $daemon_user,
}
}
else {
file { $logdir :
ensure => 'directory',
mode => $config_dir_mode,
group => $daemon_group,
owner => $daemon_user,
}
}



if $config_skip != true {
file { $config_file:
ensure => 'present',
Expand Down
25 changes: 25 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@

$tmpdir = $percona::params::tmpdir,
$logdir = $percona::params::logdir,
$logdir_link = $percona::params::logdir_link,
$socket = $percona::params::socket,
$datadir = $percona::params::datadir,
$targetdir = $percona::params::targetdir,
Expand All @@ -100,11 +101,14 @@
$pkg_version = $percona::params::pkg_version,

$mgmt_cnf = $percona::params::mgmt_cnf,
$root_password = undef,

## These options can NOT be defaulted in percona::params.
# They are specific for this server instance.
$configuration = {},
$servername = $::fqdn,
$databases = undef,
$users = undef,

## These settings are defaulted distro specific ##
$template = $percona::params::template,
Expand Down Expand Up @@ -141,6 +145,7 @@

'xtrabackup/datadir' => $::percona::datadir,
'xtrabackup/target_dir' => $::percona::targetdir,
'xtrabackup/socket' => $::percona::socket,
},
}

Expand All @@ -149,6 +154,26 @@
include percona::config
include percona::service

if $users {
create_resources('percona::rights', hiera_hash('percona::users', $users))
}

if $databases {
create_resources('percona::database', hiera_hash('percona::databases', $databases))
}

if $root_password {
percona::adminpass{ 'root':
password => $root_password,
}

percona::mgmt_cnf { $mgmt_cnf:
password => $root_password,
user => 'root',
socket => $::percona::socket,
}
}

Class['percona::preinstall'] ->
Class['percona::install'] ->
Class['percona::config'] ->
Expand Down
1 change: 1 addition & 0 deletions manifests/mgmt_cnf.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#
define percona::mgmt_cnf (
$password,
$socket,
$user = 'root',
$owner = 'root',
$group = 'root',
Expand Down
7 changes: 7 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
# $config_file:: Location of the default mysql my.cnf config file
# for your operatingsystem.
#
#
# === Extra parameters:
#
# $logdir_link:: Location of the folder which holds the mysql logs
# linked from original logs directory
#
# === Examples:
#
# ==== Setting global and default configuration options.
Expand Down Expand Up @@ -62,6 +68,7 @@
$daemon_user = 'mysql',
$tmpdir = undef,
$logdir = '/var/log/percona',
$logdir_link = undef,
$socket = '/var/lib/mysql/mysql.sock',
$datadir = '/var/lib/mysql',
$targetdir = '/data/backups/mysql/',
Expand Down
2 changes: 1 addition & 1 deletion manifests/rights.pp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
}

mysql_user { "${_user}@${_host}":
ensure => 'present',
ensure => $ensure,
password_hash => $pwhash,
mgmt_cnf => $mycnf,
require => [
Expand Down
38 changes: 38 additions & 0 deletions manifests/security.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# == Class: percona::security
#
# === Todo:
#
# TODO: Document class.
#
# Some installations have some default users which are not required.
# We remove them here. You can subclass this class to overwrite this behavior.
class percona::security (
$mgmt_cnf = undef
) {
$mycnf = $mgmt_cnf ? {
undef => $::percona::mgmt_cnf,
default => $mgmt_cnf,
}

$users = ["root@${::fqdn}", '[email protected]', 'root@::1', "@${::fqdn}", '@localhost', '@%']

mysql_user { $users:
ensure => 'absent',
mgmt_cnf => $mycnf,
require => [Service[$::percona::service_name], Percona::Mgmt_cnf[$mycnf]],
}

if ($::fqdn != $::hostname) {
mysql_user { ["root@${::hostname}", "@${::hostname}"]:
ensure => 'absent',
mgmt_cnf => $mycnf,
require => [Service[$::percona::service_name], Percona::Mgmt_cnf[$mycnf]],
}
}

mysql_database { 'test':
ensure => 'absent',
mgmt_cnf => $mycnf,
require => [Service[$::percona::service_name], Percona::Mgmt_cnf[$mycnf]],
}
}
8 changes: 8 additions & 0 deletions templates/mgmt_cnf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@
## Served by: '<%= scope.lookupvar('::servername') %>'
## Module: '<%= scope.to_hash['module_name'] %>'
## Template source: 'MODULES<%= template_source.gsub(Regexp.new("^#{Puppet::Node::Environment.current[:modulepath].gsub(':','|')}"),"") %>'
[client]
user = <%= user %>
password = <%= password %>
socket = <%= socket %>

[mysql]
user = <%= user %>
password = <%= password %>
socket = <%= socket %>

[mysqldump]
user = <%= user %>
password = <%= password %>
socket = <%= socket %>

[mysqladmin]
user = <%= user %>
password = <%= password %>
socket = <%= socket %>