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

Puppetlabs mysql rename #22

Open
wants to merge 14 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Gemfile.lock
/pkg/
.project
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require 'digest/sha1'

module Puppet::Parser::Functions
newfunction(:mysql_password, :type => :rvalue) do |args|
newfunction(:percona_password, :type => :rvalue) do |args|
'*' + Digest::SHA1.hexdigest(Digest::SHA1.digest(args[0])).upcase
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Puppet::Type.type(:mysql_database).provide(:mysql) do
Puppet::Type.type(:percona_database).provide(:mysql) do

desc "Use mysql as database."

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Puppet::Type.type(:mysql_grant).provide(:mysql) do
Puppet::Type.type(:percona_grant).provide(:mysql) do

desc "Uses mysql as database."

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Puppet::Type.type(:mysql_user).provide(:mysql) do
Puppet::Type.type(:percona_user).provide(:mysql) do

desc "Use mysql as database."

Expand Down Expand Up @@ -43,7 +43,7 @@ def exists?
end

def password_hash
mysql(mysql_args("mysql", "-NBe", "select password from mysql.user where CONCAT( user, '@', host) = '%s'" % @resource.value(:name))).chomp
mysql(mysql_args("mysql", "-NBe", "select authentication_string from mysql.user where CONCAT( user, '@', host) = '%s'" % @resource.value(:name))).chomp
end

def password_hash=(string)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This has to be a separate type to enable collecting
Puppet::Type.newtype(:mysql_database) do
Puppet::Type.newtype(:percona_database) do
@doc = "Manage a database."

ensurable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Puppet::Type.newtype(:mysql_grant) do
Puppet::Type.newtype(:percona_grant) do
@doc = "Manage a database user's rights."
#ensurable

autorequire :mysql_database do
autorequire :percona_database do
reqs = []
matches = self[:name].match(/^([^@]+)@([^\/]+)\/(.+)$/)
unless matches.nil?
Expand All @@ -11,7 +11,7 @@
reqs
end

autorequire :mysql_user do
autorequire :percona_user do
reqs = []
matches = self[:name].match(/^([^@]+)@([^\/]+).*$/)
unless matches.nil?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Puppet::Type.newtype(:mysql_user) do
Puppet::Type.newtype(:percona_user) do
@doc = "Manage a database user."

ensurable
Expand Down
12 changes: 7 additions & 5 deletions manifests/config/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,13 @@
}
}

file { $logdir :
ensure => 'directory',
mode => $config_dir_mode,
owner => $daemon_user,
group => $logdir_group,
unless File["${logdir}"] {
file { $logdir :
ensure => 'directory',
mode => $config_dir_mode,
owner => $daemon_user,
group => $logdir_group,
}
}

if $config_skip != true {
Expand Down
2 changes: 1 addition & 1 deletion manifests/database.pp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
default => $mgmt_cnf,
}

mysql_database { $name:
percona_database { $name:
ensure => $ensure,
charset => $charset,
mgmt_cnf => $mycnf,
Expand Down
12 changes: 8 additions & 4 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@
$template = $percona::params::template,
$config_dir = $percona::params::config_dir,
$config_file = $percona::params::_config_file,


$log_bin = $percona::params::log_bin,
$relay_log = $percona::params::relay_log,
$slow_query_log_file = $percona::params::slow_query_log_file,

) inherits percona::params {

$config_include_dir_default = $::percona::params::config_include_dir_default
Expand All @@ -131,9 +135,9 @@
'mysqld/socket' => $::percona::socket,
'mysqld/user' => $::percona::daemon_user,
'mysqld/innodb_log_group_home_dir' => $::percona::datadir,
'mysqld/log_bin' => "${::percona::datadir}/${sanitized_servername}-bin",
'mysqld/relay_log' => "${::percona::datadir}/${sanitized_servername}-relay",
'mysqld/slow_query_log_file' => "${::percona::logdir}/${::percona::servername}-slow.log",
'mysqld/log_bin' => $log_bin ? { undef => "${::percona::datadir}/${sanitized_servername}-bin", default => $log_bin },
'mysqld/relay_log' => $relay_log ? { undef => "${::percona::datadir}/${sanitized_servername}-relay", default => $relay_log },
'mysqld/slow_query_log_file' => $slow_query_log_file ? { undef => "${::percona::logdir}/${::percona::servername}-slow.log", default => $slow_query_log_file },
'mysqld/symbolic-links' => '0',

'mysqld_safe/log-error' => $::percona::errorlog,
Expand Down
9 changes: 9 additions & 0 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@
default => $::percona::pkg_compat,
}
}
'5.6': {
$pkg_compat = $::percona::pkg_compat
}
'5.7': {
$pkg_compat = $::percona::pkg_compat ? {
undef => 'Percona-Server-shared-compat-57',
default => $::percona::pkg_compat,
}
}
default: {
$pkg_compat = $::percona::pkg_compat ? {
undef => 'Percona-SQL-shared-compat',
Expand Down
6 changes: 5 additions & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@
'5.5' => {},
'5.1' => {},
'global' => {},
}
},

$log_bin = undef,
$relay_log = undef,
$slow_query_log_file = undef,
) {

case $::operatingsystem {
Expand Down
10 changes: 5 additions & 5 deletions manifests/rights.pp
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@
default => "${_user}@${_host}/${_database}",
}

if ! defined(Mysql_user["${_user}@${_host}"]) {
if ! defined(Percona_user["${_user}@${_host}"]) {
$pwhash = $hash ? {
undef => mysql_password($password),
undef => percona_password($password),
default => $hash,
}

mysql_user { "${_user}@${_host}":
percona_user { "${_user}@${_host}":
ensure => $ensure,
password_hash => $pwhash,
mgmt_cnf => $mycnf,
Expand All @@ -142,12 +142,12 @@
}
}

mysql_grant { $grant_name:
percona_grant { $grant_name:
privileges => $priv,
mgmt_cnf => $mycnf,
require => [
Service[$::percona::service_name],
Mysql_user["${_user}@${_host}"],
Percona_user["${_user}@${_host}"],
]
}

Expand Down