Merge pull request #90 from emonty/master
Add a bunch of new parameters
This commit is contained in:
commit
063d72493c
9 changed files with 388 additions and 74 deletions
|
@ -6,3 +6,5 @@ license 'Apache 2.0'
|
||||||
summary 'Mysql module'
|
summary 'Mysql module'
|
||||||
description 'Mysql module'
|
description 'Mysql module'
|
||||||
project_page 'http://github.com/puppetlabs/puppetlabs-mysql'
|
project_page 'http://github.com/puppetlabs/puppetlabs-mysql'
|
||||||
|
|
||||||
|
dependency 'openstackci/apparmor', '>= 0.0.1'
|
||||||
|
|
|
@ -7,31 +7,40 @@ Puppet::Type.type(:database).provide(:mysql) do
|
||||||
optional_commands :mysql => 'mysql'
|
optional_commands :mysql => 'mysql'
|
||||||
optional_commands :mysqladmin => 'mysqladmin'
|
optional_commands :mysqladmin => 'mysqladmin'
|
||||||
|
|
||||||
|
def defaults_file
|
||||||
|
case Facter.value(:operatingsystem)
|
||||||
|
when "Debian", "Ubuntu"
|
||||||
|
return "--defaults-file=/etc/mysql/debian.cnf"
|
||||||
|
else
|
||||||
|
return ""
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def self.instances
|
def self.instances
|
||||||
mysql('-NBe', "show databases").split("\n").collect do |name|
|
mysql(defaults_file, '-NBe', "show databases").split("\n").collect do |name|
|
||||||
new(:name => name)
|
new(:name => name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
mysql('-NBe', "create database `#{@resource[:name]}` character set #{resource[:charset]}")
|
mysql(defaults_file, '-NBe', "create database `#{@resource[:name]}` character set #{resource[:charset]}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
mysqladmin('-f', 'drop', @resource[:name])
|
mysqladmin(defaults_file, '-f', 'drop', @resource[:name])
|
||||||
end
|
end
|
||||||
|
|
||||||
def charset
|
def charset
|
||||||
mysql('-NBe', "show create database `#{resource[:name]}`").match(/.*?(\S+)\s\*\//)[1]
|
mysql(defaults_file, '-NBe', "show create database `#{resource[:name]}`").match(/.*?(\S+)\s\*\//)[1]
|
||||||
end
|
end
|
||||||
|
|
||||||
def charset=(value)
|
def charset=(value)
|
||||||
mysql('-NBe', "alter database `#{resource[:name]}` CHARACTER SET #{value}")
|
mysql(defaults_file, '-NBe', "alter database `#{resource[:name]}` CHARACTER SET #{value}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def exists?
|
def exists?
|
||||||
begin
|
begin
|
||||||
mysql('-NBe', "show databases").match(/^#{@resource[:name]}$/)
|
mysql(defaults_file, '-NBe', "show databases").match(/^#{@resource[:name]}$/)
|
||||||
rescue => e
|
rescue => e
|
||||||
debug(e.message)
|
debug(e.message)
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -12,6 +12,15 @@ Puppet::Type.type(:database_grant).provide(:mysql) do
|
||||||
optional_commands :mysql => 'mysql'
|
optional_commands :mysql => 'mysql'
|
||||||
optional_commands :mysqladmin => 'mysqladmin'
|
optional_commands :mysqladmin => 'mysqladmin'
|
||||||
|
|
||||||
|
def defaults_file
|
||||||
|
case Facter.value(:operatingsystem)
|
||||||
|
when "Debian", "Ubuntu"
|
||||||
|
return "--defaults-file=/etc/mysql/debian.cnf"
|
||||||
|
else
|
||||||
|
return ""
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def self.prefetch(resources)
|
def self.prefetch(resources)
|
||||||
@user_privs = query_user_privs
|
@user_privs = query_user_privs
|
||||||
@db_privs = query_db_privs
|
@db_privs = query_db_privs
|
||||||
|
@ -34,19 +43,19 @@ Puppet::Type.type(:database_grant).provide(:mysql) do
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.query_user_privs
|
def self.query_user_privs
|
||||||
results = mysql("mysql", "-Be", "describe user")
|
results = mysql(defaults_file, "-Be", "describe user")
|
||||||
column_names = results.split(/\n/).map { |l| l.chomp.split(/\t/)[0] }
|
column_names = results.split(/\n/).map { |l| l.chomp.split(/\t/)[0] }
|
||||||
@user_privs = column_names.delete_if { |e| !( e =~/_priv$/) }
|
@user_privs = column_names.delete_if { |e| !( e =~/_priv$/) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.query_db_privs
|
def self.query_db_privs
|
||||||
results = mysql("mysql", "-Be", "describe db")
|
results = mysql(defaults_file, "-Be", "describe db")
|
||||||
column_names = results.split(/\n/).map { |l| l.chomp.split(/\t/)[0] }
|
column_names = results.split(/\n/).map { |l| l.chomp.split(/\t/)[0] }
|
||||||
@db_privs = column_names.delete_if { |e| !(e =~/_priv$/) }
|
@db_privs = column_names.delete_if { |e| !(e =~/_priv$/) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def mysql_flush
|
def mysql_flush
|
||||||
mysqladmin "flush-privileges"
|
mysqladmin defaults_file, "flush-privileges"
|
||||||
end
|
end
|
||||||
|
|
||||||
# this parses the
|
# this parses the
|
||||||
|
@ -74,11 +83,11 @@ Puppet::Type.type(:database_grant).provide(:mysql) do
|
||||||
name = split_name(@resource[:name])
|
name = split_name(@resource[:name])
|
||||||
case name[:type]
|
case name[:type]
|
||||||
when :user
|
when :user
|
||||||
mysql "mysql", "-e", "INSERT INTO user (host, user) VALUES ('%s', '%s')" % [
|
mysql defaults_file, "-e", "INSERT INTO user (host, user) VALUES ('%s', '%s')" % [
|
||||||
name[:host], name[:user],
|
name[:host], name[:user],
|
||||||
]
|
]
|
||||||
when :db
|
when :db
|
||||||
mysql "mysql", "-e", "INSERT INTO db (host, user, db) VALUES ('%s', '%s', '%s')" % [
|
mysql defaults_file, "-e", "INSERT INTO db (host, user, db) VALUES ('%s', '%s', '%s')" % [
|
||||||
name[:host], name[:user], name[:db],
|
name[:host], name[:user], name[:db],
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
@ -87,7 +96,7 @@ Puppet::Type.type(:database_grant).provide(:mysql) do
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
mysql "mysql", "-e", "REVOKE ALL ON '%s'.* FROM '%s@%s'" % [ @resource[:privileges], @resource[:database], @resource[:name], @resource[:host] ]
|
mysql defaults_file, "-e", "REVOKE ALL ON '%s'.* FROM '%s@%s'" % [ @resource[:privileges], @resource[:database], @resource[:name], @resource[:host] ]
|
||||||
end
|
end
|
||||||
|
|
||||||
def row_exists?
|
def row_exists?
|
||||||
|
@ -96,7 +105,7 @@ Puppet::Type.type(:database_grant).provide(:mysql) do
|
||||||
if name[:type] == :db
|
if name[:type] == :db
|
||||||
fields << :db
|
fields << :db
|
||||||
end
|
end
|
||||||
not mysql( "mysql", "-NBe", 'SELECT "1" FROM %s WHERE %s' % [ name[:type], fields.map do |f| "%s = '%s'" % [f, name[f]] end.join(' AND ')]).empty?
|
not mysql( defaults_file, "-NBe", 'SELECT "1" FROM %s WHERE %s' % [ name[:type], fields.map do |f| "%s = '%s'" % [f, name[f]] end.join(' AND ')]).empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
def all_privs_set?
|
def all_privs_set?
|
||||||
|
@ -118,9 +127,9 @@ Puppet::Type.type(:database_grant).provide(:mysql) do
|
||||||
|
|
||||||
case name[:type]
|
case name[:type]
|
||||||
when :user
|
when :user
|
||||||
privs = mysql "mysql", "-Be", 'select * from user where user="%s" and host="%s"' % [ name[:user], name[:host] ]
|
privs = mysql defaults_file, "-Be", 'select * from user where user="%s" and host="%s"' % [ name[:user], name[:host] ]
|
||||||
when :db
|
when :db
|
||||||
privs = mysql "mysql", "-Be", 'select * from db where user="%s" and host="%s" and db="%s"' % [ name[:user], name[:host], name[:db] ]
|
privs = mysql defaults_file, "-Be", 'select * from db where user="%s" and host="%s" and db="%s"' % [ name[:user], name[:host], name[:db] ]
|
||||||
end
|
end
|
||||||
|
|
||||||
if privs.match(/^$/)
|
if privs.match(/^$/)
|
||||||
|
@ -171,7 +180,7 @@ Puppet::Type.type(:database_grant).provide(:mysql) do
|
||||||
# puts "set:", set
|
# puts "set:", set
|
||||||
stmt = stmt << set << where
|
stmt = stmt << set << where
|
||||||
|
|
||||||
mysql "mysql", "-Be", stmt
|
mysql defaults_file, "-Be", stmt
|
||||||
mysql_flush
|
mysql_flush
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,36 +7,45 @@ Puppet::Type.type(:database_user).provide(:mysql) do
|
||||||
optional_commands :mysql => 'mysql'
|
optional_commands :mysql => 'mysql'
|
||||||
optional_commands :mysqladmin => 'mysqladmin'
|
optional_commands :mysqladmin => 'mysqladmin'
|
||||||
|
|
||||||
|
def defaults_file
|
||||||
|
case Facter.value(:operatingsystem)
|
||||||
|
when "Debian", "Ubuntu"
|
||||||
|
return "--defaults-file=/etc/mysql/debian.cnf"
|
||||||
|
else
|
||||||
|
return ""
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def self.instances
|
def self.instances
|
||||||
users = mysql("mysql", '-BNe' "select concat(User, '@',Host) as User from mysql.user").split("\n")
|
users = mysql(defaults_file, '-BNe' "select concat(User, '@',Host) as User from mysql.user").split("\n")
|
||||||
users.select{ |user| user =~ /.+@/ }.collect do |name|
|
users.select{ |user| user =~ /.+@/ }.collect do |name|
|
||||||
new(:name => name)
|
new(:name => name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
mysql("mysql", "-e", "create user '%s' identified by PASSWORD '%s'" % [ @resource[:name].sub("@", "'@'"), @resource.value(:password_hash) ])
|
mysql(defaults_file, "-e", "create user '%s' identified by PASSWORD '%s'" % [ @resource[:name].sub("@", "'@'"), @resource.value(:password_hash) ])
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
mysql("mysql", "-e", "drop user '%s'" % @resource.value(:name).sub("@", "'@'") )
|
mysql(defaults_file, "-e", "drop user '%s'" % @resource.value(:name).sub("@", "'@'") )
|
||||||
end
|
end
|
||||||
|
|
||||||
def password_hash
|
def password_hash
|
||||||
mysql("mysql", "-NBe", "select password from user where CONCAT(user, '@', host) = '%s'" % @resource.value(:name)).chomp
|
mysql(defaults_file, "-NBe", "select password from user where CONCAT(user, '@', host) = '%s'" % @resource.value(:name)).chomp
|
||||||
end
|
end
|
||||||
|
|
||||||
def password_hash=(string)
|
def password_hash=(string)
|
||||||
mysql("mysql", "-e", "SET PASSWORD FOR '%s' = '%s'" % [ @resource[:name].sub("@", "'@'"), string ] )
|
mysql(defaults_file, "-e", "SET PASSWORD FOR '%s' = '%s'" % [ @resource[:name].sub("@", "'@'"), string ] )
|
||||||
end
|
end
|
||||||
|
|
||||||
def exists?
|
def exists?
|
||||||
not mysql("mysql", "-NBe", "select '1' from user where CONCAT(user, '@', host) = '%s'" % @resource.value(:name)).empty?
|
not mysql(defaults_file, "-NBe", "select '1' from user where CONCAT(user, '@', host) = '%s'" % @resource.value(:name)).empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
def flush
|
def flush
|
||||||
@property_hash.clear
|
@property_hash.clear
|
||||||
mysqladmin "flush-privileges"
|
mysqladmin(defaults_file, "flush-privileges")
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -30,22 +30,70 @@
|
||||||
# }
|
# }
|
||||||
#
|
#
|
||||||
class mysql::config(
|
class mysql::config(
|
||||||
$root_password = 'UNSET',
|
$root_password = 'UNSET',
|
||||||
$old_root_password = '',
|
$old_root_password = '',
|
||||||
$bind_address = $mysql::params::bind_address,
|
$bind_address = $mysql::params::bind_address,
|
||||||
$port = $mysql::params::port,
|
$port = $mysql::params::port,
|
||||||
$etc_root_password = $mysql::params::etc_root_password,
|
$etc_root_password = $mysql::params::etc_root_password,
|
||||||
$service_name = $mysql::params::service_name,
|
$service_name = $mysql::params::service_name,
|
||||||
$config_file = $mysql::params::config_file,
|
$config_file = $mysql::params::config_file,
|
||||||
$socket = $mysql::params::socket,
|
$socket = $mysql::params::socket,
|
||||||
$datadir = $mysql::params::datadir,
|
$datadir = $mysql::params::datadir,
|
||||||
$ssl = $mysql::params::ssl,
|
$ssl = $mysql::params::ssl,
|
||||||
$ssl_ca = $mysql::params::ssl_ca,
|
$ssl_ca = $mysql::params::ssl_ca,
|
||||||
$ssl_cert = $mysql::params::ssl_cert,
|
$ssl_cert = $mysql::params::ssl_cert,
|
||||||
$ssl_key = $mysql::params::ssl_key,
|
$ssl_key = $mysql::params::ssl_key,
|
||||||
$log_error = $mysql::params::log_error,
|
$log_error = $mysql::params::log_error,
|
||||||
$default_engine = 'UNSET',
|
$slow_query_log_file = $mysql::params::slow_query_log_file,
|
||||||
$root_group = $mysql::params::root_group
|
$long_query_time = $mysql::params::long_query_time,
|
||||||
|
$character_set_server = $mysql::params::character_set_server,
|
||||||
|
$collation_server = $mysql::params::collation_server,
|
||||||
|
$tmp_table_size = $mysql::params::tmp_table_size,
|
||||||
|
$max_heap_table_size = $mysql::params::max_heap_table_size,
|
||||||
|
$max_tmp_tables = $mysql::params::max_tmp_tables,
|
||||||
|
$join_buffer_size = $mysql::params::join_buffer_size,
|
||||||
|
$read_buffer_size = $mysql::params::read_buffer_size,
|
||||||
|
$sort_buffer_size = $mysql::params::sort_buffer_size,
|
||||||
|
$table_cache = $mysql::params::table_cache,
|
||||||
|
$table_definition_cache = $mysql::params::table_definition_cache,
|
||||||
|
$open_files_limit = $mysql::params::open_files_limit,
|
||||||
|
$thread_stack = $mysql::params::thread_stack,
|
||||||
|
$thread_cache_size = $mysql::params::thread_cache_size,
|
||||||
|
$thread_concurrency = $mysql::params::thread_concurrency,
|
||||||
|
$query_cache_size = $mysql::params::query_cache_size,
|
||||||
|
$query_cache_limit = $mysql::params::query_cache_limit,
|
||||||
|
$tmp_table_size = $mysql::params::tmp_table_size,
|
||||||
|
$read_rnd_buffer_size = $mysql::params::read_rnd_buffer_size,
|
||||||
|
$max_allowed_packet = $mysql::params::max_allowed_packet,
|
||||||
|
$max_connections = $mysql::params::max_connections,
|
||||||
|
$wait_timeout = $mysql::params::wait_timeout,
|
||||||
|
$connect_timeout = $mysql::params::connect_timeout,
|
||||||
|
$innodb_file_per_table = $mysql::params::innodb_file_per_table,
|
||||||
|
$innodb_status_file = $mysql::params::innodb_status_file,
|
||||||
|
$innodb_support_xa = $mysql::params::innodb_support_xa,
|
||||||
|
$read_only = $mysql::params::read_only,
|
||||||
|
$replication_enabled = $mysql::params::replication_enabled,
|
||||||
|
$expire_logs_days = $mysql::params::expire_logs_days,
|
||||||
|
$max_binlog_size = $mysql::params::max_binlog_size,
|
||||||
|
$replicate_ignore_table = $mysql::params::replicate_ignore_table,
|
||||||
|
$replicate_ignore_db = $mysql::params::replicate_ignore_db,
|
||||||
|
$replicate_do_table = $mysql::params::replicate_do_table,
|
||||||
|
$replicate_do_db = $mysql::params::replicate_do_db,
|
||||||
|
$extra_configs = $mysql::params::extra_configs,
|
||||||
|
$default_engine = 'UNSET',
|
||||||
|
$root_group = $mysql::params::root_group,
|
||||||
|
|
||||||
|
$key_buffer_size = $mysql::params::key_buffer_size,
|
||||||
|
$myisam_sort_buffer_size = $mysql::params::myisam_sort_buffer_size,
|
||||||
|
$myisam_max_sort_file_size = $mysql::params::myisam_max_sort_file_size,
|
||||||
|
$myisam_recover = $mysql::params::myisam_recover,
|
||||||
|
$innodb_flush_log_at_trx_commit = $mysql::params::innodb_flush_log_at_trx_commit,
|
||||||
|
$innodb_buffer_pool_size = $mysql::params::innodb_buffer_pool_size,
|
||||||
|
$innodb_log_file_size = $mysql::params::innodb_log_file_size,
|
||||||
|
$innodb_flush_method = $mysql::params::innodb_flush_method,
|
||||||
|
$innodb_thread_concurrency = $mysql::params::innodb_thread_concurrency,
|
||||||
|
$innodb_concurrency_tickets = $mysql::params::innodb_concurrency_tickets,
|
||||||
|
$innodb_doublewrite = $mysql::params::innodb_doublewrite,
|
||||||
) inherits mysql::params {
|
) inherits mysql::params {
|
||||||
|
|
||||||
File {
|
File {
|
||||||
|
|
|
@ -12,17 +12,67 @@
|
||||||
#
|
#
|
||||||
class mysql::params {
|
class mysql::params {
|
||||||
|
|
||||||
$bind_address = '127.0.0.1'
|
$bind_address = '127.0.0.1'
|
||||||
$port = 3306
|
$port = 3306
|
||||||
$etc_root_password = false
|
$etc_root_password = false
|
||||||
$ssl = false
|
$ssl = false
|
||||||
|
$slow_query_log_file = false
|
||||||
|
$long_query_time = 10
|
||||||
|
$character_set_server = 'utf8'
|
||||||
|
$collation_server = 'utf8_general_ci'
|
||||||
|
$ft_min_word_len = 3
|
||||||
|
$tmp_table_size = '16M'
|
||||||
|
$max_heap_table_size = '16M'
|
||||||
|
$max_tmp_tables = '32'
|
||||||
|
$join_buffer_size = '3M'
|
||||||
|
$read_buffer_size = '4M'
|
||||||
|
$sort_buffer_size = '4M'
|
||||||
|
$table_cache = '64'
|
||||||
|
$table_definition_cache = '256'
|
||||||
|
$open_files_limit = '1024'
|
||||||
|
$thread_stack = '192K'
|
||||||
|
$thread_cache_size = '8'
|
||||||
|
$thread_concurrency = '10'
|
||||||
|
$query_cache_size = '16M'
|
||||||
|
$query_cache_limit = '1M'
|
||||||
|
$tmp_table_size = '16M'
|
||||||
|
$read_rnd_buffer_size = '256K'
|
||||||
|
$key_buffer_size = '16M'
|
||||||
|
$myisam_sort_buffer_size = '8M'
|
||||||
|
$myisam_max_sort_file_size = '512M'
|
||||||
|
$myisam_recover = 'BACKUP'
|
||||||
|
$max_allowed_packet = "16M"
|
||||||
|
$max_connections = '151'
|
||||||
|
$wait_timeout = "28800"
|
||||||
|
$connect_timeout = "10"
|
||||||
|
$innodb_file_per_table = '1'
|
||||||
|
$innodb_status_file = '0'
|
||||||
|
$innodb_support_xa = '0'
|
||||||
|
$innodb_flush_log_at_trx_commit = '0'
|
||||||
|
$innodb_buffer_pool_size = '8M'
|
||||||
|
$innodb_log_file_size = '5M'
|
||||||
|
$innodb_flush_method = 'O_DIRECT'
|
||||||
|
$innodb_thread_concurrency = '8'
|
||||||
|
$innodb_concurrency_tickets = '500'
|
||||||
|
$innodb_doublewrite = '1'
|
||||||
|
$read_only = false
|
||||||
|
$replication_enabled = false
|
||||||
|
$expire_logs_days = '10'
|
||||||
|
$max_binlog_size = '100M'
|
||||||
|
$replicate_ignore_table = []
|
||||||
|
$replicate_ignore_db = []
|
||||||
|
$replicate_do_table = []
|
||||||
|
$replicate_do_db = []
|
||||||
|
$extra_configs = {}
|
||||||
|
|
||||||
case $::operatingsystem {
|
case $::operatingsystem {
|
||||||
"Ubuntu": {
|
"Ubuntu": {
|
||||||
$service_provider = upstart
|
$service_provider = upstart
|
||||||
|
$apparmor_file = 'mysql/templates/apparmor.usr.sbin.mysqld.erb'
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
$service_provider = undef
|
$service_provider = undef
|
||||||
|
$apparmor_file = undef
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@ class mysql::server (
|
||||||
$package_ensure = 'present',
|
$package_ensure = 'present',
|
||||||
$service_name = $mysql::params::service_name,
|
$service_name = $mysql::params::service_name,
|
||||||
$service_provider = $mysql::params::service_provider,
|
$service_provider = $mysql::params::service_provider,
|
||||||
|
$use_apparmor = false,
|
||||||
|
$apparmor_file = $mysql::params::apparmor_file,
|
||||||
$config_hash = {},
|
$config_hash = {},
|
||||||
$enabled = true
|
$enabled = true
|
||||||
) inherits mysql::params {
|
) inherits mysql::params {
|
||||||
|
@ -49,4 +51,16 @@ class mysql::server (
|
||||||
provider => $service_provider,
|
provider => $service_provider,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if $use_apparmor {
|
||||||
|
include apparmor
|
||||||
|
|
||||||
|
file { "/etc/apparmor.d/usr.sbin.mysqld":
|
||||||
|
owner => 'root',
|
||||||
|
group => 'root',
|
||||||
|
mode => 0644,
|
||||||
|
content => template($apparmor_file),
|
||||||
|
require => Package['mysql-server'],
|
||||||
|
notify => Class['apparmor'],
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
38
templates/apparmor.usr.sbin.mysqld.erb
Normal file
38
templates/apparmor.usr.sbin.mysqld.erb
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
# vim:syntax=apparmor
|
||||||
|
# Last Modified: Tue Jun 19 17:37:30 2007
|
||||||
|
#include <tunables/global>
|
||||||
|
|
||||||
|
/usr/sbin/mysqld {
|
||||||
|
#include <abstractions/base>
|
||||||
|
#include <abstractions/nameservice>
|
||||||
|
#include <abstractions/user-tmp>
|
||||||
|
#include <abstractions/mysql>
|
||||||
|
#include <abstractions/winbind>
|
||||||
|
|
||||||
|
capability dac_override,
|
||||||
|
capability sys_resource,
|
||||||
|
capability setgid,
|
||||||
|
capability setuid,
|
||||||
|
|
||||||
|
network tcp,
|
||||||
|
|
||||||
|
/etc/hosts.allow r,
|
||||||
|
/etc/hosts.deny r,
|
||||||
|
|
||||||
|
/etc/mysql/*.pem r,
|
||||||
|
/etc/mysql/conf.d/ r,
|
||||||
|
/etc/mysql/conf.d/* r,
|
||||||
|
<%= config_file %> r,
|
||||||
|
/usr/sbin/mysqld mr,
|
||||||
|
/usr/share/mysql/** r,
|
||||||
|
/var/log/mysql.log rw,
|
||||||
|
/var/log/mysql.err rw,
|
||||||
|
<%= datadir %>/ r,
|
||||||
|
<%= datadir %>/** rwk,
|
||||||
|
/var/log/mysql/ r,
|
||||||
|
/var/log/mysql/* rw,
|
||||||
|
<%= pid %> w,
|
||||||
|
<%= socket %> w,
|
||||||
|
|
||||||
|
/sys/devices/system/cpu/ r,
|
||||||
|
}
|
|
@ -1,42 +1,177 @@
|
||||||
[client]
|
###
|
||||||
port = <%= port %>
|
#### This file managed by puppet.
|
||||||
socket = <%= socket %>
|
###
|
||||||
[mysqld_safe]
|
|
||||||
socket = <%= socket %>
|
#
|
||||||
nice = 0
|
# * IMPORTANT
|
||||||
|
# If you make changes to these settings and your system uses apparmor, you may
|
||||||
|
# also need to also adjust /etc/apparmor.d/usr.sbin.mysqld.
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
[mysqld]
|
[mysqld]
|
||||||
user = mysql
|
basedir = <%= basedir %>
|
||||||
socket = <%= socket %>
|
datadir = <%= datadir %>
|
||||||
port = <%= port %>
|
tmpdir = <%= tmpdir %>
|
||||||
basedir = <%= basedir %>
|
socket = <%= socket %>
|
||||||
datadir = <%= datadir %>
|
pid-file = <%= pid %>
|
||||||
tmpdir = /tmp
|
user = mysql
|
||||||
skip-external-locking
|
|
||||||
bind-address = <%= bind_address %>
|
|
||||||
key_buffer = 16M
|
##############
|
||||||
max_allowed_packet = 16M
|
# Networking #
|
||||||
thread_stack = 192K
|
##############
|
||||||
thread_cache_size = 8
|
|
||||||
myisam-recover = BACKUP
|
bind_address = <%= bind_address %>
|
||||||
query_cache_limit = 1M
|
port = <%= port %>
|
||||||
query_cache_size = 16M
|
skip_name_resolve
|
||||||
log_error = <%= log_error %>
|
skip_external_locking
|
||||||
expire_logs_days = 10
|
max_allowed_packet = <%= max_allowed_packet %>
|
||||||
max_binlog_size = 100M
|
max_connections = <%= max_connections %>
|
||||||
|
wait_timeout = <%= wait_timeout %>
|
||||||
|
connect_timeout = <%= connect_timeout %>
|
||||||
|
|
||||||
|
|
||||||
|
###########
|
||||||
|
# Logging #
|
||||||
|
###########
|
||||||
|
log_error = <%= log_error %>
|
||||||
|
|
||||||
|
<% if slow_query_log_file -%>
|
||||||
|
slow_query_log = 1
|
||||||
|
slow_query_log_file = <%= slow_query_log_file %>
|
||||||
|
long_query_time = <%= long_query_time %>
|
||||||
|
<% end -%>
|
||||||
|
|
||||||
|
# Character Set
|
||||||
|
character_set_server = <%= character_set_server %>
|
||||||
|
collation_server = <%= collation_server %>
|
||||||
|
|
||||||
|
# Fulltext searches to find words smaller than <%= ft_min_word_len %> characters
|
||||||
|
ft_min_word_len = <%= ft_min_word_len %>
|
||||||
|
|
||||||
|
|
||||||
|
####################################
|
||||||
|
# Buffers, Threads, Caches, Limits #
|
||||||
|
####################################
|
||||||
|
tmp_table_size = <%= tmp_table_size %>
|
||||||
|
max_heap_table_size = <%= max_heap_table_size %>
|
||||||
|
max_tmp_tables = <%= max_tmp_tables %>
|
||||||
|
|
||||||
|
join_buffer_size = <%= join_buffer_size %>
|
||||||
|
read_buffer_size = <%= read_buffer_size %>
|
||||||
|
sort_buffer_size = <%= sort_buffer_size %>
|
||||||
|
|
||||||
|
table_cache = <%= table_cache %>
|
||||||
|
table_definition_cache = <%= table_definition_cache %>
|
||||||
|
open_files_limit = <%= open_files_limit %>
|
||||||
|
|
||||||
|
thread_stack = <%= thread_stack %>
|
||||||
|
thread_cache_size = <%= thread_cache_size %>
|
||||||
|
thread_concurrency = <%= thread_concurrency %>
|
||||||
|
|
||||||
|
query_cache_size = <%= query_cache_size %>
|
||||||
|
query_cache_limit = <%= query_cache_limit %>
|
||||||
|
tmp_table_size = <%= tmp_table_size %>
|
||||||
|
read_rnd_buffer_size = <%= read_rnd_buffer_size %>
|
||||||
|
|
||||||
<% if default_engine != 'UNSET' %>
|
<% if default_engine != 'UNSET' %>
|
||||||
default-storage-engine = <%= default_engine %>
|
default-storage-engine = <%= default_engine %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if ssl == true %>
|
<% if ssl == true %>
|
||||||
ssl-ca = <%= ssl_ca %>
|
ssl-ca = <%= ssl_ca %>
|
||||||
ssl-cert = <%= ssl_cert %>
|
ssl-cert = <%= ssl_cert %>
|
||||||
ssl-key = <%= ssl_key %>
|
ssl-key = <%= ssl_key %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
|
###################
|
||||||
|
# MyISAM Settings #
|
||||||
|
###################
|
||||||
|
key_buffer_size = <%= key_buffer_size %>
|
||||||
|
myisam_sort_buffer_size = <%= myisam_sort_buffer_size %>
|
||||||
|
myisam_max_sort_file_size = <%= myisam_max_sort_file_size %>
|
||||||
|
myisam_recover = <%= myisam_recover %>
|
||||||
|
|
||||||
|
|
||||||
|
###################
|
||||||
|
# InnoDB Settings #
|
||||||
|
###################
|
||||||
|
innodb_file_per_table = <%= innodb_file_per_table %>
|
||||||
|
innodb_status_file = <%= innodb_status_file %>
|
||||||
|
innodb_support_xa = <%= innodb_support_xa %>
|
||||||
|
innodb_flush_log_at_trx_commit = <%= innodb_flush_log_at_trx_commit %>
|
||||||
|
innodb_buffer_pool_size = <%= innodb_buffer_pool_size %>
|
||||||
|
innodb_log_file_size = <%= innodb_log_file_size %>
|
||||||
|
innodb_log_group_home_dir = <%= datadir %>
|
||||||
|
innodb_flush_method = <%= innodb_flush_method %>
|
||||||
|
innodb_thread_concurrency = <%= innodb_thread_concurrency %>
|
||||||
|
innodb_concurrency_tickets = <%= innodb_concurrency_tickets %>
|
||||||
|
innodb_doublewrite = <%= innodb_doublewrite %>
|
||||||
|
|
||||||
|
<% if replication_enabled -%>
|
||||||
|
|
||||||
|
########################
|
||||||
|
# Replication Settings #
|
||||||
|
########################
|
||||||
|
log_bin = <%= bindir %>/bin
|
||||||
|
relay-log = <%= bindir %>/relay-bin
|
||||||
|
relay-log-index = <%= bindir %>/relay-bin.index
|
||||||
|
expire_logs_days = <%= expire_logs_days %>
|
||||||
|
max_binlog_size = <%= max_binlog_size %>
|
||||||
|
|
||||||
|
# Log slave updates so that any machine may be a master
|
||||||
|
log_slave_updates
|
||||||
|
|
||||||
|
# report as <%= hostname + '.' + port %> to master
|
||||||
|
report-host=<%= hostname + '.' + port %>
|
||||||
|
|
||||||
|
<% #automatically generate a unique master server-id from IP -%>
|
||||||
|
<% ia = ipaddress.split('.'); server_id = ia[0] + ia[2] + ia[3]; -%>
|
||||||
|
server-id = <%= server_id %>
|
||||||
|
|
||||||
|
<% replicate_ignore_db.each do |db| -%>
|
||||||
|
replicate_ignore_db = <%= db %>
|
||||||
|
<% end -%>
|
||||||
|
<% replicate_ignore_table.each do |table| -%>
|
||||||
|
replicate_ignore_table = <%= table %>
|
||||||
|
<% end -%>
|
||||||
|
<% replicate_do_db.each do |db| -%>
|
||||||
|
replicate_do_db = <%= db %>
|
||||||
|
<% end -%>
|
||||||
|
<% replicate_do_table.each do |table| -%>
|
||||||
|
replicate_do_table = <%= table %>
|
||||||
|
<% end -%>
|
||||||
|
|
||||||
|
<% end # if replication_enabled -%>
|
||||||
|
|
||||||
|
<% # set read_only mode based on read_only variable -%>
|
||||||
|
read_only = <%= read_only ? 1 : 0 %>
|
||||||
|
|
||||||
|
<% # render out any extra_configs as key = value pairs -%>
|
||||||
|
<% extra_configs.each do |key, value| -%>
|
||||||
|
<%= "#{key} = #{value}" %>
|
||||||
|
<% end -%>
|
||||||
|
|
||||||
|
# This will be passed to all mysql clients
|
||||||
|
# It has been reported that passwords should be enclosed with ticks/quotes
|
||||||
|
# escpecially if they contain "#" chars...
|
||||||
|
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
|
||||||
|
[client]
|
||||||
|
port = <%= port %>
|
||||||
|
socket = <%= socket %>
|
||||||
|
|
||||||
[mysqldump]
|
[mysqldump]
|
||||||
quick
|
quick
|
||||||
quote-names
|
quote-names
|
||||||
max_allowed_packet = 16M
|
max_allowed_packet = <%= max_allowed_packet %>
|
||||||
|
|
||||||
[mysql]
|
[mysql]
|
||||||
[isamchk]
|
#no-auto-rehash # faster start of mysql but no tab completition
|
||||||
key_buffer = 16M
|
|
||||||
|
#
|
||||||
|
# * IMPORTANT: Additional settings that can override those from this file!
|
||||||
|
# The files must end with '.cnf', otherwise they'll be ignored.
|
||||||
|
#
|
||||||
!includedir /etc/mysql/conf.d/
|
!includedir /etc/mysql/conf.d/
|
||||||
|
|
Loading…
Reference in a new issue